summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-08 06:57:47 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-08 06:57:47 (GMT)
commit3fdbbaf1072f08a66da11ee1996bd9bddd2aacb2 (patch)
treee10d3e43d247f3a1543da72e51e33c5b23a9280b
parent37c1120d70426a9e62dd9ae35faf946415a09ade (diff)
Load Plugin settings directly
-rw-r--r--CMakeLists.txt2
-rw-r--r--messageviewer/src/viewerplugins/viewerpluginmanager.cpp34
-rw-r--r--messageviewer/src/viewerplugins/viewerpluginmanager.h3
3 files changed, 28 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 844dfb7..f8ee71b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,7 +39,7 @@ set(KMIME_LIB_VERSION "5.3.40")
set(KPIMTEXTEDIT_LIB_VERSION "5.3.43")
set(LIBKDEPIM_LIB_VERSION "5.3.42")
set(LIBKLEO_LIB_VERSION "5.3.40")
-set(PIMCOMMON_LIB_VERSION "5.3.44")
+set(PIMCOMMON_LIB_VERSION "5.3.45")
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Network PrintSupport WebEngine WebEngineWidgets WebKitWidgets)
diff --git a/messageviewer/src/viewerplugins/viewerpluginmanager.cpp b/messageviewer/src/viewerplugins/viewerpluginmanager.cpp
index e6f49fa..8a4ec67 100644
--- a/messageviewer/src/viewerplugins/viewerpluginmanager.cpp
+++ b/messageviewer/src/viewerplugins/viewerpluginmanager.cpp
@@ -84,6 +84,8 @@ public:
QString serviceTypeName;
QString pluginName;
+ QString configGroupName() const;
+ QString configPrefixSettingKey() const;
private:
QVector<ViewerPluginInfo> mPluginList;
QVector<MessageViewer::ViewerPluginManager::ViewerPluginData> mPluginDataList;
@@ -98,6 +100,16 @@ QString pluginVersion()
}
}
+QString ViewerPluginManagerPrivate::configGroupName() const
+{
+ return QStringLiteral("PluginMessageViewer%1").arg(pluginName);
+}
+
+QString ViewerPluginManagerPrivate::configPrefixSettingKey() const
+{
+ return QStringLiteral("MessageViewerPlugins");
+}
+
bool ViewerPluginManagerPrivate::initializePluginList()
{
if (serviceTypeName.isEmpty() || pluginName.isEmpty()) {
@@ -117,15 +129,7 @@ bool ViewerPluginManagerPrivate::initializePluginList()
return md.serviceTypes().contains(QStringLiteral("MessageViewer/ViewerCommonPlugin"));
});
- KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("pimpluginsrc"));
- QStringList enabledPlugins;
- QStringList disabledPlugins;
- const QString groupPluginName = QStringLiteral("PluginMessageViewer%1").arg(pluginName);
- if (config->hasGroup(groupPluginName)) {
- KConfigGroup grp = config->group(groupPluginName);
- enabledPlugins = grp.readEntry(QStringLiteral("MessageViewerPluginsEnabled"), QStringList());
- disabledPlugins = grp.readEntry(QStringLiteral("MessageViewerPluginsDisabled"), QStringList());
- }
+ const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
QSet<QString> unique;
@@ -139,7 +143,7 @@ bool ViewerPluginManagerPrivate::initializePluginList()
pluginData.mEnableByDefault = info.metaData.isEnabledByDefault();
mPluginDataList.append(pluginData);
- const bool isPluginActivated = PimCommon::PluginUtil::isPluginActivated(enabledPlugins, disabledPlugins, pluginData.mEnableByDefault, pluginData.mIdentifier);
+ 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) {
@@ -238,3 +242,13 @@ QVector<MessageViewer::ViewerPluginManager::ViewerPluginData> ViewerPluginManage
{
return d->pluginDataList();
}
+
+QString ViewerPluginManager::configGroupName() const
+{
+ return d->configGroupName();
+}
+
+QString ViewerPluginManager::configPrefixSettingKey() const
+{
+ return d->configPrefixSettingKey();
+}
diff --git a/messageviewer/src/viewerplugins/viewerpluginmanager.h b/messageviewer/src/viewerplugins/viewerpluginmanager.h
index 0d3350c..248eaa2 100644
--- a/messageviewer/src/viewerplugins/viewerpluginmanager.h
+++ b/messageviewer/src/viewerplugins/viewerpluginmanager.h
@@ -59,6 +59,9 @@ public:
QString pluginName() const;
bool initializePluginList();
+
+ QString configGroupName() const;
+ QString configPrefixSettingKey() const;
private:
ViewerPluginManagerPrivate *const d;
};