Commit 69d0919e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to new api

parent 1aea133b
Pipeline #75643 failed with stage
in 4 minutes and 25 seconds
......@@ -6,6 +6,7 @@
#include "customtoolspluginmanager.h"
#include "customtoolsplugin.h"
#include "kcoreaddons_version.h"
#include <KPluginFactory>
#include <KPluginLoader>
......@@ -56,7 +57,11 @@ public:
void CustomToolsPluginManagerPrivate::initializePluginList()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("pimcommon/customtools"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("pimcommon/customtools"));
#endif
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
......@@ -96,10 +101,16 @@ QVector<PimCommon::CustomToolsPlugin *> CustomToolsPluginManagerPrivate::plugins
void CustomToolsPluginManagerPrivate::loadPlugin(CustomToolsPluginInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 85, 0)
KPluginLoader pluginLoader(item->metaData.fileName());
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<PimCommon::CustomToolsPlugin>(q, QVariantList() << item->saveName());
}
#else
if (auto plugin = KPluginFactory::instantiatePlugin<PimCommon::CustomToolsPlugin>(item->metaData, q, QVariantList() << item->saveName()).plugin) {
item->plugin = plugin;
}
#endif
}
CustomToolsPluginManager *CustomToolsPluginManager::self()
......
......@@ -6,6 +6,7 @@
#include "genericpluginmanager.h"
#include "genericplugin.h"
#include "kcoreaddons_version.h"
#include "pimcommon_debug.h"
#include <KPluginFactory>
......@@ -22,6 +23,7 @@ public:
{
}
KPluginMetaData data;
QString metaDataFileNameBaseName;
QString metaDataFileName;
PimCommon::PluginUtilData pluginData;
......@@ -81,7 +83,11 @@ bool GenericPluginManagerPrivate::initializePlugins()
if (pluginDirectory.isEmpty() || pluginName.isEmpty()) {
return false;
}
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(pluginDirectory);
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(pluginDirectory);
#endif
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
QVectorIterator<KPluginMetaData> i(plugins);
......@@ -98,6 +104,7 @@ bool GenericPluginManagerPrivate::initializePlugins()
info.isEnabled = isPluginActivated;
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.data = data;
if (pluginVersion() == data.version()) {
info.plugin = nullptr;
......@@ -132,6 +139,7 @@ QVector<GenericPlugin *> GenericPluginManagerPrivate::pluginsList() const
void GenericPluginManagerPrivate::loadPlugin(GenericPluginInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<PimCommon::GenericPlugin>(q, QVariantList() << item->metaDataFileNameBaseName);
......@@ -139,6 +147,14 @@ void GenericPluginManagerPrivate::loadPlugin(GenericPluginInfo *item)
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
mPluginDataList.append(item->pluginData);
}
#else
if (auto plugin = KPluginFactory::instantiatePlugin<PimCommon::GenericPlugin>(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);
}
#endif
}
GenericPlugin *GenericPluginManagerPrivate::pluginFromIdentifier(const QString &id)
......
......@@ -6,8 +6,8 @@
#include "addressesslineeditpluginmanager.h"
#include "addressesslineeditabstractplugin.h"
#include "kcoreaddons_version.h"
#include "pimcommonakonadi_debug.h"
#include <KPluginFactory>
#include <KPluginLoader>
#include <KPluginMetaData>
......@@ -23,6 +23,7 @@ public:
{
}
KPluginMetaData data;
QString metaDataFileNameBaseName;
QString metaDataFileName;
PimCommon::AddressessLineEditAbstractPlugin *plugin = nullptr;
......@@ -59,7 +60,11 @@ bool AddressessLineEditPluginManagerPrivate::initializePlugins()
if (!mPluginList.isEmpty()) {
return true;
}
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("addressline"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("addressline"));
#endif
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
......@@ -69,6 +74,7 @@ bool AddressessLineEditPluginManagerPrivate::initializePlugins()
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.data = data;
if (pluginVersion() == data.version()) {
info.plugin = nullptr;
mPluginList.push_back(info);
......@@ -85,10 +91,18 @@ bool AddressessLineEditPluginManagerPrivate::initializePlugins()
void AddressessLineEditPluginManagerPrivate::loadPlugin(AddressessLineEditPluginInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 85, 0)
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<PimCommon::AddressessLineEditAbstractPlugin>(q, QVariantList() << item->metaDataFileNameBaseName);
}
#else
if (auto plugin =
KPluginFactory::instantiatePlugin<PimCommon::AddressessLineEditAbstractPlugin>(item->data, q, QVariantList() << item->metaDataFileNameBaseName)
.plugin) {
item->plugin = plugin;
}
#endif
}
QVector<PimCommon::AddressessLineEditAbstractPlugin *> AddressessLineEditPluginManagerPrivate::pluginsList() const
......
Supports Markdown
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