Commit c6e72f07 authored by David Faure's avatar David Faure
Browse files

Clean up a little, to use KPluginInfo a bit less

parent 1b44dfaf
...@@ -350,16 +350,11 @@ void MainWindow::setupActions() ...@@ -350,16 +350,11 @@ void MainWindow::setupActions()
connect(mShowHideAction, &QAction::triggered, this, &MainWindow::slotShowHideSideBar); connect(mShowHideAction, &QAction::triggered, this, &MainWindow::slotShowHideSideBar);
} }
bool MainWindow::isPluginLoaded(const KPluginInfo &info) KontactInterface::Plugin *MainWindow::pluginFromName(const QString &identifier)
{
return pluginFromInfo(info) != nullptr;
}
KontactInterface::Plugin *MainWindow::pluginFromInfo(const KPluginInfo &info)
{ {
const PluginList::ConstIterator end = mPlugins.constEnd(); const PluginList::ConstIterator end = mPlugins.constEnd();
for (PluginList::ConstIterator it = mPlugins.constBegin(); it != end; ++it) { for (PluginList::ConstIterator it = mPlugins.constBegin(); it != end; ++it) {
if ((*it)->identifier() == info.pluginName()) { if ((*it)->identifier() == identifier) {
return *it; return *it;
} }
} }
...@@ -376,12 +371,9 @@ void MainWindow::loadPlugins() ...@@ -376,12 +371,9 @@ void MainWindow::loadPlugins()
continue; continue;
} }
KontactInterface::Plugin *plugin = nullptr; KontactInterface::Plugin *plugin = pluginFromName(pluginInfo.pluginName());
if (isPluginLoaded(pluginInfo)) { if (plugin) { // already loaded
plugin = pluginFromInfo(pluginInfo); plugin->configUpdated();
if (plugin) {
plugin->configUpdated();
}
continue; continue;
} }
...@@ -390,7 +382,7 @@ void MainWindow::loadPlugins() ...@@ -390,7 +382,7 @@ void MainWindow::loadPlugins()
plugin = pluginInfo.service()->createInstance<KontactInterface::Plugin>(this, QVariantList(), &error); plugin = pluginInfo.service()->createInstance<KontactInterface::Plugin>(this, QVariantList(), &error);
if (!plugin) { if (!plugin) {
qCDebug(KONTACT_LOG) << "Unable to create plugin for" << pluginInfo.name() << error; qCDebug(KONTACT_LOG) << "Unable to create plugin for" << pluginInfo.name() << pluginInfo.service()->entryPath() << error;
continue; continue;
} }
...@@ -940,7 +932,7 @@ void MainWindow::saveProperties(KConfigGroup &config) ...@@ -940,7 +932,7 @@ void MainWindow::saveProperties(KConfigGroup &config)
for (const KPluginInfo &pluginInfo : qAsConst(mPluginInfos)) { for (const KPluginInfo &pluginInfo : qAsConst(mPluginInfos)) {
if (pluginInfo.isPluginEnabled()) { if (pluginInfo.isPluginEnabled()) {
KontactInterface::Plugin *plugin = pluginFromInfo(pluginInfo); KontactInterface::Plugin *plugin = pluginFromName(pluginInfo.pluginName());
if (plugin) { if (plugin) {
activePlugins.append(plugin->identifier()); activePlugins.append(plugin->identifier());
plugin->saveProperties(config); plugin->saveProperties(config);
......
...@@ -92,7 +92,7 @@ private: ...@@ -92,7 +92,7 @@ private:
void saveSettings(); void saveSettings();
bool isPluginLoaded(const KPluginInfo &); bool isPluginLoaded(const KPluginInfo &);
KontactInterface::Plugin *pluginFromInfo(const KPluginInfo &); KontactInterface::Plugin *pluginFromName(const QString &identifier);
void loadPlugins(); void loadPlugins();
void unloadPlugins(); void unloadPlugins();
void updateShortcuts(); void updateShortcuts();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment