Commit 7410024e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to KPluginFactory::instantiatePlugin

parent 4f8c2c48
Pipeline #75554 passed with stage
in 17 minutes and 49 seconds
......@@ -10,6 +10,7 @@
#include <KPluginFactory>
#include <KPluginLoader>
#include <KPluginMetaData>
#include <QRegularExpression>
#include <QStringList>
......@@ -20,6 +21,7 @@
#include <widgets/moveimapfolderwidget.h>
#include "kcoreaddons_version.h"
#include <autocreatescripts/sieveactions/widgets/addresslineedit.h>
using namespace KSieveUi;
......@@ -194,11 +196,19 @@ QString AutoCreateScriptUtil::indentation()
KSieveUi::AbstractMoveImapFolderWidget *AutoCreateScriptUtil::createImapFolderWidget()
{
KSieveUi::AbstractMoveImapFolderWidget *edit = nullptr;
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader loader(QStringLiteral("libksieve/imapfoldercompletionplugin"));
KPluginFactory *factory = loader.factory();
if (factory) {
edit = factory->create<KSieveUi::AbstractMoveImapFolderWidget>();
#else
const KPluginMetaData editWidgetPlugin(QStringLiteral("libksieve/imapfoldercompletionplugin"));
const auto result = KPluginFactory::instantiatePlugin<KSieveUi::AbstractMoveImapFolderWidget>(editWidgetPlugin);
if (result) {
edit = result.plugin;
} else {
#endif
edit = new KSieveUi::MoveImapFolderWidget;
}
return edit;
......@@ -207,11 +217,19 @@ KSieveUi::AbstractMoveImapFolderWidget *AutoCreateScriptUtil::createImapFolderWi
KSieveUi::AbstractSelectEmailLineEdit *AutoCreateScriptUtil::createSelectEmailsWidget()
{
KSieveUi::AbstractSelectEmailLineEdit *edit = nullptr;
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader loader(QStringLiteral("libksieve/emaillineeditplugin"));
KPluginFactory *factory = loader.factory();
if (factory) {
edit = factory->create<KSieveUi::AbstractSelectEmailLineEdit>();
#else
const KPluginMetaData editWidgetPlugin(QStringLiteral("libksieve/emaillineeditplugin"));
const auto result = KPluginFactory::instantiatePlugin<KSieveUi::AbstractSelectEmailLineEdit>(editWidgetPlugin);
if (result) {
edit = result.plugin;
} else {
#endif
edit = new AddressLineEdit;
}
return edit;
......@@ -220,10 +238,18 @@ KSieveUi::AbstractSelectEmailLineEdit *AutoCreateScriptUtil::createSelectEmailsW
AbstractRegexpEditorLineEdit *AutoCreateScriptUtil::createRegexpEditorLineEdit(QWidget *parent)
{
KSieveUi::AbstractRegexpEditorLineEdit *edit = nullptr;
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader loader(QStringLiteral("libksieve/regexpeditorlineeditplugin"));
KPluginFactory *factory = loader.factory();
if (factory) {
edit = factory->create<KSieveUi::AbstractRegexpEditorLineEdit>(parent);
#else
const KPluginMetaData editWidgetPlugin(QStringLiteral("libksieve/regexpeditorlineeditplugin"));
const auto result = KPluginFactory::instantiatePlugin<KSieveUi::AbstractRegexpEditorLineEdit>(editWidgetPlugin, parent);
if (result) {
edit = result.plugin;
#endif
} else {
edit = new KSieveUi::RegexpEditorLineEdit(parent);
}
......
......@@ -8,6 +8,7 @@
#include <KIO/JobUiDelegate>
#include <KIO/OpenUrlJob>
#include <KLocalizedString>
#include <KPluginLoader>
#include <QIcon>
#include <QWhatsThis>
#include <QWhatsThisClickedEvent>
......
......@@ -9,7 +9,6 @@
#include "widgets/abstractselectemaillineedit.h"
#include "widgets/moveimapfolderwidget.h"
#include <KPluginFactory>
#include <KPluginLoader>
#include <QHBoxLayout>
#include <QStackedWidget>
......
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