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

Allow setting a custom hint for name and email address

This allows organizations to provide a hint corresponding to the required
input pattern. Previously, this could be done with a placeholder text.
We use the placeholder text as fallback for the hint if no hint text is
configured. We do not set/use the placeholder text of the input fields
because placeholder texts are said to have bad accessibility (e.g. they
vanish as soon as one enters a character and they are not shown in the
first place if the input field already contains text).

The default hint "Must not include <, >, and @." for the name is removed.
Most people won't try to enter any of those characters as part of their
name and in case they do an appropriate error message is shown.

GnuPG-bug-id: 5832
parent 20107d80
......@@ -91,20 +91,12 @@ public:
{
if (regexp.isEmpty()) {
ui.nameInput->setValidator(Validation::simpleName(Validation::Optional));
ui.nameInput->setHint(i18n("Must not include <, >, and @."),
i18nc("text for screen readers",
"Must not include less-than sign, greater-than sign, and at sign."));
ui.nameInput->setInvalidEntryErrorMessage(
i18n("The name must not include <, >, and @."),
i18nc("text for screen readers",
"The name must not include less-than sign, greater-than sign, and at sign."));
} else {
ui.nameInput->setValidator(Validation::simpleName(regexp, Validation::Optional));
ui.nameInput->setHint(i18n("Must be in the format required by your organization and "
"must not include <, >, and @."),
i18nc("text for screen readers",
"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("The name must be in the format required by your organization and "
"it must not include <, >, and @."),
......@@ -122,8 +114,6 @@ public:
"Enter an email address in the correct format, like name@example.com."));
} else {
ui.emailInput->setValidator(Validation::email(regexp, Validation::Optional));
ui.emailInput->setHint(i18n(
"Must be in the format required by your organization"));
ui.emailInput->setInvalidEntryErrorMessage(i18n(
"Enter an email address in the correct format required by your organization."));
}
......@@ -168,6 +158,16 @@ bool NameAndEmailWidget::nameIsRequired() const
return d->ui.nameInput->isRequired();
}
void NameAndEmailWidget::setNameHint(const QString &hint)
{
d->ui.nameInput->setHint(hint);
}
QString NameAndEmailWidget::nameHint() const
{
return d->ui.nameInput->hintLabel()->text();
}
void NameAndEmailWidget::setNamePattern(const QString &pattern)
{
d->setNamePattern(pattern);
......@@ -198,6 +198,16 @@ bool NameAndEmailWidget::emailIsRequired() const
return d->ui.emailInput->isRequired();
}
void NameAndEmailWidget::setEmailHint(const QString &hint)
{
d->ui.emailInput->setHint(hint);
}
QString NameAndEmailWidget::emailHint() const
{
return d->ui.emailInput->hintLabel()->text();
}
void NameAndEmailWidget::setEmailPattern(const QString &pattern)
{
d->setEmailPattern(pattern);
......
......@@ -29,6 +29,8 @@ public:
QString name() const;
void setNameIsRequired(bool required);
bool nameIsRequired() const;
void setNameHint(const QString &hint);
QString nameHint() const;
void setNamePattern(const QString &pattern);
QString nameError() const;
......@@ -36,6 +38,8 @@ public:
QString email() const;
void setEmailIsRequired(bool required);
bool emailIsRequired() const;
void setEmailHint(const QString &hint);
QString emailHint() const;
void setEmailPattern(const QString &pattern);
QString emailError() const;
......
......@@ -125,8 +125,10 @@ public:
: i18n("Enter a name and/or an email address to use for the certificate."));
ui.nameAndEmail->setNameIsRequired(nameIsRequired);
ui.nameAndEmail->setNameHint(config.readEntry("NAME_hint", config.readEntry("NAME_placeholder")));
ui.nameAndEmail->setNamePattern(config.readEntry("NAME_regex"));
ui.nameAndEmail->setEmailIsRequired(emailIsRequired);
ui.nameAndEmail->setEmailHint(config.readEntry("EMAIL_hint", config.readEntry("EMAIL_placeholder")));
ui.nameAndEmail->setEmailPattern(config.readEntry("EMAIL_regex"));
Settings settings;
......
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