PluginManager: Implement -load %plugin% option

This loads a plugin that is disabled by default.

Change-Id: Ibbc9849c417519904fe1e69a46f93a7cc1c7edc8
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
This commit is contained in:
Daniel Teske
2013-02-12 13:19:15 +01:00
parent 16b6079895
commit d3aaa76932
6 changed files with 90 additions and 5 deletions

View File

@@ -294,16 +294,45 @@ bool PluginSpec::isEnabledInSettings() const
return d->enabledInSettings;
}
/*!
\fn bool PluginSpec::isEffectivelyEnabled() const
Returns if the plugin is loaded at startup.
\see PluginSpec::isEnabled
*/
bool PluginSpec::isEffectivelyEnabled() const
{
return !d->disabledIndirectly
&& (d->enabledInSettings || d->forceEnabled)
&& !d->forceDisabled;
}
/*!
\fn bool PluginSpec::isDisabledIndirectly() const
Returns true if loading was not done due to user unselecting this plugin or its dependencies,
or if command-line parameter -noload was used.
Returns true if loading was not done due to user unselecting this plugin or its dependencies.
*/
bool PluginSpec::isDisabledIndirectly() const
{
return d->disabledIndirectly;
}
/*!
\fn bool PluginSpec::isForceEnabled() const
Returns if the plugin is enabled via the -load option on the command line.
*/
bool PluginSpec::isForceEnabled() const
{
return d->forceEnabled;
}
/*!
\fn bool PluginSpec::isForceDisabled() const
Returns if the plugin is disabled via the -noload option on the command line.
*/
bool PluginSpec::isForceDisabled() const
{
return d->forceDisabled;
}
/*!
\fn QList<PluginDependency> PluginSpec::dependencies() const
The plugin dependencies. This is valid after the PluginSpec::Read state is reached.
@@ -473,6 +502,8 @@ PluginSpecPrivate::PluginSpecPrivate(PluginSpec *spec)
disabledByDefault(false),
enabledInSettings(true),
disabledIndirectly(false),
forceEnabled(false),
forceDisabled(false),
plugin(0),
state(PluginSpec::Invalid),
hasError(false),
@@ -544,6 +575,20 @@ void PluginSpec::setDisabledIndirectly(bool value)
d->disabledIndirectly = value;
}
void PluginSpec::setForceEnabled(bool value)
{
d->forceEnabled = value;
if (value)
d->forceDisabled = false;
}
void PluginSpec::setForceDisabled(bool value)
{
if (value)
d->forceEnabled = false;
d->forceDisabled = value;
}
/*!
\fn bool PluginSpecPrivate::reportError(const QString &err)
\internal
@@ -903,7 +948,7 @@ void PluginSpecPrivate::disableIndirectlyIfDependencyDisabled()
if (it.key().type == PluginDependency::Optional)
continue;
PluginSpec *dependencySpec = it.value();
if (dependencySpec->isDisabledIndirectly() || !dependencySpec->isEnabledInSettings()) {
if (!dependencySpec->isEffectivelyEnabled()) {
disabledIndirectly = true;
break;
}