summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-08 06:14:46 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-08 06:14:46 (GMT)
commit6210783be8d65b50c032579cd61e03ca60f0feaa (patch)
tree0af8c86c9d10db716d6b9c8309d29e8dfc6b7cdd
parent2a1649f09aa5b8df4f5efab574d4ca4de19113fa (diff)
Add common code for load settings
-rw-r--r--src/genericplugins/pluginutil.cpp19
-rw-r--r--src/genericplugins/pluginutil.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/src/genericplugins/pluginutil.cpp b/src/genericplugins/pluginutil.cpp
index f5faf87..ffe0281 100644
--- a/src/genericplugins/pluginutil.cpp
+++ b/src/genericplugins/pluginutil.cpp
@@ -17,6 +17,8 @@
#include "pluginutil.h"
+#include <KConfigGroup>
+#include <KSharedConfig>
bool PimCommon::PluginUtil::isPluginActivated(const QStringList &enabledPluginsList, const QStringList &disabledPluginsList, bool isEnabledByDefault, const QString &pluginId)
{
@@ -31,3 +33,20 @@ bool PimCommon::PluginUtil::isPluginActivated(const QStringList &enabledPluginsL
}
return false;
}
+
+QPair<QStringList, QStringList> PimCommon::PluginUtil::loadPluginSetting(const QString &groupName, const QString &prefixSettingKey)
+{
+ QPair<QStringList, QStringList> pair;
+ KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("pimpluginsrc"));
+ QStringList enabledPlugins;
+ QStringList disabledPlugins;
+ if (config->hasGroup(groupName)) {
+ KConfigGroup grp = config->group(groupName);
+ enabledPlugins = grp.readEntry(QStringLiteral("%1Enabled").arg(prefixSettingKey), QStringList());
+ disabledPlugins = grp.readEntry(QStringLiteral("%1Disabled").arg(prefixSettingKey), QStringList());
+ }
+
+ pair.first = enabledPlugins;
+ pair.second = disabledPlugins;
+ return pair;
+}
diff --git a/src/genericplugins/pluginutil.h b/src/genericplugins/pluginutil.h
index 89dee33..88ede17 100644
--- a/src/genericplugins/pluginutil.h
+++ b/src/genericplugins/pluginutil.h
@@ -23,12 +23,14 @@
#include <QString>
#include <QStringList>
+#include <QPair>
namespace PimCommon
{
namespace PluginUtil
{
PIMCOMMON_EXPORT bool isPluginActivated(const QStringList &enabledPluginsList, const QStringList &disabledPluginsList, bool isEnabledByDefault, const QString &pluginId);
+PIMCOMMON_EXPORT QPair<QStringList, QStringList> loadPluginSetting(const QString &groupName, const QString &prefixSettingKey);
}
}