Commit 05571caa authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to KPluginMetaData::findPlugins

parent 68316021
Pipeline #75632 passed with stage
in 5 minutes and 27 seconds
......@@ -5,6 +5,7 @@
*/
#include "pluginmanager.h"
#include "kcoreaddons_version.h"
#include "libkaddressbookexportimport_debug.h"
#include "plugin.h"
......@@ -33,6 +34,7 @@ public:
QString metaDataFileNameBaseName;
QString metaDataFileName;
PimCommon::PluginUtilData pluginData;
KPluginMetaData data;
Plugin *plugin = nullptr;
bool isEnabled = true;
};
......@@ -76,7 +78,11 @@ private:
bool PluginManagerPrivate::initializePlugins()
{
#if KCOREADDONS_VERSION > QT_VERSION_CHECK(5, 85, 0)
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("kaddressbook/importexportplugin"));
#else
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("kaddressbook/importexportplugin"));
#endif
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
......@@ -94,6 +100,7 @@ bool PluginManagerPrivate::initializePlugins()
info.isEnabled = isPluginActivated;
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.data = data;
if (pluginVersion() == data.version()) {
info.plugin = nullptr;
mPluginList.push_back(info);
......@@ -110,6 +117,14 @@ bool PluginManagerPrivate::initializePlugins()
void PluginManagerPrivate::loadPlugin(ImportExportInfo *item)
{
#if KCOREADDONS_VERSION > QT_VERSION_CHECK(5, 85, 0)
if (auto plugin = KPluginFactory::instantiatePlugin<Plugin>(item->data, q, QVariantList() << item->metaDataFileNameBaseName).plugin) {
item->plugin = plugin;
item->plugin->setIsEnabled(item->isEnabled);
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
mPluginDataList.append(item->pluginData);
}
#else
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<Plugin>(q, QVariantList() << item->metaDataFileNameBaseName);
......@@ -117,6 +132,7 @@ void PluginManagerPrivate::loadPlugin(ImportExportInfo *item)
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
mPluginDataList.append(item->pluginData);
}
#endif
}
QVector<Plugin *> PluginManagerPrivate::pluginsList() const
......
......@@ -16,6 +16,7 @@
#include "kaddressbook_options.h"
#include "kaddressbookadaptor.h"
#include "kcmutils_version.h"
#include "kcoreaddons_version.h"
#include "manageshowcollectionproperties.h"
#include "modelcolumnmanager.h"
#include "printing/printingwizard.h"
......@@ -353,7 +354,11 @@ void MainWidget::initializeImportExportPlugin(KActionCollection *collection)
void MainWidget::configure()
{
QPointer<KCMultiDialog> dlg = new KCMultiDialog(this);
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> availablePlugins = KPluginLoader::findPlugins(QStringLiteral("pim/kcms/kaddressbook"));
#else
const QVector<KPluginMetaData> availablePlugins = KPluginMetaData::findPlugins(QStringLiteral("pim/kcms/kaddressbook"));
#endif
for (const KPluginMetaData &metaData : availablePlugins) {
dlg->addModule(metaData);
}
......
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