From 1e537f7ab0f0ff97d9cb57a88d18a468654b8c27 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 30 Nov 2021 11:34:25 +0100 Subject: [PATCH] Wizards: Expose project name for qmlproject to file wizard If the project has a .qmlproject, then this exposes the name to file wizards. Change-Id: I3522784bc5fb4d373072eb72e5881d7a6d1d2777 Reviewed-by: Alessandro Portale --- .../jsonwizard/jsonwizardfactory.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp index 425cfcd5526..5439d98d2b9 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp @@ -521,6 +521,19 @@ void JsonWizardFactory::registerGeneratorFactory(JsonWizardGeneratorFactory *fac s_generatorFactories.append(factory); } +static QString qmlProjectName(const FilePath &folder) +{ + FilePath currentFolder = folder; + while (!currentFolder.isEmpty()) { + const QList fileList = currentFolder.dirEntries({"*.qmlproject"}); + if (!fileList.isEmpty()) + return fileList.first().baseName(); + currentFolder = currentFolder.parentDir(); + } + + return {}; +} + Wizard *JsonWizardFactory::runWizardImpl(const FilePath &path, QWidget *parent, Id platform, const QVariantMap &variables, bool showWizard) @@ -545,6 +558,7 @@ Wizard *JsonWizardFactory::runWizardImpl(const FilePath &path, QWidget *parent, wizard->setValue(i.key(), i.value()); wizard->setValue(QStringLiteral("InitialPath"), path.toString()); + wizard->setValue(QStringLiteral("QmlProjectName"), qmlProjectName(path)); wizard->setValue(QStringLiteral("Platform"), platform.toString()); QString kindStr = QLatin1String(Core::Constants::WIZARD_KIND_UNKNOWN);