diff --git a/kdevplatform/shell/plugincontroller.h b/kdevplatform/shell/plugincontroller.h --- a/kdevplatform/shell/plugincontroller.h +++ b/kdevplatform/shell/plugincontroller.h @@ -132,7 +132,6 @@ void unloadProjectPlugins(); void resetToDefaults(); - bool isEnabled(const KPluginMetaData& info) const; private: /** diff --git a/kdevplatform/shell/plugincontroller.cpp b/kdevplatform/shell/plugincontroller.cpp --- a/kdevplatform/shell/plugincontroller.cpp +++ b/kdevplatform/shell/plugincontroller.cpp @@ -60,6 +60,8 @@ inline QString KEY_Interfaces() { return QStringLiteral("X-KDevelop-Interfaces"); } inline QString KEY_Required() { return QStringLiteral("X-KDevelop-IRequired"); } inline QString KEY_Optional() { return QStringLiteral("X-KDevelop-IOptional"); } +inline QString KEY_KPlugin() { return QStringLiteral("KPlugin"); } +inline QString KEY_EnabledByDefault() { return QStringLiteral("EnabledByDefault"); } inline QString KEY_Global() { return QStringLiteral("Global"); } inline QString KEY_Project() { return QStringLiteral("Project"); } @@ -228,33 +230,22 @@ */ bool isEnabled(const KPluginMetaData& info) const { + // first check black listing from environment static const QStringList disabledPlugins = QString::fromLatin1(qgetenv("KDEV_DISABLE_PLUGINS")).split(';'); if (disabledPlugins.contains(info.pluginId())) { return false; } if (!isUserSelectable( info )) return true; - // in case there's a user preference, prefer that + // read stored user preference 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 auto defaultPlugins = ShellExtension::getInstance()->defaultPlugins(); - const bool isDefaultPlugin = defaultPlugins.isEmpty() || 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 - } - return false; } @@ -346,11 +337,6 @@ return loadPluginInternal( pluginName ); } -bool PluginController::isEnabled( const KPluginMetaData& info ) const -{ - return d->isEnabled(info); -} - void PluginController::initialize() { QElapsedTimer timer; @@ -361,7 +347,10 @@ { foreach( const KPluginMetaData& pi, d->plugins ) { - pluginMap.insert( pi.pluginId(), true ); + QJsonValue enabledByDefaultValue = pi.rawData()[KEY_KPlugin()].toObject()[KEY_EnabledByDefault()]; + // plugins enabled until explicitly specified otherwise + const bool enabledByDefault = (enabledByDefaultValue.isNull() || enabledByDefaultValue.toBool()); + pluginMap.insert(pi.pluginId(), enabledByDefault); } } else { @@ -387,32 +376,28 @@ } } - foreach( const KPluginMetaData& pi, d->plugins ) - { - if( isGlobalPlugin( pi ) ) - { - QMap::const_iterator it = pluginMap.constFind( pi.pluginId() ); - if( it != pluginMap.constEnd() && ( it.value() || !isUserSelectable( pi ) ) ) - { - // Plugin is mentioned in pluginmap and the value is true, so try to load it - loadPluginInternal( pi.pluginId() ); - if(!grp.hasKey(pi.pluginId() + KEY_Suffix_Enabled())) { - if( isUserSelectable( pi ) ) - { - // If plugin isn't listed yet, add it with true now - grp.writeEntry(pi.pluginId() + KEY_Suffix_Enabled(), true); - } - } else if( grp.hasKey( pi.pluginId() + "Disabled" ) && !isUserSelectable( pi ) ) - { - // Remove now-obsolete entries - grp.deleteEntry( pi.pluginId() + "Disabled" ); - } + // store current known set of enabled plugins + foreach (const KPluginMetaData& pi, d->plugins) { + if (isUserSelectable(pi)) { + auto it = pluginMap.constFind(pi.pluginId()); + if (it != pluginMap.constEnd() && (it.value())) { + grp.writeEntry(pi.pluginId() + KEY_Suffix_Enabled(), true); } + } else { + // Backward compat: Remove any now-obsolete entries + grp.deleteEntry(pi.pluginId() + QLatin1String("Disabled")); } } // Synchronize so we're writing out to the file. grp.sync(); + // load global plugins + foreach (const KPluginMetaData& pi, d->plugins) { + if (isGlobalPlugin(pi)) { + loadPluginInternal(pi.pluginId()); + } + } + qCDebug(SHELL) << "Done loading plugins - took:" << timer.elapsed() << "ms"; } @@ -490,7 +475,7 @@ return plugin; } - if ( !isEnabled( info ) ) { + if (!d->isEnabled(info)) { // Do not load disabled plugins qCWarning(SHELL) << "Not loading plugin named" << pluginId << "because it has been disabled!"; return nullptr; @@ -760,6 +745,7 @@ loadPluginInternal( info.pluginId() ); } } + // TODO: what about project plugins? what about dependency plugins? } } @@ -774,7 +760,15 @@ { foreach( const KPluginMetaData& info, d->plugins ) { - plugins << info.pluginId(); + if (!isUserSelectable(info)) { + continue; + } + + QJsonValue enabledByDefault = info.rawData()[KEY_KPlugin()].toObject()[KEY_EnabledByDefault()]; + // plugins enabled until explicitly specified otherwise + if (enabledByDefault.isNull() || enabledByDefault.toBool()) { + plugins << info.pluginId(); + } } } foreach( const QString& s, plugins ) diff --git a/kdevplatform/shell/settings/pluginpreferences.cpp b/kdevplatform/shell/settings/pluginpreferences.cpp --- a/kdevplatform/shell/settings/pluginpreferences.cpp +++ b/kdevplatform/shell/settings/pluginpreferences.cpp @@ -68,7 +68,6 @@ category = QStringLiteral("Other"); } KPluginInfo kpi(info); - kpi.setPluginEnabled(Core::self()->pluginControllerInternal()->isEnabled(info)); plugins[category] << kpi; } else qCDebug(SHELL) << "skipping..." << info.pluginId() << info.value(QStringLiteral("X-KDevelop-Category")) << loadMode; @@ -82,7 +81,6 @@ Core::self()->activeSession()->config()); } connect(selector, &KPluginSelector::changed, this, &PluginPreferences::changed); - selector->load(); } void PluginPreferences::defaults() diff --git a/kdevplatform/shell/shellextension.h b/kdevplatform/shell/shellextension.h --- a/kdevplatform/shell/shellextension.h +++ b/kdevplatform/shell/shellextension.h @@ -69,7 +69,9 @@ /** * Reimplement to return the list of plugins that should - * automatically be loaded + * loaded by default. + * If an empty list is returned, instead the plugin metadata is fallen back to, + * by reading the bool value KPlugin/EnabledByDefault (default: true). */ virtual QStringList defaultPlugins() = 0; diff --git a/plugins/cmake/tests/test_cmakemanager.cpp b/plugins/cmake/tests/test_cmakemanager.cpp --- a/plugins/cmake/tests/test_cmakemanager.cpp +++ b/plugins/cmake/tests/test_cmakemanager.cpp @@ -44,7 +44,7 @@ { QLoggingCategory::setFilterRules(QStringLiteral("*.debug=false\ndefault.debug=true\n")); - AutoTestShell::init({"kdevcmakemanager"}); + AutoTestShell::init({"KDevCMakeManager", "KDevCMakeBuilder", "KDevMakeBuilder", "KDevStandardOutputView"}); TestCore::initialize(); cleanup(); diff --git a/plugins/cmake/tests/test_ctestfindsuites.cpp b/plugins/cmake/tests/test_ctestfindsuites.cpp --- a/plugins/cmake/tests/test_ctestfindsuites.cpp +++ b/plugins/cmake/tests/test_ctestfindsuites.cpp @@ -53,7 +53,7 @@ void TestCTestFindSuites::initTestCase() { - AutoTestShell::init({"kdevcmakemanager"}); + AutoTestShell::init({"KDevCMakeManager", "KDevCMakeBuilder", "KDevMakeBuilder", "KDevStandardOutputView"}); TestCore::initialize(); cleanup(); diff --git a/plugins/custom-buildsystem/tests/test_custombuildsystemplugin.cpp b/plugins/custom-buildsystem/tests/test_custombuildsystemplugin.cpp --- a/plugins/custom-buildsystem/tests/test_custombuildsystemplugin.cpp +++ b/plugins/custom-buildsystem/tests/test_custombuildsystemplugin.cpp @@ -52,7 +52,7 @@ } void TestCustomBuildSystemPlugin::initTestCase() { - AutoTestShell::init({"kdevcustombuildsystem"}); + AutoTestShell::init({"KDevCustomBuildSystem", "KDevStandardOutputView"}); TestCore::initialize(); } diff --git a/plugins/qmakemanager/tests/test_qmakeproject.cpp b/plugins/qmakemanager/tests/test_qmakeproject.cpp --- a/plugins/qmakemanager/tests/test_qmakeproject.cpp +++ b/plugins/qmakemanager/tests/test_qmakeproject.cpp @@ -55,7 +55,7 @@ void TestQMakeProject::initTestCase() { - AutoTestShell::init({ "kdevqmakemanager" }); + AutoTestShell::init({ "KDevQMakeManager", "KDevQMakeBuilder", "KDevMakeBuilder", "KDevStandardOutputView" }); TestCore::initialize(); } diff --git a/plugins/qmljs/duchain/tests/test_qmljsdeclarations.cpp b/plugins/qmljs/duchain/tests/test_qmljsdeclarations.cpp --- a/plugins/qmljs/duchain/tests/test_qmljsdeclarations.cpp +++ b/plugins/qmljs/duchain/tests/test_qmljsdeclarations.cpp @@ -44,7 +44,7 @@ void TestDeclarations::initTestCase() { - AutoTestShell::init({"kdevqmljslanguagesupport"}); + AutoTestShell::init({"kdevqmljs"}); TestCore::initialize(Core::NoUi); QmlJS::registerDUChainItems(); diff --git a/plugins/qmljs/tests/test_files.cpp b/plugins/qmljs/tests/test_files.cpp --- a/plugins/qmljs/tests/test_files.cpp +++ b/plugins/qmljs/tests/test_files.cpp @@ -46,7 +46,7 @@ void TestFiles::initTestCase() { - AutoTestShell::init({"kdevqmljslanguagesupport"}); + AutoTestShell::init({"kdevqmljs"}); TestCore::initialize(KDevelop::Core::NoUi); DUChain::self()->disablePersistentStorage(); Core::self()->languageController()->backgroundParser()->setDelay(0); diff --git a/plugins/subversion/tests/test_svnimport.cpp b/plugins/subversion/tests/test_svnimport.cpp --- a/plugins/subversion/tests/test_svnimport.cpp +++ b/plugins/subversion/tests/test_svnimport.cpp @@ -73,7 +73,7 @@ void TestSvnImport::initTestCase() { QLoggingCategory::setFilterRules(QStringLiteral("*.debug=false\ndefault.debug=true\nkdevplatform.plugins.svn.debug=true\n")); - AutoTestShell::init({QStringLiteral("kdevsubversion")}); + AutoTestShell::init({QStringLiteral("kdevsubversion"), QStringLiteral("KDevStandardOutputView")}); TestCore::initialize(); QList plugins = Core::self()->pluginController()->allPluginsForExtension(QStringLiteral("org.kdevelop.IBasicVersionControl")); diff --git a/plugins/subversion/tests/test_svnrecursiveadd.cpp b/plugins/subversion/tests/test_svnrecursiveadd.cpp --- a/plugins/subversion/tests/test_svnrecursiveadd.cpp +++ b/plugins/subversion/tests/test_svnrecursiveadd.cpp @@ -110,7 +110,7 @@ void TestSvnRecursiveAdd::initTestCase() { - AutoTestShell::init({"kdevsubversion"}); + AutoTestShell::init({"kdevsubversion", "KDevStandardOutputView"}); TestCore::initialize(); }