Commit a4c45e5c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to new api

parent e02c2563
Pipeline #75644 failed with stage
in 15 minutes and 40 seconds
......@@ -5,8 +5,8 @@
*/
#include "shorturlenginepluginmanager.h"
#include "kcoreaddons_version.h"
#include "shorturlengineplugin.h"
#include <KPluginFactory>
#include <KPluginLoader>
#include <KPluginMetaData>
......@@ -17,6 +17,7 @@
class ShortUrlEnginePluginInfo
{
public:
KPluginMetaData data;
QString metaDataFileNameBaseName;
QString metaDataFileName;
QString pluginName;
......@@ -40,7 +41,11 @@ public:
void ShortUrlEnginePluginManagerPrivate::initializePlugins()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("pimcommon/shorturlengine"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("pimcommon/shorturlengine"));
#endif
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
......@@ -50,6 +55,7 @@ void ShortUrlEnginePluginManagerPrivate::initializePlugins()
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.pluginName = data.name();
info.data = data;
info.plugin = nullptr;
mPluginList.push_back(info);
......@@ -62,11 +68,17 @@ void ShortUrlEnginePluginManagerPrivate::initializePlugins()
void ShortUrlEnginePluginManagerPrivate::loadPlugin(ShortUrlEnginePluginInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 85, 0)
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<ShortUrlEnginePlugin>(q, QVariantList() << item->metaDataFileNameBaseName);
item->plugin->setPluginName(item->pluginName);
}
#else
if (auto plugin = KPluginFactory::instantiatePlugin<ShortUrlEnginePlugin>(item->data, q, QVariantList() << item->metaDataFileNameBaseName).plugin) {
item->plugin = plugin;
}
#endif
}
QVector<ShortUrlEnginePlugin *> ShortUrlEnginePluginManagerPrivate::pluginsList() const
......
......@@ -5,6 +5,7 @@
*/
#include "emaillineedit.h"
#include "kcoreaddons_version.h"
#include "sieveeditoremaillineditplugin_debug.h"
#include <Akonadi/Contact/EmailAddressSelectionDialog>
#include <KPluginFactory>
......@@ -78,10 +79,18 @@ void EmailLineEdit::insertAddresses(const KContacts::Addressee::List &list)
void EmailLineEdit::slotSelectEmail()
{
std::unique_ptr<Akonadi::AbstractEmailAddressSelectionDialog> dlg;
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader loader(QStringLiteral("akonadi/emailaddressselectionldapdialogplugin"));
KPluginFactory *factory = loader.factory();
if (factory) {
dlg.reset(factory->create<Akonadi::AbstractEmailAddressSelectionDialog>(this));
#else
const KPluginMetaData editWidgetPlugin(QStringLiteral("akonadi/emailaddressselectionldapdialogplugin"));
const auto result = KPluginFactory::instantiatePlugin<Akonadi::AbstractEmailAddressSelectionDialog>(editWidgetPlugin);
if (result) {
dlg.reset(result.plugin);
#endif
} else {
dlg = std::make_unique<Akonadi::EmailAddressSelectionDialog>(this);
}
......
......@@ -5,6 +5,7 @@
*/
#include "selectimapwidgettest.h"
#include "kcoreaddons_version.h"
#include <KPluginFactory>
#include <KPluginLoader>
#include <QDebug>
......@@ -18,13 +19,21 @@ SelectImapWidgetTest::SelectImapWidgetTest(QWidget *parent)
auto mainLayout = new QHBoxLayout(this);
KSieveUi::AbstractMoveImapFolderWidget *lineEdit = nullptr;
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader loader(QStringLiteral("libksieve/imapfoldercompletionplugin"));
KPluginFactory *factory = loader.factory();
if (factory) {
lineEdit = factory->create<KSieveUi::AbstractMoveImapFolderWidget>();
#else
const KPluginMetaData editWidgetPlugin(QStringLiteral("libksieve/imapfoldercompletionplugin"));
const auto result = KPluginFactory::instantiatePlugin<KSieveUi::AbstractMoveImapFolderWidget>(editWidgetPlugin);
if (result) {
lineEdit = result.plugin;
#endif
} else {
lineEdit = new DefaultMoveImapFolderWidget(this);
qDebug() << " error during load : " << loader.errorString();
// qDebug() << " error during load : " << loader.errorString();
}
mainLayout->addWidget(lineEdit);
}
......
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