Commit 2ee0b363 authored by Eike Ziller's avatar Eike Ziller

Make it possible for installers to disable plugins by default.

Plugin manager reads Plugins/Ignored in installation global settings
now, and handles these plugins similar to as if they were experimental.

Change-Id: I56a0c5fe143e3fbd9261244bafece26d7b99c154
Reviewed-by: default avatarMaurice Kalinowski <maurice.kalinowski@nokia.com>
Reviewed-by: default avatarDaniel Molkentin <daniel.molkentin@nokia.com>
parent 28039af9
......@@ -253,9 +253,11 @@ int main(int argc, char **argv)
// plugin manager takes control of this settings object
QSettings *settings = new QSettings(QSettings::IniFormat, QSettings::UserScope,
QLatin1String("Nokia"), QLatin1String("QtCreator"));
QSettings *globalSettings = new QSettings(QSettings::IniFormat, QSettings::SystemScope,
QLatin1String("Nokia"), QLatin1String("QtCreator"));
ExtensionSystem::PluginManager pluginManager;
pluginManager.setFileExtension(QLatin1String("pluginspec"));
pluginManager.setGlobalSettings(globalSettings);
pluginManager.setSettings(settings);
locale = settings->value("General/OverrideLanguage", locale).toString();
......
......@@ -402,19 +402,38 @@ void PluginManager::setFileExtension(const QString &extension)
d->extension = extension;
}
/*!
Define the user specific settings to use for information about enabled/disabled plugins.
Needs to be set before the plugin search path is set with setPluginPaths().
*/
void PluginManager::setSettings(QSettings *settings)
{
d->setSettings(settings);
}
/*!
Define the global (user-independent) settings to use for information about default disabled plugins.
Needs to be set before the plugin search path is set with setPluginPaths().
*/
void PluginManager::setGlobalSettings(QSettings *settings)
{
d->setGlobalSettings(settings);
}
/*!
Returns the user specific settings used for information about enabled/disabled plugins.
*/
QSettings *PluginManager::settings() const
{
return d->settings;
}
void PluginManager::readSettings()
/*!
Returns the global (user-independent) settings used for information about default disabled plugins.
*/
QSettings *PluginManager::globalSettings() const
{
d->readSettings();
return d->globalSettings;
}
void PluginManager::writeSettings()
......@@ -737,6 +756,18 @@ void PluginManagerPrivate::setSettings(QSettings *s)
settings->setParent(this);
}
/*!
\internal
*/
void PluginManagerPrivate::setGlobalSettings(QSettings *s)
{
if (globalSettings)
delete globalSettings;
globalSettings = s;
if (globalSettings)
globalSettings->setParent(this);
}
/*!
\fn PluginSpecPrivate *PluginManagerPrivate::privateSpec(PluginSpec *spec)
\internal
......@@ -755,6 +786,7 @@ PluginManagerPrivate::PluginManagerPrivate(PluginManager *pluginManager) :
m_profileElapsedMS(0),
m_profilingVerbosity(0),
settings(0),
globalSettings(0),
q(pluginManager)
{
}
......@@ -781,9 +813,9 @@ void PluginManagerPrivate::writeSettings()
QStringList tempDisabledPlugins;
QStringList tempForceEnabledPlugins;
foreach(PluginSpec *spec, pluginSpecs) {
if (!spec->isExperimental() && !spec->isEnabled())
if (!spec->isDisabledByDefault() && !spec->isEnabled())
tempDisabledPlugins.append(spec->name());
if (spec->isExperimental() && spec->isEnabled())
if (spec->isDisabledByDefault() && spec->isEnabled())
tempForceEnabledPlugins.append(spec->name());
}
......@@ -797,10 +829,13 @@ void PluginManagerPrivate::writeSettings()
*/
void PluginManagerPrivate::readSettings()
{
if (!settings)
return;
disabledPlugins = settings->value(QLatin1String(C_IGNORED_PLUGINS)).toStringList();
forceEnabledPlugins = settings->value(QLatin1String(C_FORCEENABLED_PLUGINS)).toStringList();
if (globalSettings) {
defaultDisabledPlugins = globalSettings->value(QLatin1String(C_IGNORED_PLUGINS)).toStringList();
}
if (settings) {
disabledPlugins = settings->value(QLatin1String(C_IGNORED_PLUGINS)).toStringList();
forceEnabledPlugins = settings->value(QLatin1String(C_FORCEENABLED_PLUGINS)).toStringList();
}
}
/*!
......@@ -1109,9 +1144,13 @@ void PluginManagerPrivate::readPluginPaths()
collection = new PluginCollection(spec->category());
pluginCategories.insert(spec->category(), collection);
}
if (spec->isExperimental() && forceEnabledPlugins.contains(spec->name()))
if (defaultDisabledPlugins.contains(spec->name())) {
spec->setDisabledByDefault(true);
spec->setEnabled(false);
}
if (spec->isDisabledByDefault() && forceEnabledPlugins.contains(spec->name()))
spec->setEnabled(true);
if (!spec->isExperimental() && disabledPlugins.contains(spec->name()))
if (!spec->isDisabledByDefault() && disabledPlugins.contains(spec->name()))
spec->setEnabled(false);
collection->addPlugin(spec);
......
......@@ -111,7 +111,8 @@ public:
// Settings
void setSettings(QSettings *settings);
QSettings *settings() const;
void readSettings();
void setGlobalSettings(QSettings *settings);
QSettings *globalSettings() const;
void writeSettings();
// command line arguments
......
......@@ -76,6 +76,7 @@ public:
void initProfiling();
void profilingReport(const char *what, const PluginSpec *spec = 0);
void setSettings(QSettings *settings);
void setGlobalSettings(QSettings *settings);
void readSettings();
void writeSettings();
void disablePluginIndirectly(PluginSpec *spec);
......@@ -86,6 +87,7 @@ public:
QStringList pluginPaths;
QString extension;
QList<QObject *> allObjects; // ### make this a QList<QPointer<QObject> > > ?
QStringList defaultDisabledPlugins;
QStringList disabledPlugins;
QStringList forceEnabledPlugins;
QList<PluginSpec *> asynchronousPlugins; // plugins that have requested async shutdown
......@@ -96,6 +98,7 @@ public:
int m_profileElapsedMS;
unsigned m_profilingVerbosity;
QSettings *settings;
QSettings *globalSettings;
// Look in argument descriptions of the specs for the option.
PluginSpec *pluginForOption(const QString &option, bool *requiresArgument) const;
......
......@@ -275,6 +275,16 @@ bool PluginSpec::isExperimental() const
return d->experimental;
}
/*!
Returns if the plugin is disabled by default.
This might be because the plugin is experimental, or because
the plugin manager's settings define it as disabled by default.
*/
bool PluginSpec::isDisabledByDefault() const
{
return d->disabledByDefault;
}
/*!
\fn bool PluginSpec::isEnabled() const
Returns if the plugin is loaded at startup. True by default - the user can change it from the Plugin settings.
......@@ -458,6 +468,8 @@ namespace {
*/
PluginSpecPrivate::PluginSpecPrivate(PluginSpec *spec)
:
experimental(false),
disabledByDefault(false),
enabled(true),
disabledIndirectly(false),
plugin(0),
......@@ -521,6 +533,11 @@ void PluginSpec::setEnabled(bool value)
d->enabled = value;
}
void PluginSpec::setDisabledByDefault(bool value)
{
d->disabledByDefault = value;
}
void PluginSpec::setDisabledIndirectly(bool value)
{
d->disabledIndirectly = value;
......@@ -601,6 +618,7 @@ void PluginSpecPrivate::readPluginSpec(QXmlStreamReader &reader)
reader.raiseError(msgInvalidFormat(PLUGIN_EXPERIMENTAL));
return;
}
disabledByDefault = experimental;
enabled = !experimental;
while (!reader.atEnd()) {
reader.readNext();
......
......@@ -94,6 +94,7 @@ public:
QString url() const;
QString category() const;
bool isExperimental() const;
bool isDisabledByDefault() const;
bool isEnabled() const;
bool isDisabledIndirectly() const;
QList<PluginDependency> dependencies() const;
......@@ -106,6 +107,7 @@ public:
QString filePath() const;
void setEnabled(bool value);
void setDisabledByDefault(bool value);
void setDisabledIndirectly(bool value);
QStringList arguments() const;
......
......@@ -67,6 +67,7 @@ public:
QString version;
QString compatVersion;
bool experimental;
bool disabledByDefault;
QString vendor;
QString copyright;
QString license;
......
......@@ -129,8 +129,7 @@ MainWindow::MainWindow() :
m_coreImpl(new CoreImpl(this)),
m_additionalContexts(Constants::C_GLOBAL),
m_settings(ExtensionSystem::PluginManager::instance()->settings()),
m_globalSettings(new QSettings(QSettings::IniFormat, QSettings::SystemScope,
QLatin1String("Nokia"), QLatin1String("QtCreator"), this)),
m_globalSettings(ExtensionSystem::PluginManager::instance()->globalSettings()),
m_settingsDatabase(new SettingsDatabase(QFileInfo(m_settings->fileName()).path(),
QLatin1String("QtCreator"),
this)),
......
Markdown is supported
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