aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/projectintropage.cpp
diff options
context:
space:
mode:
authorSamuel Ghinet <[email protected]>2021-11-15 16:56:52 +0200
committerSamuel Ghinet <[email protected]>2021-11-18 09:50:41 +0000
commit00d186ce10ee5c3f09a5ec4c224f444abe76ec22 (patch)
tree10491edb534149dc718935b935dd300294b4b166 /src/libs/utils/projectintropage.cpp
parent06a6549075eb765221bc62be954981d301828d07 (diff)
QDS NewProject dialog: use friendly error message when regex does not match
Instead of telling the user that the project name does not match a complex regular expression, we can tell him in English words what the rules are. Also, updates the icon of the status message so that, when the status is multiline, the icon appears at the top, rather than vertical center, on the left side of the text. Change-Id: I848b3858f5f92a09588b9646c56cbf743b06ea09 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Eike Ziller <[email protected]>
Diffstat (limited to 'src/libs/utils/projectintropage.cpp')
-rw-r--r--src/libs/utils/projectintropage.cpp10
1 files changed, 7 insertions, 3 deletions
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 &regEx)
+void ProjectIntroPage::setProjectNameRegularExpression(const QRegularExpression &regEx, 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;
}