forked from qt-creator/qt-creator
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:
@@ -521,6 +521,19 @@ void JsonWizardFactory::registerGeneratorFactory(JsonWizardGeneratorFactory *fac
|
|||||||
s_generatorFactories.append(factory);
|
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,
|
Wizard *JsonWizardFactory::runWizardImpl(const FilePath &path, QWidget *parent,
|
||||||
Id platform,
|
Id platform,
|
||||||
const QVariantMap &variables, bool showWizard)
|
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(i.key(), i.value());
|
||||||
|
|
||||||
wizard->setValue(QStringLiteral("InitialPath"), path.toString());
|
wizard->setValue(QStringLiteral("InitialPath"), path.toString());
|
||||||
|
wizard->setValue(QStringLiteral("QmlProjectName"), qmlProjectName(path));
|
||||||
wizard->setValue(QStringLiteral("Platform"), platform.toString());
|
wizard->setValue(QStringLiteral("Platform"), platform.toString());
|
||||||
|
|
||||||
QString kindStr = QLatin1String(Core::Constants::WIZARD_KIND_UNKNOWN);
|
QString kindStr = QLatin1String(Core::Constants::WIZARD_KIND_UNKNOWN);
|
||||||
|
Reference in New Issue
Block a user