Skip to content

Commit

Permalink
Fix accessible text and cleanup code (open-eid#1092)
Browse files Browse the repository at this point in the history
IB-7445

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored Jul 7, 2022
1 parent 4c2ec10 commit 3365785
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 112 deletions.
56 changes: 21 additions & 35 deletions client/translations/en.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en">
<TS version="2.1" language="en_US">
<context>
<name>AccessCert</name>
<message>
Expand Down Expand Up @@ -2967,12 +2967,28 @@ Additional licenses and components</translation>
<context>
<name>SignatureItem</name>
<message>
<source>Signature</source>
<translation>Signature</translation>
<source>Signature is valid</source>
<translation>Signature is valid</translation>
</message>
<message>
<source>Timestamp</source>
<translation>Timestamp</translation>
<source>Timestamp is valid</source>
<translation>Timestamp is valid</translation>
</message>
<message>
<source>Signature is not valid</source>
<translation>Signature is not valid</translation>
</message>
<message>
<source>Timestamp is not valid</source>
<translation>Timestamp is not valid</translation>
</message>
<message>
<source>Signature is unknown</source>
<translation>Signature is unknown</translation>
</message>
<message>
<source>Timestamp is unknown</source>
<translation>Timestamp is unknown</translation>
</message>
<message>
<source>Warnings</source>
Expand Down Expand Up @@ -3006,36 +3022,6 @@ Additional licenses and components</translation>
<source>OK</source>
<translation>OK</translation>
</message>
<message>
<source>is valid</source>
<comment>Signature</comment>
<translation>is valid</translation>
</message>
<message>
<source>is valid</source>
<comment>Timestamp</comment>
<translation>is valid</translation>
</message>
<message>
<source>is not valid</source>
<comment>Signature</comment>
<translation>is not valid</translation>
</message>
<message>
<source>is not valid</source>
<comment>Timestamp</comment>
<translation>is not valid</translation>
</message>
<message>
<source>is unknown</source>
<comment>Signature</comment>
<translation>is unknown</translation>
</message>
<message>
<source>is unknown</source>
<comment>Timestamp</comment>
<translation>is unknown</translation>
</message>
<message>
<source>Remove signature</source>
<extracomment>accessible</extracomment>
Expand Down
56 changes: 21 additions & 35 deletions client/translations/et.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="et">
<TS version="2.1" language="et_EE">
<context>
<name>AccessCert</name>
<message>
Expand Down Expand Up @@ -2967,12 +2967,28 @@ Täiendavad litsentsid ja komponendid</translation>
<context>
<name>SignatureItem</name>
<message>
<source>Signature</source>
<translation>Allkiri</translation>
<source>Signature is valid</source>
<translation>Allkiri on kehtiv</translation>
</message>
<message>
<source>Timestamp</source>
<translation>Ajatempel</translation>
<source>Timestamp is valid</source>
<translation>Ajatempel on kehtiv</translation>
</message>
<message>
<source>Signature is not valid</source>
<translation>Allkiri ei ole kehtiv</translation>
</message>
<message>
<source>Timestamp is not valid</source>
<translation>Ajatempel ei ole kehtiv</translation>
</message>
<message>
<source>Signature is unknown</source>
<translation>Allkiri on teadmata</translation>
</message>
<message>
<source>Timestamp is unknown</source>
<translation>Ajatempel on teadmata</translation>
</message>
<message>
<source>Warnings</source>
Expand Down Expand Up @@ -3006,36 +3022,6 @@ Täiendavad litsentsid ja komponendid</translation>
<source>OK</source>
<translation>OK</translation>
</message>
<message>
<source>is valid</source>
<comment>Signature</comment>
<translation>on kehtiv</translation>
</message>
<message>
<source>is valid</source>
<comment>Timestamp</comment>
<translation>on kehtiv</translation>
</message>
<message>
<source>is not valid</source>
<comment>Signature</comment>
<translation>ei ole kehtiv</translation>
</message>
<message>
<source>is not valid</source>
<comment>Timestamp</comment>
<translation>ei ole kehtiv</translation>
</message>
<message>
<source>is unknown</source>
<comment>Signature</comment>
<translation>on teadmata</translation>
</message>
<message>
<source>is unknown</source>
<comment>Timestamp</comment>
<translation>on teadmata</translation>
</message>
<message>
<source>Remove signature</source>
<extracomment>accessible</extracomment>
Expand Down
40 changes: 13 additions & 27 deletions client/translations/ru.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ru">
<TS version="2.1" language="ru_RU">
<context>
<name>AccessCert</name>
<message>
Expand Down Expand Up @@ -2969,14 +2969,6 @@ Additional licenses and components</source>
</context>
<context>
<name>SignatureItem</name>
<message>
<source>Signature</source>
<translation>Подпись</translation>
</message>
<message>
<source>Timestamp</source>
<translation>Временной штамп</translation>
</message>
<message>
<source>Warnings</source>
<translation>Предупреждения</translation>
Expand All @@ -2990,34 +2982,28 @@ Additional licenses and components</source>
<translation>Пробная подпись</translation>
</message>
<message>
<source>is valid</source>
<comment>Signature</comment>
<translation>действительна</translation>
<source>Signature is valid</source>
<translation>Подпись действительна</translation>
</message>
<message>
<source>is valid</source>
<comment>Timestamp</comment>
<translation>действителен</translation>
<source>Timestamp is valid</source>
<translation>Временной штамп действителен</translation>
</message>
<message>
<source>is not valid</source>
<comment>Signature</comment>
<translation>недействительна</translation>
<source>Signature is not valid</source>
<translation>Подпись недействительна</translation>
</message>
<message>
<source>is not valid</source>
<comment>Timestamp</comment>
<translation>недействителен</translation>
<source>Timestamp is not valid</source>
<translation>Временной штамп недействителен</translation>
</message>
<message>
<source>is unknown</source>
<comment>Signature</comment>
<translation>неизвестная</translation>
<source>Signature is unknown</source>
<translation>Подпись неизвестная</translation>
</message>
<message>
<source>is unknown</source>
<comment>Timestamp</comment>
<translation>неизвестный</translation>
<source>Timestamp is unknown</source>
<translation>Временной штамп неизвестный</translation>
</message>
<message>
<source>Signed on</source>
Expand Down
25 changes: 10 additions & 15 deletions client/widgets/SignatureItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -104,35 +102,32 @@ void SignatureItem::init()
ui->icon->load(QStringLiteral(":/images/icon_Allkiri_small.svg"));
s << "<span style=\"font-weight:normal;\">";
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("<font color=\"%1\">%2</font>").arg(color, text);
};
switch( signatureValidity )
{
case DigiDocSignature::Valid:
s << "<font color=\"green\">" << label << " " << isValid() << "</font>";
s << color(QLatin1String("green"), isValid());
break;
case DigiDocSignature::Warning:
s << "<font color=\"green\">" << label << " " << isValid() << "</font> <font color=\"#996C0B\">(" << tr("Warnings") << ")";
s << color(QLatin1String("green"), isValid()) << " " << color(QLatin1String("#996C0B"), QStringLiteral("(%1)").arg(tr("Warnings")));
break;
case DigiDocSignature::NonQSCD:
s << "<font color=\"green\">" << label << " " << isValid() << "</font> <font color=\"#996C0B\">(" << tr("Restrictions") << ")";
s << color(QLatin1String("green"), isValid()) << " " << color(QLatin1String("#996C0B"), QStringLiteral("(%1)").arg(tr("Restrictions")));
break;
case DigiDocSignature::Test:
s << "<font color=\"green\">" << label << " " << isValid() << "</font> <font>(" << 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 << "<font color=\"red\">" << 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 << "<font color=\"red\">" << label << " " << isUnknown();
s << color(QLatin1String("red"), isSignature ? tr("Signature is unknown") : tr("Timestamp is unknown"));
break;
}
s << "</span>";
Expand Down Expand Up @@ -253,7 +248,7 @@ void SignatureItem::updateNameField()
ui->name->setText(red(ui->nameText + " - ", ui->invalid) + ui->status);
else
ui->name->setText(QStringLiteral("%1<br />%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));
}

0 comments on commit 3365785

Please sign in to comment.