summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-06 11:55:58 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-06 11:55:58 (GMT)
commit9a2d66d25c6ec923680adda2ec2f0a1d7c6de9b1 (patch)
tree3ad8dcf6b384e31f4bcc72525ebb695b43495852
parent355fbd2bf8089da23eccd1e61c8a249c3ee90034 (diff)
Enable/disable by settings (We will configure it in future dialogbox settings in kmail)
-rw-r--r--messageviewer/src/viewerplugins/viewerpluginmanager.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/messageviewer/src/viewerplugins/viewerpluginmanager.cpp b/messageviewer/src/viewerplugins/viewerpluginmanager.cpp
index 1406f32..d155099 100644
--- a/messageviewer/src/viewerplugins/viewerpluginmanager.cpp
+++ b/messageviewer/src/viewerplugins/viewerpluginmanager.cpp
@@ -21,11 +21,13 @@
#include "viewerplugin.h"
#include "messageviewer_debug.h"
+#include <KSharedConfig>
#include <kpluginmetadata.h>
#include <KPluginLoader>
#include <KPluginFactory>
#include <QFileInfo>
#include <QSet>
+#include <KConfigGroup>
using namespace MessageViewer;
@@ -109,13 +111,25 @@ bool ViewerPluginManagerPrivate::initializePluginList()
plugins += KPluginLoader::findPlugins(QStringLiteral("messageviewer"), [](const KPluginMetaData & md) {
return md.serviceTypes().contains(QStringLiteral("MessageViewer/ViewerCommonPlugin"));
});
+
+ KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("pimpluginsrc"));
+ QStringList enabledPlugins;
+ QStringList disabledPlugins;
+ if (config->hasGroup("MessageViewer")) {
+ KConfigGroup grp = config->group("MessageViewer");
+ enabledPlugins = grp.readEntry(QStringLiteral("MessageViewerPluginsEnabled"), QStringList());
+ disabledPlugins = grp.readEntry(QStringLiteral("MessageViewerPluginsDisabled"), QStringList());
+ }
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
QSet<QString> unique;
while (i.hasPrevious()) {
ViewerPluginInfo info;
info.metaData = i.previous();
- if (info.metaData.isEnabledByDefault()) {
+ const bool pluginEnabledByUser = enabledPlugins.contains(info.metaData.name());
+ const bool pluginDisabledByUser = disabledPlugins.contains(info.metaData.name());
+ if ((info.metaData.isEnabledByDefault() && !pluginDisabledByUser)
+ || (!info.metaData.isEnabledByDefault() && pluginEnabledByUser)) {
const QString version = info.metaData.version();
if (pluginVersion() == version) {
// only load plugins once, even if found multiple times!