diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp index 79c73ce995d..3e346893a19 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp @@ -157,11 +157,12 @@ QList JsonWizard::parseOptions(const QVariant &v, foreach (const QVariant &o, optList) { QVariantMap optionObject = o.toMap(); JsonWizard::OptionDefinition odef; - odef.key = optionObject.value(QLatin1String("key")).toString(); - odef.value = optionObject.value(QLatin1String("value")).toString(); - odef.condition = optionObject.value(QLatin1String("condition"), QLatin1String("true")).toString(); + odef.m_key = optionObject.value(QLatin1String("key")).toString(); + odef.m_value = optionObject.value(QLatin1String("value")).toString(); + odef.m_condition = optionObject.value(QLatin1String("condition"), true); + odef.m_evaluate = optionObject.value(QLatin1String("evaluate"), false); - if (odef.key.isEmpty()) { + if (odef.m_key.isEmpty()) { *errorMessage = QCoreApplication::translate("ProjectExplorer::Internal::JsonWizardFileGenerator", "No 'key' in options object."); result.clear(); @@ -383,4 +384,16 @@ void JsonWizard::openFiles(const JsonWizard::GeneratorFiles &files) } } +QString JsonWizard::OptionDefinition::value(Utils::MacroExpander &expander) const +{ + if (JsonWizard::boolFromVariant(m_evaluate, &expander)) + return expander.expand(m_value); + return m_value; +} + +bool JsonWizard::OptionDefinition::condition(Utils::MacroExpander &expander) const +{ + return JsonWizard::boolFromVariant(m_condition, &expander); +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.h b/src/plugins/projectexplorer/jsonwizard/jsonwizard.h index 4e59d27a036..9d20d3241e0 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.h @@ -38,6 +38,8 @@ #include #include +#include + namespace ProjectExplorer { class JsonWizardGenerator; @@ -80,9 +82,17 @@ public: class OptionDefinition { public: - QString key; - QString value; - QString condition; + QString key() const { return m_key; } + QString value(Utils::MacroExpander &expander) const; + bool condition(Utils::MacroExpander &expander) const; + + private: + QString m_key; + QString m_value; + QVariant m_condition; + QVariant m_evaluate; + + friend class JsonWizard; }; static QList parseOptions(const QVariant &v, QString *errorMessage); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp index b5ea8bfeb6c..9768e043e98 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp @@ -395,8 +395,11 @@ Utils::Wizard *JsonWizardFactory::runWizardImpl(const QString &path, QWidget *pa wizard->setValue(QStringLiteral("category"), category()); wizard->setValue(QStringLiteral("id"), id().toString()); - foreach (const JsonWizard::OptionDefinition &od, m_options) - wizard->setValue(od.key, od.value); + Utils::MacroExpander *expander = wizard->expander(); + foreach (const JsonWizard::OptionDefinition &od, m_options) { + if (od.condition(*expander)) + wizard->setValue(od.key(), od.value(*expander)); + } bool havePage = false; foreach (const Page &data, m_pages) { diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp index be8f9ba1518..ceece887412 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp @@ -122,9 +122,8 @@ Core::GeneratedFile JsonWizardFileGenerator::generateFile(const File &file, // evaluate file options once: QHash options; foreach (const JsonWizard::OptionDefinition &od, file.options) { - if (!JsonWizard::boolFromVariant(od.condition, expander)) - continue; - options.insert(od.key, od.value); + if (od.condition(*expander)) + options.insert(od.key(), od.value(*expander)); } nested.registerExtraResolver([&options](QString n, QString *ret) -> bool {