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

Set useful accessible names for the radio buttons

This way it's immediately clear after which period resp. on which date
the key would expire without having to combine the text and the values
of the other UI elements mentally.

GnuPG-bug-id: 6080
parent cc33eb2e
Pipeline #204923 passed with stage
in 2 minutes and 13 seconds
......@@ -16,6 +16,8 @@
#include "utils/gui-helper.h"
#include "utils/qt-cxx20-compat.h"
#include <Libkleo/Formatting>
#include <KDateComboBox>
#include <KLocalizedString>
#include <KStandardGuiItem>
......@@ -60,6 +62,23 @@ static QDate date_by_amount_and_unit(int inAmount, int inUnit)
return QDate();
static QString accessibleValidityDuration(int amount, Period unit)
switch (unit) {
case Days:
return i18ncp("(Expires) in x day(s)", "in %1 day", "in %1 days", amount);
case Weeks:
return i18ncp("(Expires) in x week(s)", "in %1 week", "in %1 weeks", amount);
case Months:
return i18ncp("(Expires) in x month(s)", "in %1 month", "in %1 months", amount);
case Years:
return i18ncp("(Expires) in x year(s)", "in %1 year", "in %1 years", amount);
Q_ASSERT(!"invalid unit");
return {};
// these calculations should be precise enough for the forseeable future...
static const double DAYS_IN_GREGORIAN_YEAR = 365.2425;
......@@ -246,6 +265,7 @@ void ExpiryDialog::Private::slotInAmountChanged()
if (ui.inRB->isChecked()) {
ui.inRB->setAccessibleName(accessibleValidityDuration(ui.inSB->value(), static_cast<Period>(ui.inCB->currentIndex())));
void ExpiryDialog::Private::slotOnDateChanged()
......@@ -253,6 +273,7 @@ void ExpiryDialog::Private::slotOnDateChanged()
if (ui.onRB->isChecked()) {
ui.onRB->setAccessibleName(i18nc("(Expires) on DATE", "on %1", Formatting::accessibleDate(ui.onCB->date())));
QDate ExpiryDialog::Private::inDate() const
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