forked from qt-creator/qt-creator
Introduce new plugin attribute "disabledByDefault".
A plugin might be disabled by default for other reasons than being experimental, e.g. because it is not expected to be needed by the average user. This is probably becoming more relevant the more plugins are added, since we want to keep the start-up time reasonable. Change-Id: I87927596d5c78e14793c5e8d6f0548eff6b58d59 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -441,6 +441,7 @@ namespace {
|
||||
const char PLUGIN_VERSION[] = "version";
|
||||
const char PLUGIN_COMPATVERSION[] = "compatVersion";
|
||||
const char PLUGIN_EXPERIMENTAL[] = "experimental";
|
||||
const char PLUGIN_DISABLED_BY_DEFAULT[] = "disabledByDefault";
|
||||
const char VENDOR[] = "vendor";
|
||||
const char COPYRIGHT[] = "copyright";
|
||||
const char LICENSE[] = "license";
|
||||
@@ -609,15 +610,13 @@ void PluginSpecPrivate::readPluginSpec(QXmlStreamReader &reader)
|
||||
} else if (compatVersion.isEmpty()) {
|
||||
compatVersion = version;
|
||||
}
|
||||
QString experimentalString = reader.attributes().value(QLatin1String(PLUGIN_EXPERIMENTAL)).toString();
|
||||
experimental = (experimentalString.compare(QLatin1String("true"), Qt::CaseInsensitive) == 0);
|
||||
if (!experimentalString.isEmpty() && !experimental
|
||||
&& experimentalString.compare(QLatin1String("false"), Qt::CaseInsensitive) != 0) {
|
||||
reader.raiseError(msgInvalidFormat(PLUGIN_EXPERIMENTAL));
|
||||
disabledByDefault = readBooleanValue(reader, PLUGIN_DISABLED_BY_DEFAULT);
|
||||
experimental = readBooleanValue(reader, PLUGIN_EXPERIMENTAL);
|
||||
if (reader.hasError())
|
||||
return;
|
||||
}
|
||||
disabledByDefault = experimental;
|
||||
enabled = !experimental;
|
||||
if (experimental)
|
||||
disabledByDefault = true;
|
||||
enabled = !disabledByDefault;
|
||||
while (!reader.atEnd()) {
|
||||
reader.readNext();
|
||||
switch (reader.tokenType()) {
|
||||
@@ -707,6 +706,17 @@ void PluginSpecPrivate::readArgumentDescription(QXmlStreamReader &reader)
|
||||
argumentDescriptions.push_back(arg);
|
||||
}
|
||||
|
||||
bool PluginSpecPrivate::readBooleanValue(QXmlStreamReader &reader, const char *key)
|
||||
{
|
||||
const QString valueString = reader.attributes().value(QLatin1String(key)).toString();
|
||||
const bool isOn = valueString.compare(QLatin1String("true"), Qt::CaseInsensitive) == 0;
|
||||
if (!valueString.isEmpty() && !isOn
|
||||
&& valueString.compare(QLatin1String("false"), Qt::CaseInsensitive) != 0) {
|
||||
reader.raiseError(msgInvalidFormat(key));
|
||||
}
|
||||
return isOn;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void PluginSpecPrivate::readDependencies(QXmlStreamReader &reader)
|
||||
\internal
|
||||
|
||||
Reference in New Issue
Block a user