diff --git a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml index 87a63dcefe8..786f17db064 100644 --- a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml +++ b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml @@ -127,6 +127,7 @@ Item { Image { id: statusIcon + Layout.alignment: Qt.AlignTop asynchronous: false } diff --git a/src/libs/utils/projectintropage.cpp b/src/libs/utils/projectintropage.cpp index 6e180496375..e5189759b03 100644 --- a/src/libs/utils/projectintropage.cpp +++ b/src/libs/utils/projectintropage.cpp @@ -61,6 +61,7 @@ public: Ui::ProjectIntroPage m_ui; bool m_complete = false; QRegularExpressionValidator m_projectNameValidator; + QString m_projectNameValidatorUserMessage; bool m_forceSubProject = false; FilePaths m_projectDirectories; }; @@ -124,10 +125,11 @@ void ProjectIntroPage::setFilePath(const FilePath &path) d->m_ui.pathChooser->setFilePath(path); } -void ProjectIntroPage::setProjectNameRegularExpression(const QRegularExpression ®Ex) +void ProjectIntroPage::setProjectNameRegularExpression(const QRegularExpression ®Ex, const QString &userErrorMessage) { Q_ASSERT_X(regEx.isValid(), Q_FUNC_INFO, qPrintable(regEx.errorString())); d->m_projectNameValidator.setRegularExpression(regEx); + d->m_projectNameValidatorUserMessage = userErrorMessage; } void ProjectIntroPage::setProjectName(const QString &name) @@ -263,8 +265,10 @@ bool ProjectIntroPage::validateProjectName(const QString &name, QString *errorMe // a more detailed error message if (validatorState != QValidator::Acceptable && (pos == -1 || pos >= name.count())) { if (errorMessage) { - *errorMessage = tr("Name does not match \"%1\".").arg( - d->m_projectNameValidator.regularExpression().pattern()); + if (d->m_projectNameValidatorUserMessage.isEmpty()) + *errorMessage = tr("Project name is invalid."); + else + *errorMessage = d->m_projectNameValidatorUserMessage; } return false; } diff --git a/src/libs/utils/projectintropage.h b/src/libs/utils/projectintropage.h index 0bccd91f2b1..ea755d671ed 100644 --- a/src/libs/utils/projectintropage.h +++ b/src/libs/utils/projectintropage.h @@ -80,7 +80,7 @@ public slots: void setProjectName(const QString &name); void setDescription(const QString &description); void setUseAsDefaultPath(bool u); - void setProjectNameRegularExpression(const QRegularExpression ®Ex); + void setProjectNameRegularExpression(const QRegularExpression ®Ex, const QString &userErrorMessage); private: void slotChanged(); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp index dad6e9539e9..c0349814e0a 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp @@ -195,6 +195,7 @@ bool KitsPageFactory::validateData(Utils::Id typeId, const QVariant &data, QStri // -------------------------------------------------------------------- static const char KEY_PROJECT_NAME_VALIDATOR[] = "projectNameValidator"; +static const char KEY_PROJECT_NAME_VALIDATOR_USER_MESSAGE[] = "trProjectNameValidatorUserMessage"; ProjectPageFactory::ProjectPageFactory() { @@ -215,10 +216,13 @@ Utils::WizardPage *ProjectPageFactory::create(JsonWizard *wizard, Utils::Id type page->setDescription(wizard->expander()->expand(description)); QString projectNameValidator = tmp.value(QLatin1String(KEY_PROJECT_NAME_VALIDATOR)).toString(); + QString projectNameValidatorUserMessage + = JsonWizardFactory::localizedString(tmp.value(QLatin1String(KEY_PROJECT_NAME_VALIDATOR_USER_MESSAGE))); + if (!projectNameValidator.isEmpty()) { QRegularExpression regularExpression(projectNameValidator); if (regularExpression.isValid()) - page->setProjectNameRegularExpression(regularExpression); + page->setProjectNameRegularExpression(regularExpression, projectNameValidatorUserMessage); } return page; diff --git a/src/plugins/studiowelcome/qdsnewdialog.cpp b/src/plugins/studiowelcome/qdsnewdialog.cpp index b031a083bcf..9afca814dda 100644 --- a/src/plugins/studiowelcome/qdsnewdialog.cpp +++ b/src/plugins/studiowelcome/qdsnewdialog.cpp @@ -101,7 +101,7 @@ QdsNewDialog::QdsNewDialog(QWidget *parent) QObject::connect(&m_wizard, &WizardHandler::projectCanBeCreated, this, &QdsNewDialog::onProjectCanBeCreatedChanged); QObject::connect(&m_wizard, &WizardHandler::wizardCreationFailed, this, [this]() { - QMessageBox::critical(m_dialog, "New project", "Failed to initialize data"); + QMessageBox::critical(m_dialog, tr("New project"), tr("Failed to initialize data")); reject(); delete this; });