diff --git a/doc/api/plugin-specifications.qdoc b/doc/api/plugin-specifications.qdoc index 0eefadbc7c5..0183a8c02d4 100644 --- a/doc/api/plugin-specifications.qdoc +++ b/doc/api/plugin-specifications.qdoc @@ -31,8 +31,8 @@ \section2 Main Tag The root tag is \c plugin. It has the mandatory attributes \c name - and \c version, and the optional attributes \c compatVersion, \c experimental - and \c disabledByDefault. + and \c version, and the optional attributes \c compatVersion, \c experimental, + \c disabledByDefault and \c required. \table \header \li Tag @@ -79,6 +79,12 @@ If set, the respective plugin is not loaded by default but must be explicitly enabled by the user. This should be done for plugins which are not expected to be used by so many people as to justify the additional resource consumption. + + \row + \li required + \li Optional. Can be \c true or \c false, defaults to \c false. + Is used as a hint for the \gui{About Plugins...} dialog, that the user may not + manually disable this plugin. Only used for the Core plugin. \endtable \section2 Plugin-describing Tags diff --git a/src/libs/extensionsystem/pluginspec.cpp b/src/libs/extensionsystem/pluginspec.cpp index aba11235c10..fd6f7c0549c 100644 --- a/src/libs/extensionsystem/pluginspec.cpp +++ b/src/libs/extensionsystem/pluginspec.cpp @@ -270,6 +270,11 @@ bool PluginSpec::isAvailableForHostPlatform() const return d->platformSpecification.isEmpty() || d->platformSpecification.exactMatch(PluginManager::platformName()); } +bool PluginSpec::isRequired() const +{ + return d->required; +} + /*! Returns whether the plugin has its experimental flag set. */ @@ -465,6 +470,7 @@ namespace { const char PLUGIN_NAME[] = "name"; const char PLUGIN_VERSION[] = "version"; const char PLUGIN_COMPATVERSION[] = "compatVersion"; + const char PLUGIN_REQUIRED[] = "required"; const char PLUGIN_EXPERIMENTAL[] = "experimental"; const char PLUGIN_DISABLED_BY_DEFAULT[] = "disabledByDefault"; const char VENDOR[] = "vendor"; @@ -490,17 +496,17 @@ namespace { \internal */ PluginSpecPrivate::PluginSpecPrivate(PluginSpec *spec) - : - experimental(false), - disabledByDefault(false), - enabledInSettings(true), - disabledIndirectly(false), - forceEnabled(false), - forceDisabled(false), - plugin(0), - state(PluginSpec::Invalid), - hasError(false), - q(spec) + : required(false), + experimental(false), + disabledByDefault(false), + enabledInSettings(true), + disabledIndirectly(false), + forceEnabled(false), + forceDisabled(false), + plugin(0), + state(PluginSpec::Invalid), + hasError(false), + q(spec) { } @@ -647,8 +653,9 @@ void PluginSpecPrivate::readPluginSpec(QXmlStreamReader &reader) } else if (compatVersion.isEmpty()) { compatVersion = version; } - disabledByDefault = readBooleanValue(reader, PLUGIN_DISABLED_BY_DEFAULT); + required = readBooleanValue(reader, PLUGIN_REQUIRED); experimental = readBooleanValue(reader, PLUGIN_EXPERIMENTAL); + disabledByDefault = readBooleanValue(reader, PLUGIN_DISABLED_BY_DEFAULT); if (reader.hasError()) return; if (experimental) diff --git a/src/libs/extensionsystem/pluginspec.h b/src/libs/extensionsystem/pluginspec.h index 62a1b4fd996..7ebb65f09ef 100644 --- a/src/libs/extensionsystem/pluginspec.h +++ b/src/libs/extensionsystem/pluginspec.h @@ -93,6 +93,7 @@ public: QString category() const; QRegExp platformSpecification() const; bool isAvailableForHostPlatform() const; + bool isRequired() const; bool isExperimental() const; bool isDisabledByDefault() const; bool isEnabledInSettings() const; diff --git a/src/libs/extensionsystem/pluginspec_p.h b/src/libs/extensionsystem/pluginspec_p.h index f6944cf1371..6dfac9dbd31 100644 --- a/src/libs/extensionsystem/pluginspec_p.h +++ b/src/libs/extensionsystem/pluginspec_p.h @@ -65,6 +65,7 @@ public: QString name; QString version; QString compatVersion; + bool required; bool experimental; bool disabledByDefault; QString vendor; diff --git a/src/libs/extensionsystem/pluginview.cpp b/src/libs/extensionsystem/pluginview.cpp index cf48a9d744b..a3c268ff6cd 100644 --- a/src/libs/extensionsystem/pluginview.cpp +++ b/src/libs/extensionsystem/pluginview.cpp @@ -108,10 +108,6 @@ PluginView::PluginView(QWidget *parent) m_errorIcon = QIcon(QLatin1String(":/extensionsystem/images/error.png")); m_notLoadedIcon = QIcon(QLatin1String(":/extensionsystem/images/notloaded.png")); - // cannot disable these - m_whitelist << QString::fromLatin1("Core") << QString::fromLatin1("Locator") - << QString::fromLatin1("Find") << QString::fromLatin1("TextEditor"); - connect(PluginManager::instance(), SIGNAL(pluginsChanged()), this, SLOT(updateList())); connect(m_categoryWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectPlugin(QTreeWidgetItem*))); @@ -238,13 +234,13 @@ int PluginView::parsePluginSpecs(QTreeWidgetItem *parentItem, Qt::CheckState &gr pluginItem->setData(C_LOAD, Qt::CheckStateRole, Qt::Unchecked); pluginItem->setFlags(Qt::ItemIsSelectable); pluginItem->setToolTip(C_LOAD, tr("Plugin is not vailable for this platform.")); - } else if (!m_whitelist.contains(spec->name())) { - pluginItem->setData(C_LOAD, Qt::CheckStateRole, state); - pluginItem->setToolTip(C_LOAD, tr("Load on startup")); - } else { + } else if (spec->isRequired()){ pluginItem->setData(C_LOAD, Qt::CheckStateRole, Qt::Checked); pluginItem->setFlags(Qt::ItemIsSelectable); pluginItem->setToolTip(C_LOAD, tr("Plugin is required.")); + } else { + pluginItem->setData(C_LOAD, Qt::CheckStateRole, state); + pluginItem->setToolTip(C_LOAD, tr("Load on startup")); } m_specToItem.insert(spec, pluginItem); @@ -340,16 +336,10 @@ void PluginView::updatePluginSettings(QTreeWidgetItem *item, int column) PluginSpec *spec = collection->plugins().at(i); QTreeWidgetItem *child = m_specToItem.value(spec); - if (!spec->isAvailableForHostPlatform()) { - child->setData(C_LOAD, Qt::CheckStateRole, Qt::Unchecked); - child->setFlags(Qt::ItemIsSelectable); - } else if (!m_whitelist.contains(spec->name())) { + if (spec->isAvailableForHostPlatform() && !spec->isRequired()) { spec->setEnabled(loadOnStartup); Qt::CheckState state = (loadOnStartup ? Qt::Checked : Qt::Unchecked); child->setData(C_LOAD, Qt::CheckStateRole, state); - } else { - child->setData(C_LOAD, Qt::CheckStateRole, Qt::Checked); - child->setFlags(Qt::ItemIsSelectable); } } updatePluginDependencies(); @@ -364,7 +354,7 @@ void PluginView::updatePluginDependencies() { foreach (PluginSpec *spec, PluginManager::loadQueue()) { bool disableIndirectly = false; - if (m_whitelist.contains(spec->name())) + if (spec->isRequired()) continue; QHashIterator it(spec->dependencySpecs()); diff --git a/src/libs/extensionsystem/pluginview.h b/src/libs/extensionsystem/pluginview.h index bf7e5992118..2709014b181 100644 --- a/src/libs/extensionsystem/pluginview.h +++ b/src/libs/extensionsystem/pluginview.h @@ -79,7 +79,6 @@ private: QList m_items; QHash m_specToItem; - QStringList m_whitelist; QIcon m_okIcon; QIcon m_errorIcon; QIcon m_notLoadedIcon; diff --git a/src/plugins/coreplugin/Core.pluginspec.in b/src/plugins/coreplugin/Core.pluginspec.in index a9103261546..cb4c7fa9e73 100644 --- a/src/plugins/coreplugin/Core.pluginspec.in +++ b/src/plugins/coreplugin/Core.pluginspec.in @@ -1,4 +1,4 @@ - + Digia Plc (C) 2014 Digia Plc diff --git a/tests/auto/extensionsystem/pluginspec/testspecs/spec2.xml b/tests/auto/extensionsystem/pluginspec/testspecs/spec2.xml index 454f58cb755..24d272902a7 100644 --- a/tests/auto/extensionsystem/pluginspec/testspecs/spec2.xml +++ b/tests/auto/extensionsystem/pluginspec/testspecs/spec2.xml @@ -1,2 +1,2 @@ - + diff --git a/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp b/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp index dcb1e67b168..8318a6bea6a 100644 --- a/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp +++ b/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp @@ -74,6 +74,7 @@ void tst_PluginSpec::read() QCOMPARE(spec.name, QString("test")); QCOMPARE(spec.version, QString("1.0.1")); QCOMPARE(spec.compatVersion, QString("1.0.0")); + QCOMPARE(spec.required, false); QCOMPARE(spec.experimental, false); QCOMPARE(spec.enabledInSettings, true); QCOMPARE(spec.vendor, QString("Digia Plc")); @@ -90,9 +91,11 @@ void tst_PluginSpec::read() QCOMPARE(spec.dependencies, QList() << dep1 << dep2); // test missing compatVersion behavior + // and 'required' attribute QVERIFY(spec.read("testspecs/spec2.xml")); QCOMPARE(spec.version, QString("3.1.4_10")); QCOMPARE(spec.compatVersion, QString("3.1.4_10")); + QCOMPARE(spec.required, true); } void tst_PluginSpec::readError()