QmlDesigner: Use IFeatureProvider to hide wizards

Instead of filtering manualy we can simply defien a feature only
in the full QDS.

Change-Id: Ibeb2faca85cba77aacd1a99d5f405b21fcf3530b
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Thomas Hartmann
2024-07-11 14:15:26 +02:00
parent 07d8a8109f
commit cc32336129
4 changed files with 23 additions and 7 deletions

View File

@@ -10,7 +10,7 @@
"fontIconName": "wizardsGeneric", "fontIconName": "wizardsGeneric",
"enabled": "%{JS: [ %{Plugins} ].indexOf('QmlProjectManager') >= 0}", "enabled": "%{JS: [ %{Plugins} ].indexOf('QmlProjectManager') >= 0}",
"platformIndependent": true, "platformIndependent": true,
"featuresRequired": [ "QDS.3D" ], "featuresRequired": [ "QmlDesigner.Wizards.FullQDS" ],
"options": "options":
[ [

View File

@@ -10,7 +10,7 @@
"fontIconName": "wizardsGeneric", "fontIconName": "wizardsGeneric",
"enabled": "%{JS: [ %{Plugins} ].indexOf('QmlProjectManager') >= 0}", "enabled": "%{JS: [ %{Plugins} ].indexOf('QmlProjectManager') >= 0}",
"platformIndependent": true, "platformIndependent": true,
"featuresRequired": [ "QDS.3D" ], "featuresRequired": [ "QmlDesigner.Wizards.FullQDS" ],
"options": "options":
[ [

View File

@@ -96,6 +96,19 @@ namespace QmlDesigner {
namespace Internal { namespace Internal {
class FullQDSFeatureProvider : public Core::IFeatureProvider
{
public:
QSet<Utils::Id> availableFeatures(Utils::Id) const override
{
return {"QmlDesigner.Wizards.FullQDS"};
}
QSet<Utils::Id> availablePlatforms() const override { return {}; }
QString displayNameForPlatform(Utils::Id) const override { return {}; }
};
class EnterpriseFeatureProvider : public Core::IFeatureProvider class EnterpriseFeatureProvider : public Core::IFeatureProvider
{ {
public: public:
@@ -300,8 +313,6 @@ bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *e
StudioQuickWidget::registerDeclarativeType(); StudioQuickWidget::registerDeclarativeType();
QmlDesignerBase::WindowManager::registerDeclarativeType(); QmlDesignerBase::WindowManager::registerDeclarativeType();
if (checkEnterpriseLicense())
Core::IWizardFactory::registerFeatureProvider(new EnterpriseFeatureProvider);
Exception::setWarnAboutException(!QmlDesignerPlugin::instance() Exception::setWarnAboutException(!QmlDesignerPlugin::instance()
->settings() ->settings()
.value(DesignerSettingsKey::ENABLE_MODEL_EXCEPTION_OUTPUT) .value(DesignerSettingsKey::ENABLE_MODEL_EXCEPTION_OUTPUT)
@@ -343,6 +354,12 @@ void QmlDesignerPlugin::extensionsInitialized()
registerCombinedTracedPoints(Constants::EVENT_STATE_ADDED, registerCombinedTracedPoints(Constants::EVENT_STATE_ADDED,
Constants::EVENT_STATE_CLONED, Constants::EVENT_STATE_CLONED,
Constants::EVENT_STATE_ADDED_AND_CLONED); Constants::EVENT_STATE_ADDED_AND_CLONED);
if (checkEnterpriseLicense())
Core::IWizardFactory::registerFeatureProvider(new EnterpriseFeatureProvider);
if (!QmlDesignerBasePlugin::isLiteModeEnabled())
Core::IWizardFactory::registerFeatureProvider(new FullQDSFeatureProvider);
} }
ExtensionSystem::IPlugin::ShutdownFlag QmlDesignerPlugin::aboutToShutdown() ExtensionSystem::IPlugin::ShutdownFlag QmlDesignerPlugin::aboutToShutdown()

View File

@@ -49,9 +49,8 @@ void WizardFactories::sortByCategoryAndId()
void WizardFactories::filter() void WizardFactories::filter()
{ {
QList<JsonWizardFactory *> acceptedFactories = Utils::filtered(m_factories, [&](auto *wizard) { QList<JsonWizardFactory *> acceptedFactories = Utils::filtered(m_factories, [&](auto *wizard) {
const bool liteDesigner = QmlDesigner::QmlDesignerBasePlugin::isLiteModeEnabled(); return wizard->isAvailable(m_platform)
return wizard->isAvailable(m_platform) && wizard->kind() == JsonWizardFactory::ProjectWizard && wizard->kind() == JsonWizardFactory::ProjectWizard;
&& (!liteDesigner || !wizard->requiredFeatures().contains("QDS.3D"));
}); });
m_factories = acceptedFactories; m_factories = acceptedFactories;