diff --git a/src/plugins/coreplugin/iwizardfactory.h b/src/plugins/coreplugin/iwizardfactory.h index 1f65e9d5c62..d9091cd2924 100644 --- a/src/plugins/coreplugin/iwizardfactory.h +++ b/src/plugins/coreplugin/iwizardfactory.h @@ -90,7 +90,7 @@ public: virtual void runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &variables) = 0; - bool isAvailable(const QString &platformName) const; + virtual bool isAvailable(const QString &platformName) const; QStringList supportedPlatforms() const; typedef std::function()> FactoryCreator; diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp index 9278d26bbb9..6fc23ca5748 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp @@ -277,11 +277,6 @@ QList JsonWizardFactory::createWizardFactories() continue; } - if (!data.value(QLatin1String(ENABLED_EXPRESSION_KEY), true).toBool()) { - verboseLog.append(tr("* Wizard is disabled.\n")); - continue; - } - JsonWizardFactory *factory = createWizardFactory(data, current, &errorMessage); if (!factory) { verboseLog.append(tr("* Failed to create: %1\n").arg(errorMessage)); @@ -476,6 +471,18 @@ QString JsonWizardFactory::localizedString(const QVariant &value) return QCoreApplication::translate("ProjectExplorer::JsonWizardFactory", value.toByteArray()); } +bool JsonWizardFactory::isAvailable(const QString &platformName) const +{ + if (!IWizardFactory::isAvailable(platformName)) // check for required features + return false; + + Utils::MacroExpander expander; + expander.registerVariable("Platform", tr("The platform selected for the wizard."), + [platformName]() { return platformName; }); + + return JsonWizard::boolFromVariant(m_enabledExpression, &expander); +} + void JsonWizardFactory::destroyAllFactories() { qDeleteAll(s_pageFactories); @@ -492,6 +499,8 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir, m_wizardDir = baseDir.absolutePath(); + m_enabledExpression = data.value(QLatin1String(ENABLED_EXPRESSION_KEY), true); + QString strVal = data.value(QLatin1String(KIND_KEY)).toString(); if (strVal != QLatin1String("class") && strVal != QLatin1String("file") diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h index 5098930bfb9..9cb53404ec9 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h @@ -92,6 +92,8 @@ public: static QList objectOrList(const QVariant &data, QString *errorMessage); static QString localizedString(const QVariant &value); + bool isAvailable(const QString &platformName) const override; + private: // Create all wizards. As other plugins might register factories for derived // classes. Called when the new file dialog is shown for the first time. @@ -106,6 +108,7 @@ private: static void destroyAllFactories(); bool initialize(const QVariantMap &data, const QDir &baseDir, QString *errorMessage); + QVariant m_enabledExpression; QString m_wizardDir; QList m_generators;