PluginManager: Add an "Deprecated" flag for plugins

For plugins that are still provided, but are no longer supported.
They are disabled by default and show a "unsupported" hint in the
plugin manager (similar to "experimental" plugins).

Change-Id: I6ad72fc0043900b5aa919c225ae94850d1d7a443
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2023-12-12 14:14:10 +01:00
parent 3211fd1e43
commit 39927ff44d
5 changed files with 33 additions and 3 deletions

View File

@@ -59,6 +59,13 @@
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 Deprecated
\li Boolean
\li Optional. Defaults to \c false.
Deprecated plugins are not loaded by default but must be explicitly
enabled by the user. This attribute is a hint that the plugin is no longer
supported and might negatively affect the user experience.
\row
\li Required
\li Boolean

View File

@@ -320,9 +320,17 @@ bool PluginSpec::isExperimental() const
return d->experimental;
}
/*!
Returns whether the plugin has its deprecated flag set.
*/
bool PluginSpec::isDeprecated() const
{
return d->deprecated;
}
/*!
Returns whether the plugin is enabled by default.
A plugin might be disabled because the plugin is experimental, or because
A plugin might be disabled because the plugin is experimental or deprecated, or because
the installation settings define it as disabled by default.
*/
bool PluginSpec::isEnabledByDefault() const
@@ -575,6 +583,7 @@ namespace {
const char PLUGIN_REQUIRED[] = "Required";
const char PLUGIN_EXPERIMENTAL[] = "Experimental";
const char PLUGIN_DISABLED_BY_DEFAULT[] = "DisabledByDefault";
const char PLUGIN_DEPRECATED[] = "Deprecated";
const char PLUGIN_SOFTLOADABLE[] = "SoftLoadable";
const char VENDOR[] = "Vendor";
const char COPYRIGHT[] = "Copyright";
@@ -797,13 +806,19 @@ bool PluginSpecPrivate::readMetaData(const QJsonObject &pluginMetaData)
experimental = value.toBool(false);
qCDebug(pluginLog) << "experimental =" << experimental;
value = metaData.value(QLatin1String(PLUGIN_DEPRECATED));
if (!value.isUndefined() && !value.isBool())
return reportError(msgValueIsNotABool(PLUGIN_DEPRECATED));
deprecated = value.toBool(false);
qCDebug(pluginLog) << "deprecated =" << deprecated;
value = metaData.value(QLatin1String(PLUGIN_DISABLED_BY_DEFAULT));
if (!value.isUndefined() && !value.isBool())
return reportError(msgValueIsNotABool(PLUGIN_DISABLED_BY_DEFAULT));
enabledByDefault = !value.toBool(false);
qCDebug(pluginLog) << "enabledByDefault =" << enabledByDefault;
if (experimental)
if (experimental || deprecated)
enabledByDefault = false;
enabledBySettings = enabledByDefault;

View File

@@ -94,6 +94,7 @@ public:
bool isAvailableForHostPlatform() const;
bool isRequired() const;
bool isExperimental() const;
bool isDeprecated() const;
bool isEnabledByDefault() const;
bool isEnabledBySettings() const;
bool isEffectivelyEnabled() const;

View File

@@ -56,6 +56,7 @@ public:
bool required = false;
bool experimental = false;
bool enabledByDefault = true;
bool deprecated = false;
QString vendor;
QString copyright;
QString license;

View File

@@ -96,9 +96,15 @@ public:
{
switch (column) {
case NameColumn:
if (role == Qt::DisplayRole)
if (role == Qt::DisplayRole) {
if (m_spec->isDeprecated()) {
//: %1 is a plugin name
return Tr::tr("%1 (deprecated)").arg(m_spec->name());
}
//: %1 is a plugin name
return m_spec->isExperimental() ? Tr::tr("%1 (experimental)").arg(m_spec->name())
: m_spec->name();
}
if (role == SortRole)
return m_spec->name();
if (role == Qt::ToolTipRole) {