summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-12 05:54:42 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-12 05:54:42 (GMT)
commit9056704d18c72afaf107126fe237de576864a318 (patch)
treec9ba1b96ac6623377aa26fd844f455acb173d3a3
parent52543b91f66ba18b753375516d7a32c9c8dff2c3 (diff)
Allow to enable/disable header style
-rw-r--r--CMakeLists.txt2
-rw-r--r--messageviewer/src/header/headerstylepluginmanager.cpp95
-rw-r--r--messageviewer/src/header/headerstylepluginmanager.h4
3 files changed, 76 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a3eafff..c6f9f34 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,7 +18,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
-set(PIM_VERSION "5.3.56")
+set(PIM_VERSION "5.3.57")
set(MESSAGELIB_LIB_VERSION ${PIM_VERSION})
set(AKONADIMIME_LIB_VERSION "5.3.40")
diff --git a/messageviewer/src/header/headerstylepluginmanager.cpp b/messageviewer/src/header/headerstylepluginmanager.cpp
index e88178b..0215b07 100644
--- a/messageviewer/src/header/headerstylepluginmanager.cpp
+++ b/messageviewer/src/header/headerstylepluginmanager.cpp
@@ -74,8 +74,13 @@ public:
}
QVector<MessageViewer::HeaderStylePlugin *> pluginsList() const;
+ QVector<PimCommon::PluginUtilData> pluginDataList() const;
void initializePluginList();
void loadPlugin(HeaderStylePluginInfo *item);
+ QString configGroupName() const;
+ QString configPrefixSettingKey() const;
+private:
+ QVector<PimCommon::PluginUtilData> mPluginDataList;
QVector<HeaderStylePluginInfo> mPluginList;
HeaderStylePluginManager *q;
};
@@ -88,6 +93,22 @@ QString pluginVersion()
}
}
+QVector<PimCommon::PluginUtilData> HeaderStylePluginManagerPrivate::pluginDataList() const
+{
+ return mPluginDataList;
+}
+
+QString HeaderStylePluginManagerPrivate::configGroupName() const
+{
+ return QStringLiteral("HeaderStylePlugins");
+}
+
+QString HeaderStylePluginManagerPrivate::configPrefixSettingKey() const
+{
+ return QStringLiteral("PluginHeaderStyle");
+}
+
+
void HeaderStylePluginManagerPrivate::initializePluginList()
{
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("messageviewer"), [](const KPluginMetaData & md) {
@@ -96,38 +117,49 @@ void HeaderStylePluginManagerPrivate::initializePluginList()
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
+ const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
QSet<QString> unique;
QList<int> listOrder;
while (i.hasPrevious()) {
HeaderStylePluginInfo info;
info.metaData = i.previous();
- const QString version = info.metaData.version();
- if (pluginVersion() == version) {
-
- // only load plugins once, even if found multiple times!
- if (unique.contains(info.saveName())) {
- continue;
- }
- const QVariant p = info.metaData.rawData().value(QStringLiteral("X-KDE-MessageViewer-Header-Order")).toVariant();
- int order = -1;
- if (p.isValid()) {
- order = p.toInt();
- }
- int pos = 0;
- for (; pos < listOrder.count(); ++pos) {
- if (listOrder.at(pos) > order) {
- pos--;
- break;
+ PimCommon::PluginUtilData pluginData;
+ pluginData.mDescription = info.metaData.description();
+ pluginData.mName = info.metaData.name();
+ pluginData.mIdentifier = info.metaData.pluginId();
+ pluginData.mEnableByDefault = info.metaData.isEnabledByDefault();
+ mPluginDataList.append(pluginData);
+
+ const bool isPluginActivated = PimCommon::PluginUtil::isPluginActivated(pair.first, pair.second, pluginData.mEnableByDefault, pluginData.mIdentifier);
+ if (isPluginActivated) {
+ const QString version = info.metaData.version();
+ if (pluginVersion() == version) {
+
+ // only load plugins once, even if found multiple times!
+ if (unique.contains(info.saveName())) {
+ continue;
+ }
+ const QVariant p = info.metaData.rawData().value(QStringLiteral("X-KDE-MessageViewer-Header-Order")).toVariant();
+ int order = -1;
+ if (p.isValid()) {
+ order = p.toInt();
+ }
+ int pos = 0;
+ for (; pos < listOrder.count(); ++pos) {
+ if (listOrder.at(pos) > order) {
+ pos--;
+ break;
+ }
}
+ pos = qMax(0, pos);
+ listOrder.insert(pos, order);
+ info.plugin = Q_NULLPTR;
+ mPluginList.insert(pos, info);
+ unique.insert(info.saveName());
+ } else {
+ qCWarning(MESSAGEVIEWER_LOG) << "Plugin " << info.metaData.name() << " doesn't have correction plugin version. It will not be loaded.";
}
- pos = qMax(0, pos);
- listOrder.insert(pos, order);
- info.plugin = Q_NULLPTR;
- mPluginList.insert(pos, info);
- unique.insert(info.saveName());
- } else {
- qCWarning(MESSAGEVIEWER_LOG) << "Plugin " << info.metaData.name() << " doesn't have correction plugin version. It will not be loaded.";
}
}
QVector<HeaderStylePluginInfo>::iterator end(mPluginList.end());
@@ -186,3 +218,18 @@ QStringList HeaderStylePluginManager::pluginListName() const
}
return lst;
}
+
+QString HeaderStylePluginManager::configGroupName() const
+{
+ return d->configGroupName();
+}
+
+QString HeaderStylePluginManager::configPrefixSettingKey() const
+{
+ return d->configPrefixSettingKey();
+}
+
+QVector<PimCommon::PluginUtilData> HeaderStylePluginManager::pluginsDataList() const
+{
+ return d->pluginDataList();
+}
diff --git a/messageviewer/src/header/headerstylepluginmanager.h b/messageviewer/src/header/headerstylepluginmanager.h
index e6208f6..676897f 100644
--- a/messageviewer/src/header/headerstylepluginmanager.h
+++ b/messageviewer/src/header/headerstylepluginmanager.h
@@ -22,6 +22,7 @@
#include <QObject>
#include "messageviewer_export.h"
+#include <PimCommon/PluginUtil>
namespace MessageViewer
{
class HeaderStylePlugin;
@@ -38,6 +39,9 @@ public:
QVector<MessageViewer::HeaderStylePlugin *> pluginsList() const;
QStringList pluginListName() const;
+ QVector<PimCommon::PluginUtilData> pluginsDataList() const;
+ QString configPrefixSettingKey() const;
+ QString configGroupName() const;
private:
HeaderStylePluginManagerPrivate *const d;
};