Skip to content
Snippets Groups Projects
Commit 9d73ce15 authored by Kevin Funk's avatar Kevin Funk
Browse files

Fix PluginController::isEnabled

Make sure to respect user decisions about which plugin are supposed to
be loaded.

One problem to that: We can't change the 'enabled by default' property
'under the hood'. If the user loads a session, the plugin's activation
state is persisted in the session settings and preferred then. If we
were to change a plugin's 'enabled by default' property from false to
true; the user would still need to activate it himself. I don't think
that's an issue for us, though.

Differential Revision: D2618
BUG: 368264
FIXED-IN: 5.0.1
parent c0e4c85f
No related branches found
No related tags found
No related merge requests found
......@@ -224,6 +224,9 @@ public:
}
}
/**
* Decide whether a plugin is enabled
*/
bool isEnabled(const KPluginMetaData& info) const
{
static const QStringList disabledPlugins = QString::fromLatin1(qgetenv("KDEV_DISABLE_PLUGINS")).split(';');
......@@ -234,16 +237,26 @@ public:
if (!isUserSelectable( info ))
return true;
// in case there's a user preference, prefer that
const KConfigGroup grp = Core::self()->activeSession()->config()->group( KEY_Plugins() );
const QString pluginEnabledKey = info.pluginId() + KEY_Suffix_Enabled();
if (grp.hasKey(pluginEnabledKey)) {
return grp.readEntry(pluginEnabledKey, true);
}
// in all other cases: figure out if we want to load that plugin by default
const bool isDefaultPlugin = ShellExtension::getInstance()->defaultPlugins().isEmpty()
|| ShellExtension::getInstance()->defaultPlugins().contains(info.pluginId());
if (isDefaultPlugin) {
return true;
}
if (!isGlobalPlugin( info )) {
QJsonValue enabledByDefault = info.rawData()[QStringLiteral("KPlugin")].toObject()[QStringLiteral("EnabledByDefault")];
return enabledByDefault.isNull() || enabledByDefault.toBool(); //We consider plugins enabled until specified otherwise
}
KConfigGroup grp = Core::self()->activeSession()->config()->group( KEY_Plugins() );
const bool isDefaultPlugin = ShellExtension::getInstance()->defaultPlugins().isEmpty() || ShellExtension::getInstance()->defaultPlugins().contains(info.pluginId());
bool isEnabled = grp.readEntry(info.pluginId() + KEY_Suffix_Enabled(), isDefaultPlugin);
// qDebug() << "read config:" << info.pluginId() << isEnabled << "is global plugin:" << isGlobalPlugin( info ) << "default:" << ShellExtension::getInstance()->defaultPlugins().isEmpty() << ShellExtension::getInstance()->defaultPlugins().contains( info.pluginId() );
return isEnabled;
return false;
}
Core *core;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment