"New Project" wizard: Create project parent directory, if needed

There's no reason to force users to the terminal if they want to create
their project in a new subdirectory.

Fixes: QTCREATORBUG-28346
Change-Id: Id92b2194c018274aac6f7f29c7304efa8c1d2d9e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Kandeler
2022-11-23 16:52:14 +01:00
parent 2e75492257
commit 706b0ff9eb
2 changed files with 8 additions and 2 deletions

View File

@@ -53,7 +53,7 @@ public:
}; };
Q_ENUM(Kind) Q_ENUM(Kind)
// Default is <Directory> // Default is <ExistingDirectory>
void setExpectedKind(Kind expected); void setExpectedKind(Kind expected);
Kind expectedKind() const; Kind expectedKind() const;

View File

@@ -78,6 +78,7 @@ ProjectIntroPage::ProjectIntroPage(QWidget *parent) :
d->m_nameLineEdit = new Utils::FancyLineEdit(frame); d->m_nameLineEdit = new Utils::FancyLineEdit(frame);
d->m_pathChooser = new Utils::PathChooser(frame); d->m_pathChooser = new Utils::PathChooser(frame);
d->m_pathChooser->setExpectedKind(PathChooser::Directory);
d->m_pathChooser->setDisabled(d->m_forceSubProject); d->m_pathChooser->setDisabled(d->m_forceSubProject);
d->m_projectsDirectoryCheckBox = new QCheckBox(tr("Use as default project location")); d->m_projectsDirectoryCheckBox = new QCheckBox(tr("Use as default project location"));
@@ -217,7 +218,12 @@ bool ProjectIntroPage::validate()
filePath().pathAppended(QDir::fromNativeSeparators(d->m_nameLineEdit->text())); filePath().pathAppended(QDir::fromNativeSeparators(d->m_nameLineEdit->text()));
if (!projectDir.exists()) { // All happy if (!projectDir.exists()) { // All happy
if (!d->m_pathChooser->filePath().exists()) {
displayStatusMessage(InfoLabel::Information, tr("Directory \"%1\" will be created.")
.arg(d->m_pathChooser->filePath().toUserOutput()));
} else {
hideStatusLabel(); hideStatusLabel();
}
return true; return true;
} }