Commit b5e66009 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Prefix the error messages with "Error: "

This allows us to omit the prefix if it's not wanted.

GnuPG-bug-id: 5916
parent 3d26858f
......@@ -89,7 +89,7 @@ public:
ui.nameInput = FormTextInput<QLineEdit>::create(q);
ui.nameInput->setLabelText(i18nc("@label", "Name"));
ui.nameInput->setIsRequired(nameIsRequired);
ui.nameInput->setValueRequiredErrorMessage(i18n("Error: Enter a name."));
ui.nameInput->setValueRequiredErrorMessage(i18n("Enter a name."));
const auto regexp = config.readEntry("NAME_regex");
if (regexp.isEmpty()) {
ui.nameInput->setValidator(Validation::simpleName(Validation::Optional, q));
......@@ -97,9 +97,9 @@ public:
i18nc("text for screen readers",
"Must not include less-than sign, greater-than sign, and at sign."));
ui.nameInput->setInvalidEntryErrorMessage(
i18n("Error: The name must not include <, >, and @."),
i18n("The name must not include <, >, and @."),
i18nc("text for screen readers",
"Error: The name must not include less-than sign, greater-than sign, and at sign."));
"The name must not include less-than sign, greater-than sign, and at sign."));
} else {
ui.nameInput->setValidator(Validation::simpleName(regexp, Validation::Optional, q));
ui.nameInput->setHint(i18n("Must be in the format required by your organization and "
......@@ -108,10 +108,10 @@ public:
"Must be in the format required by your organization and "
"must not include less-than sign, greater-than sign, and at sign."));
ui.nameInput->setInvalidEntryErrorMessage(
i18n("Error: The name must be in the format required by your organization and "
i18n("The name must be in the format required by your organization and "
"it must not include <, >, and @."),
i18nc("text for screen readers",
"Error: The name must be in the format required by your organization and "
"The name must be in the format required by your organization and "
"it must not include less-than sign, greater-than sign, and at sign."));
}
......@@ -127,18 +127,18 @@ public:
ui.emailInput = FormTextInput<QLineEdit>::create(q);
ui.emailInput->setLabelText(i18nc("@label", "Email address"));
ui.emailInput->setIsRequired(emailIsRequired);
ui.emailInput->setValueRequiredErrorMessage(i18n("Error: Enter an email address."));
ui.emailInput->setValueRequiredErrorMessage(i18n("Enter an email address."));
const auto regexp = config.readEntry(QLatin1String("EMAIL_regex"));
if (regexp.isEmpty()) {
ui.emailInput->setValidator(Validation::email(Validation::Optional, q));
ui.emailInput->setInvalidEntryErrorMessage(i18n(
"Error: Enter an email address in the correct format, like name@example.com."));
"Enter an email address in the correct format, like name@example.com."));
} else {
ui.emailInput->setValidator(Validation::email(regexp, Validation::Optional, q));
ui.emailInput->setHint(i18n(
"Must be in the format required by your organization"));
ui.emailInput->setInvalidEntryErrorMessage(i18n(
"Error: Enter an email address in the correct format required by your organization."));
"Enter an email address in the correct format required by your organization."));
}
mainLayout->addWidget(ui.emailInput->label());
......
......@@ -113,6 +113,14 @@ void FormTextInputBase::Private::setHint(const QString &text, const QString &acc
updateAccessibleNameAndDescription();
}
namespace
{
QString decoratedError(const QString &text)
{
return text.isEmpty() ? QString() : i18nc("@info", "Error: %1", text);
}
}
QString FormTextInputBase::Private::errorMessage(Error error) const
{
switch (error) {
......@@ -154,7 +162,7 @@ void FormTextInputBase::Private::updateError()
}
const auto currentErrorMessage = mErrorLabel->text();
const auto newErrorMessage = errorMessage(mError);
const auto newErrorMessage = decoratedError(errorMessage(mError));
if (newErrorMessage == currentErrorMessage) {
return;
}
......@@ -169,7 +177,7 @@ void FormTextInputBase::Private::updateError()
}
mErrorLabel->setVisible(!newErrorMessage.isEmpty());
mErrorLabel->setText(newErrorMessage);
mErrorLabel->setAccessibleName(accessibleErrorMessage(mError));
mErrorLabel->setAccessibleName(decoratedError(accessibleErrorMessage(mError)));
updateAccessibleNameAndDescription();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment