Commit bd40ef36 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

JsonWizard: Make enabled state of wizard more dynamic

Now it can be toggled based on platform selected.

Change-Id: I663e8cff149da8df55baab4ab4f61c2c2e06f837
Reviewed-by: default avatarAlessandro Portale <>
parent 97cb82c1
......@@ -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<QList<IWizardFactory *>()> FactoryCreator;
......@@ -277,11 +277,6 @@ QList<Core::IWizardFactory *> JsonWizardFactory::createWizardFactories()
if (!data.value(QLatin1String(ENABLED_EXPRESSION_KEY), true).toBool()) {
verboseLog.append(tr("* Wizard is disabled.\n"));
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()
......@@ -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")
......@@ -92,6 +92,8 @@ public:
static QList<QVariant> objectOrList(const QVariant &data, QString *errorMessage);
static QString localizedString(const QVariant &value);
bool isAvailable(const QString &platformName) const override;
// 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<Generator> m_generators;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment