Changeset View
Changeset View
Standalone View
Standalone View
utils/okteta/oktetaplugin.cpp
Show All 21 Lines | |||||
22 | 22 | | |||
23 | #include "oktetaplugin.h" | 23 | #include "oktetaplugin.h" | ||
24 | 24 | | |||
25 | // plugin | 25 | // plugin | ||
26 | #include "oktetadocumentfactory.h" | 26 | #include "oktetadocumentfactory.h" | ||
27 | #include "oktetatoolviewfactory.h" | 27 | #include "oktetatoolviewfactory.h" | ||
28 | #include "oktetadocument.h" | 28 | #include "oktetadocument.h" | ||
29 | // Okteta Kasten tools | 29 | // Okteta Kasten tools | ||
30 | #include <stringsextracttoolviewfactory.h> | 30 | #include <kasten/okteta/stringsextracttoolviewfactory.h> | ||
31 | #include <stringsextracttoolfactory.h> | 31 | #include <kasten/okteta/stringsextracttoolfactory.h> | ||
32 | #include <infotoolviewfactory.h> | 32 | #include <kasten/okteta/infotoolviewfactory.h> | ||
33 | #include <infotoolfactory.h> | 33 | #include <kasten/okteta/infotoolfactory.h> | ||
34 | #include <filtertoolviewfactory.h> | 34 | #include <kasten/okteta/filtertoolviewfactory.h> | ||
35 | #include <filtertoolfactory.h> | 35 | #include <kasten/okteta/filtertoolfactory.h> | ||
36 | #include <checksumtoolviewfactory.h> | 36 | #include <kasten/okteta/checksumtoolviewfactory.h> | ||
37 | #include <checksumtoolfactory.h> | 37 | #include <kasten/okteta/checksumtoolfactory.h> | ||
38 | // #include <documentinfotoolview.h> | 38 | // #include <documentinfotoolview.h> | ||
39 | // #include <documentinfotool.h> | 39 | // #include <documentinfotool.h> | ||
40 | #include <poddecodertoolviewfactory.h> | 40 | #include <kasten/okteta/poddecodertoolviewfactory.h> | ||
41 | #include <poddecodertoolfactory.h> | 41 | #include <kasten/okteta/poddecodertoolfactory.h> | ||
42 | #include <bytetabletoolviewfactory.h> | 42 | #include <kasten/okteta/bytetabletoolviewfactory.h> | ||
43 | #include <bytetabletoolfactory.h> | 43 | #include <kasten/okteta/bytetabletoolfactory.h> | ||
44 | #include <bookmarkstoolviewfactory.h> | 44 | #include <kasten/okteta/bookmarkstoolviewfactory.h> | ||
45 | #include <bookmarkstoolfactory.h> | 45 | #include <kasten/okteta/bookmarkstoolfactory.h> | ||
46 | #ifndef BIG_ENDIAN | 46 | #ifndef BIG_ENDIAN | ||
47 | #include <structurestoolviewfactory.h> | 47 | #include <kasten/okteta/structurestoolviewfactory.h> | ||
48 | #include <structurestoolfactory.h> | 48 | #include <kasten/okteta/structurestoolfactory.h> | ||
49 | #endif | 49 | #endif | ||
50 | // Okteta Kasten | 50 | // Okteta Kasten | ||
51 | #if KASTEN_VERSION == 2 | 51 | #include <kasten/okteta/bytearrayviewprofilemanager.h> | ||
52 | #include <bytearrayviewprofilemanager.h> | | |||
53 | #endif | | |||
54 | // KDev | 52 | // KDev | ||
55 | #include <project/projectmodel.h> | 53 | #include <project/projectmodel.h> | ||
56 | #include <interfaces/icore.h> | 54 | #include <interfaces/icore.h> | ||
57 | #include <interfaces/idocumentcontroller.h> | 55 | #include <interfaces/idocumentcontroller.h> | ||
58 | #include <interfaces/iuicontroller.h> | 56 | #include <interfaces/iuicontroller.h> | ||
59 | #include <interfaces/contextmenuextension.h> | 57 | #include <interfaces/contextmenuextension.h> | ||
60 | #include <interfaces/context.h> | 58 | #include <interfaces/context.h> | ||
61 | // KDE | 59 | // KDE | ||
62 | #include <KAboutData> | 60 | #include <KAboutData> | ||
63 | #include <KPluginFactory> | 61 | #include <KPluginFactory> | ||
62 | #include <KLocalizedString> | ||||
64 | 63 | | |||
65 | #include <QAction> | 64 | #include <QAction> | ||
66 | 65 | | |||
67 | K_PLUGIN_FACTORY(OktetaPluginFactory, registerPlugin<KDevelop::OktetaPlugin>(); ) | 66 | K_PLUGIN_FACTORY_WITH_JSON(OktetaPluginFactory, "kdevokteta.json", registerPlugin<KDevelop::OktetaPlugin>(); ) | ||
68 | 67 | | |||
69 | namespace KDevelop | 68 | namespace KDevelop | ||
70 | { | 69 | { | ||
71 | 70 | | |||
72 | static inline | 71 | static inline | ||
73 | void addTool( IUiController* uiController, | 72 | void addTool( IUiController* uiController, | ||
74 | Kasten::AbstractToolViewFactory* toolViewFactory, | 73 | Kasten::AbstractToolViewFactory* toolViewFactory, | ||
75 | Kasten::AbstractToolFactory* toolFactory ) | 74 | Kasten::AbstractToolFactory* toolFactory ) | ||
76 | { | 75 | { | ||
77 | OktetaToolViewFactory* factory = | 76 | OktetaToolViewFactory* factory = | ||
78 | new OktetaToolViewFactory( toolViewFactory, toolFactory ); | 77 | new OktetaToolViewFactory( toolViewFactory, toolFactory ); | ||
79 | 78 | | |||
80 | uiController->addToolView( toolViewFactory->title(), factory ); | 79 | uiController->addToolView( toolViewFactory->title(), factory ); | ||
81 | } | 80 | } | ||
82 | 81 | | |||
83 | 82 | | |||
84 | OktetaPlugin::OktetaPlugin( QObject* parent, const QVariantList& args ) | 83 | OktetaPlugin::OktetaPlugin( QObject* parent, const QVariantList& args ) | ||
85 | : IPlugin( "kdevokteta", parent ) | 84 | : IPlugin( "kdevokteta", parent ) | ||
86 | , mDocumentFactory( new OktetaDocumentFactory(this) ) | 85 | , mDocumentFactory( new OktetaDocumentFactory(this) ) | ||
87 | #if KASTEN_VERSION == 2 | | |||
88 | , mViewProfileManager( new Kasten::ByteArrayViewProfileManager() ) | 86 | , mViewProfileManager( new Kasten::ByteArrayViewProfileManager() ) | ||
89 | #endif | | |||
90 | { | 87 | { | ||
91 | Q_UNUSED(args) | 88 | Q_UNUSED(args) | ||
92 | 89 | | |||
93 | #if KASTEN_VERSION == 0 || KASTEN_VERSION == 1 | | |||
94 | KLocale* globalLocale = KGlobal::locale(); | | |||
95 | globalLocale->insertCatalog( QString::fromLatin1("liboktetacore") ); | | |||
96 | globalLocale->insertCatalog( QString::fromLatin1("libkasten") ); | | |||
97 | globalLocale->insertCatalog( QString::fromLatin1("liboktetakasten") ); | | |||
98 | #endif | | |||
99 | | ||||
100 | IUiController* uiController = core()->uiController(); | 90 | IUiController* uiController = core()->uiController(); | ||
101 | addTool( uiController, new Kasten::ChecksumToolViewFactory(), new Kasten::ChecksumToolFactory() ); | 91 | addTool( uiController, new Kasten::ChecksumToolViewFactory(), new Kasten::ChecksumToolFactory() ); | ||
102 | addTool( uiController, new Kasten::FilterToolViewFactory(), new Kasten::FilterToolFactory() ); | 92 | addTool( uiController, new Kasten::FilterToolViewFactory(), new Kasten::FilterToolFactory() ); | ||
103 | addTool( uiController, new Kasten::StringsExtractToolViewFactory, new Kasten::StringsExtractToolFactory() ); | 93 | addTool( uiController, new Kasten::StringsExtractToolViewFactory, new Kasten::StringsExtractToolFactory() ); | ||
104 | addTool( uiController, new Kasten::ByteTableToolViewFactory(), new Kasten::ByteTableToolFactory() ); | 94 | addTool( uiController, new Kasten::ByteTableToolViewFactory(), new Kasten::ByteTableToolFactory() ); | ||
105 | addTool( uiController, new Kasten::InfoToolViewFactory(), new Kasten::InfoToolFactory() ); | 95 | addTool( uiController, new Kasten::InfoToolViewFactory(), new Kasten::InfoToolFactory() ); | ||
106 | addTool( uiController, new Kasten::PodDecoderToolViewFactory(), new Kasten::PodDecoderToolFactory() ); | 96 | addTool( uiController, new Kasten::PodDecoderToolViewFactory(), new Kasten::PodDecoderToolFactory() ); | ||
107 | // disable Okteta Structures tool on big-endian as it's disable in kdesdk | 97 | // disable Okteta Structures tool on big-endian as it's disable in kdesdk | ||
108 | #ifndef BIG_ENDIAN | 98 | #ifndef BIG_ENDIAN | ||
109 | addTool( uiController, new Kasten::StructuresToolViewFactory(), new Kasten::StructuresToolFactory() ); | 99 | addTool( uiController, new Kasten::StructuresToolViewFactory(), new Kasten::StructuresToolFactory() ); | ||
110 | #endif | 100 | #endif | ||
111 | addTool( uiController, new Kasten::BookmarksToolViewFactory, new Kasten::BookmarksToolFactory() ); | 101 | addTool( uiController, new Kasten::BookmarksToolViewFactory, new Kasten::BookmarksToolFactory() ); | ||
112 | 102 | | |||
113 | KDevelop::IDocumentController* documentController = core()->documentController(); | 103 | KDevelop::IDocumentController* documentController = core()->documentController(); | ||
114 | documentController->registerDocumentForMimetype("application/octet-stream", mDocumentFactory); | 104 | documentController->registerDocumentForMimetype("application/octet-stream", mDocumentFactory); | ||
115 | } | 105 | } | ||
116 | 106 | | |||
117 | ContextMenuExtension OktetaPlugin::contextMenuExtension( Context* context ) | 107 | ContextMenuExtension OktetaPlugin::contextMenuExtension( Context* context ) | ||
118 | { | 108 | { | ||
119 | OpenWithContext* openWithContext = dynamic_cast<OpenWithContext*>( context ); | 109 | OpenWithContext* openWithContext = dynamic_cast<OpenWithContext*>( context ); | ||
120 | 110 | | |||
121 | if( openWithContext && !openWithContext->mimeType()->is("inode/directory")) | 111 | if( openWithContext && !openWithContext->mimeType().inherits("inode/directory")) | ||
122 | { | 112 | { | ||
123 | QAction* openAction = new QAction( i18n("Hex Editor"), this ); | 113 | QAction* openAction = new QAction( i18n("Hex Editor"), this ); | ||
124 | openAction->setIcon( QIcon::fromTheme("document-open") ); | 114 | openAction->setIcon( QIcon::fromTheme("document-open") ); | ||
125 | openAction->setData( openWithContext->urls() ); | 115 | openAction->setData( QVariant::fromValue(openWithContext->urls()) ); | ||
126 | connect( openAction, SIGNAL(triggered()), SLOT(onOpenTriggered()) ); | 116 | connect( openAction, &QAction::triggered, this, &OktetaPlugin::onOpenTriggered ); | ||
kfunk: `QVariant::fromValue(...)`? | |||||
127 | 117 | | |||
128 | KDevelop::ContextMenuExtension contextMenuExtension; | 118 | KDevelop::ContextMenuExtension contextMenuExtension; | ||
129 | contextMenuExtension.addAction( KDevelop::ContextMenuExtension::OpenEmbeddedGroup, openAction ); | 119 | contextMenuExtension.addAction( KDevelop::ContextMenuExtension::OpenEmbeddedGroup, openAction ); | ||
130 | return contextMenuExtension; | 120 | return contextMenuExtension; | ||
131 | } | 121 | } | ||
132 | 122 | | |||
133 | return KDevelop::IPlugin::contextMenuExtension( context ); | 123 | return KDevelop::IPlugin::contextMenuExtension( context ); | ||
134 | } | 124 | } | ||
Show All 20 Lines | |||||
155 | } | 145 | } | ||
156 | 146 | | |||
157 | OktetaPlugin::~OktetaPlugin() | 147 | OktetaPlugin::~OktetaPlugin() | ||
158 | { | 148 | { | ||
159 | delete mDocumentFactory; | 149 | delete mDocumentFactory; | ||
160 | } | 150 | } | ||
161 | 151 | | |||
162 | } | 152 | } | ||
153 | | ||||
154 | #include "oktetaplugin.moc" |
QVariant::fromValue(...)?