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 <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Samuel Ghinet
2021-11-15 16:56:52 +02:00
parent 06a6549075
commit 00d186ce10
5 changed files with 15 additions and 6 deletions

View File

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