diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2021-11-30 11:34:25 +0100 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2021-11-30 15:40:51 +0000 |
commit | 1e537f7ab0f0ff97d9cb57a88d18a468654b8c27 (patch) | |
tree | 96c364ae8e57df48a54e7095fc78f6fb753c268c | |
parent | 536c31fd89d906e9c1c21d8eb305bd92b3961c7f (diff) |
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 <alessandro.portale@qt.io>
-rw-r--r-- | src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp index 425cfcd552..5439d98d2b 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<FilePath> 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); |