Commit 1b120f92 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Activate plugin interface support

parent bc2d2d3f
Pipeline #67475 passed with stage
in 41 minutes and 14 seconds
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(PIM_VERSION "5.17.51")
set(PIM_VERSION "5.17.52")
project(Messagelib VERSION ${PIM_VERSION})
......
......@@ -189,6 +189,7 @@ target_sources(KF5MessageViewer PRIVATE
messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingplugin.cpp
messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingpluginmanager.cpp
messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletingpluginwidget.cpp
messageviewercheckbeforedeletingplugins/messageviewercheckbeforedeletinginterface.cpp
messagepartthemes/default/converthtmltoplaintext.cpp
messagepartthemes/default/defaultrenderer.cpp
messagepartthemes/default/htmlblock.cpp
......@@ -437,6 +438,7 @@ ecm_generate_headers(MessageViewer_CamelcaseCheckBeforeDeletingPlugin_HEADERS
MessageViewerCheckBeforeDeletingPlugin
MessageViewerCheckBeforeDeletingPluginManager
MessageViewerCheckBeforeDeletingPluginWidget
MessageViewerCheckBeforeDeletingInterface
REQUIRED_HEADERS MessageViewer_CheckBeforeDeletingPlugin_HEADERS
PREFIX MessageViewer
RELATIVE messageviewercheckbeforedeletingplugins
......
......@@ -6,8 +6,7 @@
#pragma once
#include "messagecomposer_export.h"
#include "plugineditorcheckbeforesendparams.h"
#include "messageviewer_export.h"
#include <QObject>
namespace MessageViewer
......@@ -17,7 +16,7 @@ class MessageViewerCheckBeforeDeletingInterfacePrivate;
* @brief The MessageViewerCheckBeforeDeletingInterface class
* @author Laurent Montel <montel@kde.org>
*/
class MESSAGECOMPOSER_EXPORT MessageViewerCheckBeforeDeletingInterface : public QObject
class MESSAGEVIEWER_EXPORT MessageViewerCheckBeforeDeletingInterface : public QObject
{
Q_OBJECT
public:
......
......@@ -13,6 +13,7 @@ public:
MessageViewerCheckBeforeDeletingPluginPrivate()
{
}
bool mIsEnabled = true;
};
MessageViewerCheckBeforeDeletingPlugin::MessageViewerCheckBeforeDeletingPlugin(QObject *parent)
......@@ -31,3 +32,13 @@ void MessageViewerCheckBeforeDeletingPlugin::showConfigureDialog(QWidget *parent
Q_UNUSED(parent)
// Reimplement
}
void MessageViewerCheckBeforeDeletingPlugin::setIsEnabled(bool enabled)
{
d->mIsEnabled = enabled;
}
bool MessageViewerCheckBeforeDeletingPlugin::isEnabled() const
{
return d->mIsEnabled;
}
......@@ -25,6 +25,8 @@ public:
virtual void showConfigureDialog(QWidget *parent);
void setIsEnabled(bool enabled);
Q_REQUIRED_RESULT bool isEnabled() const;
Q_SIGNALS:
void configChanged();
......
......@@ -15,16 +15,17 @@
using namespace MessageViewer;
class ConfigureSettingsPluginInfo
class CheckBeforeDeletingPluginInfo
{
public:
ConfigureSettingsPluginInfo()
CheckBeforeDeletingPluginInfo()
{
}
PimCommon::PluginUtilData pluginData;
QString metaDataFileNameBaseName;
QString metaDataFileName;
bool isEnabled = true;
MessageViewer::MessageViewerCheckBeforeDeletingPlugin *plugin = nullptr;
};
......@@ -39,14 +40,14 @@ public:
QVector<MessageViewer::MessageViewerCheckBeforeDeletingPlugin *> pluginsList() const;
QVector<PimCommon::PluginUtilData> pluginDataList() const;
void initializePluginList();
void loadPlugin(ConfigureSettingsPluginInfo *item);
void loadPlugin(CheckBeforeDeletingPluginInfo *item);
QString configGroupName() const;
QString configPrefixSettingKey() const;
MessageViewerCheckBeforeDeletingPlugin *pluginFromIdentifier(const QString &id);
private:
QVector<PimCommon::PluginUtilData> mPluginDataList;
QVector<ConfigureSettingsPluginInfo> mPluginList;
QVector<CheckBeforeDeletingPluginInfo> mPluginList;
MessageViewerCheckBeforeDeletingPluginManager *const q;
};
......@@ -82,13 +83,17 @@ void MessageViewerCheckBeforeDeletingPluginManagerPrivate::initializePluginList(
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
QVector<int> listOrder;
while (i.hasPrevious()) {
ConfigureSettingsPluginInfo info;
CheckBeforeDeletingPluginInfo info;
const KPluginMetaData data = i.previous();
// 1) get plugin data => name/description etc.
info.pluginData = PimCommon::PluginUtil::createPluginMetaData(data);
// 2) look at if plugin is activated
const bool isPluginActivated =
PimCommon::PluginUtil::isPluginActivated(pair.first, pair.second, info.pluginData.mEnableByDefault, info.pluginData.mIdentifier);
info.isEnabled = isPluginActivated;
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
const QString version = data.version();
......@@ -113,8 +118,8 @@ void MessageViewerCheckBeforeDeletingPluginManagerPrivate::initializePluginList(
qCWarning(MESSAGEVIEWER_LOG) << "Plugin " << data.name() << " doesn't have correction plugin version. It will not be loaded.";
}
}
QVector<ConfigureSettingsPluginInfo>::iterator end(mPluginList.end());
for (QVector<ConfigureSettingsPluginInfo>::iterator it = mPluginList.begin(); it != end; ++it) {
QVector<CheckBeforeDeletingPluginInfo>::iterator end(mPluginList.end());
for (QVector<CheckBeforeDeletingPluginInfo>::iterator it = mPluginList.begin(); it != end; ++it) {
loadPlugin(&(*it));
}
}
......@@ -122,8 +127,8 @@ void MessageViewerCheckBeforeDeletingPluginManagerPrivate::initializePluginList(
QVector<MessageViewer::MessageViewerCheckBeforeDeletingPlugin *> MessageViewerCheckBeforeDeletingPluginManagerPrivate::pluginsList() const
{
QVector<MessageViewer::MessageViewerCheckBeforeDeletingPlugin *> lst;
QVector<ConfigureSettingsPluginInfo>::ConstIterator end(mPluginList.constEnd());
for (QVector<ConfigureSettingsPluginInfo>::ConstIterator it = mPluginList.constBegin(); it != end; ++it) {
QVector<CheckBeforeDeletingPluginInfo>::ConstIterator end(mPluginList.constEnd());
for (QVector<CheckBeforeDeletingPluginInfo>::ConstIterator it = mPluginList.constBegin(); it != end; ++it) {
if (auto plugin = (*it).plugin) {
lst << plugin;
}
......@@ -131,7 +136,7 @@ QVector<MessageViewer::MessageViewerCheckBeforeDeletingPlugin *> MessageViewerCh
return lst;
}
void MessageViewerCheckBeforeDeletingPluginManagerPrivate::loadPlugin(ConfigureSettingsPluginInfo *item)
void MessageViewerCheckBeforeDeletingPluginManagerPrivate::loadPlugin(CheckBeforeDeletingPluginInfo *item)
{
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
......@@ -139,14 +144,15 @@ void MessageViewerCheckBeforeDeletingPluginManagerPrivate::loadPlugin(ConfigureS
pluginLoader.factory()->create<MessageViewer::MessageViewerCheckBeforeDeletingPlugin>(q, QVariantList() << item->metaDataFileNameBaseName);
// By default it's true
item->pluginData.mHasConfigureDialog = true;
item->plugin->setIsEnabled(item->isEnabled);
mPluginDataList.append(item->pluginData);
}
}
MessageViewerCheckBeforeDeletingPlugin *MessageViewerCheckBeforeDeletingPluginManagerPrivate::pluginFromIdentifier(const QString &id)
{
QVector<ConfigureSettingsPluginInfo>::ConstIterator end(mPluginList.constEnd());
for (QVector<ConfigureSettingsPluginInfo>::ConstIterator it = mPluginList.constBegin(); it != end; ++it) {
QVector<CheckBeforeDeletingPluginInfo>::ConstIterator end(mPluginList.constEnd());
for (QVector<CheckBeforeDeletingPluginInfo>::ConstIterator it = mPluginList.constBegin(); it != end; ++it) {
if ((*it).pluginData.mIdentifier == id) {
return (*it).plugin;
}
......
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