From 3365785677791e81c9ac8243092b0e2105f9c1d5 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Thu, 7 Jul 2022 13:33:28 +0300 Subject: [PATCH] Fix accessible text and cleanup code (#1092) IB-7445 Signed-off-by: Raul Metsma --- client/translations/en.ts | 56 ++++++++++++-------------------- client/translations/et.ts | 56 ++++++++++++-------------------- client/translations/ru.ts | 40 ++++++++--------------- client/widgets/SignatureItem.cpp | 25 ++++++-------- 4 files changed, 65 insertions(+), 112 deletions(-) diff --git a/client/translations/en.ts b/client/translations/en.ts index 21caad3e5..a093a1c5a 100644 --- a/client/translations/en.ts +++ b/client/translations/en.ts @@ -1,6 +1,6 @@ - + AccessCert @@ -2967,12 +2967,28 @@ Additional licenses and components SignatureItem - Signature - Signature + Signature is valid + Signature is valid - Timestamp - Timestamp + Timestamp is valid + Timestamp is valid + + + Signature is not valid + Signature is not valid + + + Timestamp is not valid + Timestamp is not valid + + + Signature is unknown + Signature is unknown + + + Timestamp is unknown + Timestamp is unknown Warnings @@ -3006,36 +3022,6 @@ Additional licenses and components OK OK - - is valid - Signature - is valid - - - is valid - Timestamp - is valid - - - is not valid - Signature - is not valid - - - is not valid - Timestamp - is not valid - - - is unknown - Signature - is unknown - - - is unknown - Timestamp - is unknown - Remove signature accessible diff --git a/client/translations/et.ts b/client/translations/et.ts index a23f23a11..65d06ebb5 100644 --- a/client/translations/et.ts +++ b/client/translations/et.ts @@ -1,6 +1,6 @@ - + AccessCert @@ -2967,12 +2967,28 @@ Täiendavad litsentsid ja komponendid SignatureItem - Signature - Allkiri + Signature is valid + Allkiri on kehtiv - Timestamp - Ajatempel + Timestamp is valid + Ajatempel on kehtiv + + + Signature is not valid + Allkiri ei ole kehtiv + + + Timestamp is not valid + Ajatempel ei ole kehtiv + + + Signature is unknown + Allkiri on teadmata + + + Timestamp is unknown + Ajatempel on teadmata Warnings @@ -3006,36 +3022,6 @@ Täiendavad litsentsid ja komponendid OK OK - - is valid - Signature - on kehtiv - - - is valid - Timestamp - on kehtiv - - - is not valid - Signature - ei ole kehtiv - - - is not valid - Timestamp - ei ole kehtiv - - - is unknown - Signature - on teadmata - - - is unknown - Timestamp - on teadmata - Remove signature accessible diff --git a/client/translations/ru.ts b/client/translations/ru.ts index 8030a2ee0..d41efb107 100644 --- a/client/translations/ru.ts +++ b/client/translations/ru.ts @@ -1,6 +1,6 @@ - + AccessCert @@ -2969,14 +2969,6 @@ Additional licenses and components SignatureItem - - Signature - Подпись - - - Timestamp - Временной штамп - Warnings Предупреждения @@ -2990,34 +2982,28 @@ Additional licenses and components Пробная подпись - is valid - Signature - действительна + Signature is valid + Подпись действительна - is valid - Timestamp - действителен + Timestamp is valid + Временной штамп действителен - is not valid - Signature - недействительна + Signature is not valid + Подпись недействительна - is not valid - Timestamp - недействителен + Timestamp is not valid + Временной штамп недействителен - is unknown - Signature - неизвестная + Signature is unknown + Подпись неизвестная - is unknown - Timestamp - неизвестный + Timestamp is unknown + Временной штамп неизвестный Signed on diff --git a/client/widgets/SignatureItem.cpp b/client/widgets/SignatureItem.cpp index f2ef2b8a5..b2b816fee 100644 --- a/client/widgets/SignatureItem.cpp +++ b/client/widgets/SignatureItem.cpp @@ -91,11 +91,9 @@ void SignatureItem::init() QTextStream s(&ui->status); bool isSignature = true; - QString label = tr("Signature"); if(ui->signature.profile() == QStringLiteral("TimeStampToken")) { isSignature = false; - label = tr("Timestamp"); ui->icon->load(QStringLiteral(":/images/icon_ajatempel.svg")); } else if(cert.type() & SslCertificate::TempelType) @@ -104,35 +102,32 @@ void SignatureItem::init() ui->icon->load(QStringLiteral(":/images/icon_Allkiri_small.svg")); s << ""; auto isValid = [&isSignature] { - return isSignature ? tr("is valid", "Signature") : tr("is valid", "Timestamp"); + return isSignature ? tr("Signature is valid") : tr("Timestamp is valid"); }; - auto isNotValid = [&isSignature] { - return isSignature ? tr("is not valid", "Signature") : tr("is not valid", "Timestamp"); - }; - auto isUnknown = [&isSignature] { - return isSignature ? tr("is unknown", "Signature") : tr("is unknown", "Timestamp"); + auto color = [](QLatin1String color, const QString &text) { + return QStringLiteral("%2").arg(color, text); }; switch( signatureValidity ) { case DigiDocSignature::Valid: - s << "" << label << " " << isValid() << ""; + s << color(QLatin1String("green"), isValid()); break; case DigiDocSignature::Warning: - s << "" << label << " " << isValid() << " (" << tr("Warnings") << ")"; + s << color(QLatin1String("green"), isValid()) << " " << color(QLatin1String("#996C0B"), QStringLiteral("(%1)").arg(tr("Warnings"))); break; case DigiDocSignature::NonQSCD: - s << "" << label << " " << isValid() << " (" << tr("Restrictions") << ")"; + s << color(QLatin1String("green"), isValid()) << " " << color(QLatin1String("#996C0B"), QStringLiteral("(%1)").arg(tr("Restrictions"))); break; case DigiDocSignature::Test: - s << "" << label << " " << isValid() << " (" << tr("Test signature") << ")"; + s << color(QLatin1String("green"), isValid()) << " (" << tr("Test signature") << ")"; break; case DigiDocSignature::Invalid: ui->error = isSignature ? ria::qdigidoc4::InvalidSignatureWarning : ria::qdigidoc4::InvalidTimestampWarning; - s << "" << label << " " << isNotValid(); + s << color(QLatin1String("red"), isSignature ? tr("Signature is not valid") : tr("Timestamp is not valid")); break; case DigiDocSignature::Unknown: ui->error = isSignature ? ria::qdigidoc4::UnknownSignatureWarning : ria::qdigidoc4::UnknownTimestampWarning; - s << "" << label << " " << isUnknown(); + s << color(QLatin1String("red"), isSignature ? tr("Signature is unknown") : tr("Timestamp is unknown")); break; } s << ""; @@ -253,7 +248,7 @@ void SignatureItem::updateNameField() ui->name->setText(red(ui->nameText + " - ", ui->invalid) + ui->status); else ui->name->setText(QStringLiteral("%1
%2").arg(red(ui->nameText, ui->invalid), ui->status)); - ui->name->setAccessibleName(QStringLiteral("%1. %2 %3").arg(plain, ui->role->text(), ui->idSignTime->text())); + ui->name->setAccessibleName(QStringLiteral("%1. %2. %3 %4").arg(ui->nameText.toLower(), plain, ui->role->text(), ui->idSignTime->text())); ui->role->setText(ui->role->fontMetrics().elidedText( ui->roleText, Qt::ElideRight, ui->role->width() - 10, Qt::TextShowMnemonic)); }