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>
This commit is contained in:
Thomas Hartmann
2021-11-30 11:34:25 +01:00
parent 536c31fd89
commit 1e537f7ab0

View File

@@ -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);