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

Focus first unresolved recipient if validation fails

If there are unresolved recipients, then move the input focus to the
first unresolved recipient after showing the error message.

GnuPG-bug-id: 5845
parent cbc7d23b
Pipeline #147834 passed with stage
in 1 minute and 53 seconds
......@@ -630,9 +630,13 @@ void Kleo::SignEncryptWidget::onProtocolChanged()
bool SignEncryptWidget::validate()
{
CertificateLineEdit *firstUnresolvedRecipient = nullptr;
QStringList unresolvedRecipients;
for (const auto edit: std::as_const(mRecpWidgets)) {
if (edit->isEnabled() && !edit->isEmpty() && edit->key().isNull() && edit->group().isNull()) {
if (!firstUnresolvedRecipient) {
firstUnresolvedRecipient = edit;
}
unresolvedRecipients.push_back(edit->text().toHtmlEscaped());
}
}
......@@ -642,6 +646,9 @@ bool SignEncryptWidget::validate()
unresolvedRecipients,
i18n("Failed to find some keys"));
}
if (firstUnresolvedRecipient) {
firstUnresolvedRecipient->setFocus();
}
return unresolvedRecipients.isEmpty();
}
......
Markdown is supported
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