Auto status change to "Under Review"
@@ -25,6 +25,7 | |||||
25 | #include <SqpApplication.h> |
|
25 | #include <SqpApplication.h> | |
26 | #include <qglobal.h> |
|
26 | #include <qglobal.h> | |
27 |
|
27 | |||
|
28 | #include <QtPlugin> | |||
28 | #include <Plugin/PluginManager.h> |
|
29 | #include <Plugin/PluginManager.h> | |
29 | #include <QDir> |
|
30 | #include <QDir> | |
30 |
|
31 | |||
@@ -41,6 +42,13 const auto PLUGIN_DIRECTORY_NAME = QStringLiteral("plugins"); | |||||
41 |
|
42 | |||
42 | int main(int argc, char *argv[]) |
|
43 | int main(int argc, char *argv[]) | |
43 | { |
|
44 | { | |
|
45 | #ifdef QT_STATICPLUGIN | |||
|
46 | Q_IMPORT_PLUGIN(MockPlugin) | |||
|
47 | Q_IMPORT_PLUGIN(AmdaPlugin) | |||
|
48 | Q_INIT_RESOURCE(amdaresources); | |||
|
49 | #endif | |||
|
50 | Q_INIT_RESOURCE(sqpguiresources); | |||
|
51 | ||||
44 | SqpApplication a{argc, argv}; |
|
52 | SqpApplication a{argc, argv}; | |
45 | SqpApplication::setOrganizationName("LPP"); |
|
53 | SqpApplication::setOrganizationName("LPP"); | |
46 | SqpApplication::setOrganizationDomain("lpp.fr"); |
|
54 | SqpApplication::setOrganizationDomain("lpp.fr"); | |
@@ -75,6 +83,7 int main(int argc, char *argv[]) | |||||
75 | pluginManager.loadPlugins(directory); |
|
83 | pluginManager.loadPlugins(directory); | |
76 | } |
|
84 | } | |
77 | } |
|
85 | } | |
|
86 | pluginManager.loadStaticPlugins(); | |||
78 |
|
87 | |||
79 | return a.exec(); |
|
88 | return a.exec(); | |
80 | } |
|
89 | } |
@@ -25,11 +25,16 public: | |||||
25 | */ |
|
25 | */ | |
26 | void loadPlugins(const QDir &pluginDir); |
|
26 | void loadPlugins(const QDir &pluginDir); | |
27 |
|
27 | |||
|
28 | /** | |||
|
29 | * Loads static plugins into SciQlop. SciQLOP supports statically linked plugins. | |||
|
30 | */ | |||
|
31 | void loadStaticPlugins(); | |||
|
32 | ||||
28 | /// @returns the number of plugins loaded |
|
33 | /// @returns the number of plugins loaded | |
29 | int nbPluginsLoaded() const noexcept; |
|
34 | int nbPluginsLoaded() const noexcept; | |
30 |
|
35 | |||
31 | private: |
|
36 | private: | |
32 |
|
|
37 | struct PluginManagerPrivate; | |
33 | spimpl::unique_impl_ptr<PluginManagerPrivate> impl; |
|
38 | spimpl::unique_impl_ptr<PluginManagerPrivate> impl; | |
34 | }; |
|
39 | }; | |
35 |
|
40 |
@@ -95,6 +95,15 struct PluginManager::PluginManagerPrivate { | |||||
95 | loadState.log(); |
|
95 | loadState.log(); | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
|
98 | void loadStaticPlugins() | |||
|
99 | { | |||
|
100 | for (QObject *plugin : QPluginLoader::staticInstances()) | |||
|
101 | { | |||
|
102 | qobject_cast<IPlugin *>(plugin)->initialize(); | |||
|
103 | m_RegisteredPlugins.insert(plugin->metaObject()->className(), "StaticPlugin"); | |||
|
104 | } | |||
|
105 | } | |||
|
106 | ||||
98 | /// Registered plugins (key: plugin name, value: plugin path) |
|
107 | /// Registered plugins (key: plugin name, value: plugin path) | |
99 | QHash<QString, QString> m_RegisteredPlugins; |
|
108 | QHash<QString, QString> m_RegisteredPlugins; | |
100 | }; |
|
109 | }; | |
@@ -118,6 +127,11 void PluginManager::loadPlugins(const QDir &pluginDir) | |||||
118 | } |
|
127 | } | |
119 | } |
|
128 | } | |
120 |
|
129 | |||
|
130 | void PluginManager::loadStaticPlugins() | |||
|
131 | { | |||
|
132 | impl->loadStaticPlugins(); | |||
|
133 | } | |||
|
134 | ||||
121 | int PluginManager::nbPluginsLoaded() const noexcept |
|
135 | int PluginManager::nbPluginsLoaded() const noexcept | |
122 | { |
|
136 | { | |
123 | return impl->m_RegisteredPlugins.size(); |
|
137 | return impl->m_RegisteredPlugins.size(); |
General Comments 3
Status change > Approved
You need to be logged in to leave comments.
Login now