Commit 3fdbbaf1 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Load Plugin settings directly

parent 37c1120d
......@@ -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)
......
......@@ -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();
}
......@@ -59,6 +59,9 @@ public:
QString pluginName() const;
bool initializePluginList();
QString configGroupName() const;
QString configPrefixSettingKey() const;
private:
ViewerPluginManagerPrivate *const d;
};
......
Supports Markdown
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