2222#include " ui_SignatureDialog.h"
2323
2424#include " DateTime.h"
25- #include " Styles.h"
2625#include " SslCertificate.h"
2726#include " dialogs/CertificateDetails.h"
2827#include " effects/Overlay.h"
@@ -50,53 +49,55 @@ SignatureDialog::SignatureDialog(const DigiDocSignature &signature, QWidget *par
5049
5150 new Overlay (this );
5251
53- SslCertificate c = signature.cert ();
54- QString style = QStringLiteral (" <font color=\" green\" >" );
55- QString status = tr (" Signature" );
56- bool isTS = signature.profile () == QStringLiteral (" TimeStampToken" );
57- if (isTS)
58- status = tr (" Timestamp" );
59- status += ' ' ;
60- auto isValid = [](bool isTS) -> QString {
61- return isTS ? tr (" is valid" , " Timestamp" ) : tr (" is valid" , " Signature" );
62- };
52+ bool isTS = signature.profile () == QLatin1String (" TimeStampToken" );
53+ d->warning ->hide ();
6354 switch (s.status ())
6455 {
6556 case DigiDocSignature::Valid:
66- status += isValid (isTS);
57+ d->status ->setLabel (QStringLiteral (" good" ));
58+ d->status ->setText (QCoreApplication::translate (" SignatureItem" , isTS ? " Timestamp is valid" : " Signature is valid" ));
6759 break ;
6860 case DigiDocSignature::Warning:
69- status += QStringLiteral (" %1</font> <font color=\" #996C0B\" >(%2)" ).arg (isValid (isTS), tr (" Warnings" ));
70- decorateNotice (QStringLiteral (" #996C0B" ));
61+ d->status ->setLabel (QStringLiteral (" good" ));
62+ d->status ->setText (QCoreApplication::translate (" SignatureItem" , isTS ? " Timestamp is valid" : " Signature is valid" ));
63+ d->warning ->show ();
64+ d->warning ->setText (QCoreApplication::translate (" SignatureItem" , " Warnings" ));
65+ d->lblNotice ->setLabel (QStringLiteral (" warning" ));
7166 if (!s.lastError ().isEmpty ())
7267 d->error ->setPlainText ( s.lastError () );
7368 if (s.warning () & DigiDocSignature::DigestWeak )
7469 d->info ->setText (tr (
7570 " The signature is technically correct, but it is based on the currently weak hash algorithm SHA-1, "
7671 " therefore it is not protected against forgery or alteration." ));
7772 else
78- d->info ->setText (tr (" SIGNATURE_WARNING" ));
73+ d->info ->setText (tr (
74+ " The signature is valid, but the container has a specific feature. Usually, this feature has arisen accidentally "
75+ " when containers were created. However, as it is not possible to edit a container without invalidating the signature, "
76+ " <a href='https://www.id.ee/en/article/digital-signing-and-electronic-signatures/'>a warning</a> is displayed." ));
7977 break ;
8078 case DigiDocSignature::NonQSCD:
81- status += QStringLiteral (" %1</font> <font color=\" #996C0B\" >(%2)" ).arg (isValid (isTS), tr (" Restrictions" ));
82- decorateNotice (QStringLiteral (" #996C0B" ));
79+ d->status ->setLabel (QStringLiteral (" good" ));
80+ d->status ->setText (QCoreApplication::translate (" SignatureItem" , isTS ? " Timestamp is valid" : " Signature is valid" ));
81+ d->warning ->show ();
82+ d->warning ->setText (QCoreApplication::translate (" SignatureItem" , " Restrictions" ));
83+ d->lblNotice ->setLabel (QStringLiteral (" warning" ));
8384 d->info ->setText ( tr (
8485 " This e-Signature is not equivalent with handwritten signature and therefore "
8586 " can be used only in transactions where Qualified e-Signature is not required." ) );
8687 break ;
8788 case DigiDocSignature::Invalid:
88- style = QStringLiteral (" <font color= \" red \" > " );
89- status += isTS ? tr ( " is not valid" , " Timestamp " ) : tr ( " is not valid" , " Signature " );
89+ d-> status -> setLabel ( QStringLiteral (" error " ) );
90+ d-> status -> setText ( QCoreApplication::translate ( " SignatureItem " , isTS ? " Timestamp is not valid" : " Signature is not valid" ) );
9091 d->error ->setPlainText ( s.lastError ().isEmpty () ? tr (" Unknown error" ) : s.lastError () );
91- decorateNotice (QStringLiteral (" red " ));
92+ d-> lblNotice -> setLabel (QStringLiteral (" error " ));
9293 d->info ->setText ( tr (
9394 " This is an invalid signature or malformed digitally signed file. The signature is not valid." ) );
9495 break ;
9596 case DigiDocSignature::Unknown:
96- style = QStringLiteral (" <font color= \" red \" > " );
97- status += isTS ? tr ( " is unknown" , " Timestamp " ) : tr ( " is unknown" , " Signature " );
97+ d-> status -> setLabel ( QStringLiteral (" warning " ) );
98+ d-> status -> setText ( QCoreApplication::translate ( " SignatureItem " , isTS ? " Timestamp is unknown" : " Signature is unknown" ) );
9899 d->error ->setPlainText ( s.lastError ().isEmpty () ? tr (" Unknown error" ) : s.lastError () );
99- decorateNotice (QStringLiteral (" red " ));
100+ d-> lblNotice -> setLabel (QStringLiteral (" error " ));
100101 d->info ->setText ( tr (
101102 " Signature status is displayed \" unknown\" if you don't have all validity confirmation "
102103 " service certificates and/or certificate authority certificates installed into your computer "
@@ -112,32 +113,10 @@ SignatureDialog::SignatureDialog(const DigiDocSignature &signature, QWidget *par
112113 else if (!noError)
113114 d->showErrors ->show ();
114115
115- QString name = !c.isNull () ? c.toString (c.showCN () ? QStringLiteral (" CN serialNumber" ) : QStringLiteral (" GN SN serialNumber" )) : s.signedBy ();
116- d->title ->setText (QStringLiteral (" %1 | %2%3</font>" ).arg (name.toHtmlEscaped (), style, status));
117- d->close ->setFont (Styles::font (Styles::Condensed, 14 ));
116+ SslCertificate c = signature.cert ();
117+ d->title ->setText (!c.isNull () ? c.toString (c.showCN () ? QStringLiteral (" CN serialNumber" ) : QStringLiteral (" GN SN serialNumber" )) : s.signedBy ());
118118 connect (d->close , &QPushButton::clicked, this , &SignatureDialog::accept);
119119
120- QFont header = Styles::font (Styles::Regular, 18 , QFont::Bold);
121- QFont regular = Styles::font (Styles::Regular, 14 );
122-
123- d->lblSignerHeader ->setFont (header);
124- d->lblSignatureHeader ->setFont (header);
125- d->lblNotice ->setFont (Styles::font (Styles::Regular, 15 ));
126-
127- d->title ->setFont (regular);
128- d->info ->setFont (regular);
129- d->signatureView ->header ()->setFont (regular);
130- d->lblRole ->setFont (regular);
131- d->lblSigningCity ->setFont (regular);
132- d->lblSigningCountry ->setFont (regular);
133- d->lblSigningCounty ->setFont (regular);
134- d->lblSigningZipCode ->setFont (regular);
135- d->signerCity ->setFont (regular);
136- d->signerState ->setFont (regular);
137- d->signerZip ->setFont (regular);
138- d->signerCountry ->setFont (regular);
139- d->signerRoles ->setFont (regular);
140-
141120 const QStringList l = s.locations ();
142121 d->signerCity ->setText ( l.value ( 0 ) );
143122 d->signerState ->setText ( l.value ( 1 ) );
@@ -150,16 +129,15 @@ SignatureDialog::SignatureDialog(const DigiDocSignature &signature, QWidget *par
150129 cnt->setFocusPolicy (cnt->text ().isEmpty () ? Qt::NoFocus : Qt::TabFocus);
151130 };
152131 setFocus (d->lblSigningCity , d->signerCity );
153- setFocus (d->lblSigningCounty , d->signerState );
132+ setFocus (d->lblSigningState , d->signerState );
154133 setFocus (d->lblSigningCountry , d->signerCountry );
155- setFocus (d->lblSigningZipCode , d->signerZip );
134+ setFocus (d->lblSigningZip , d->signerZip );
156135 setFocus (d->lblRole , d->signerRoles );
157136
158137 // Certificate info
159138 QTreeWidget *t = d->signatureView ;
160139 t->header ()->setSectionResizeMode (0 , QHeaderView::Fixed);
161140 t->header ()->resizeSection (0 , 244 );
162- t->setHeaderLabels ({ tr (" Attribute" ), tr (" Value" ) });
163141
164142 auto addCert = [this ](QTreeWidget *t, const QString &title, const QString &title2, const SslCertificate &cert) {
165143 if (cert.isNull ())
@@ -192,17 +170,11 @@ SignatureDialog::SignatureDialog(const DigiDocSignature &signature, QWidget *par
192170 addCert (t, tr (" Archive TS Certificate" ), tr (" Archive TS Certificate issuer" ), s.tsaCert ());
193171 addTime (t, tr (" Signature Timestamp" ), s.tsTime ());
194172 addCert (t, tr (" TS Certificate" ), tr (" TS Certificate issuer" ), s.tsCert ());
195- addItem (t, tr (" Hash value of signature" ), SslCertificate::toHex ( s.messageImprint ()));
173+ addItem (t, tr (" Hash value of signature" ), s.messageImprint (). toHex ( ' ' ). toUpper ( ));
196174 addCert (t, tr (" OCSP Certificate" ), tr (" OCSP Certificate issuer" ), s.ocspCert ());
197175 addTime (t, tr (" OCSP time" ), s.ocspTime ());
198176 addItem (t, tr (" Signing time (UTC)" ), s.trustedTime ());
199177 addItem (t, tr (" Claimed signing time (UTC)" ), s.claimedTime ());
200-
201- #ifdef Q_OS_MAC
202- t->setFont (Styles::font (Styles::Regular, 13 ));
203- #else
204- t->setFont (regular);
205- #endif
206178}
207179
208180SignatureDialog::~SignatureDialog ()
@@ -236,12 +208,11 @@ void SignatureDialog::addItem(QTreeWidget *view, const QString &variable, const
236208 addItem (view, variable, DateTime (value).toStringZ (QStringLiteral (" dd.MM.yyyy hh:mm:ss" )));
237209}
238210
239- void SignatureDialog::addItem (QTreeWidget *view, const QString &variable, const QSslCertificate & value)
211+ void SignatureDialog::addItem (QTreeWidget *view, const QString &variable, SslCertificate value)
240212{
241- SslCertificate c (value);
242213 QPushButton *button = itemButton (
243- c .toString (c .showCN () ? QStringLiteral (" CN" ) : QStringLiteral (" GN,SN,serialNumber" )), view);
244- connect (button, &QPushButton::clicked, this , [this , c = std::move (c )]{ CertificateDetails::showCertificate (c, this ); });
214+ value .toString (value .showCN () ? QStringLiteral (" CN" ) : QStringLiteral (" GN,SN,serialNumber" )), view);
215+ connect (button, &QPushButton::clicked, this , [this , c = std::move (value )]{ CertificateDetails::showCertificate (c, this ); });
245216 addItem (view, variable, button);
246217}
247218
@@ -254,37 +225,18 @@ void SignatureDialog::addItem(QTreeWidget *view, const QString &variable, const
254225 addItem (view, variable, button);
255226}
256227
257- void SignatureDialog::decorateNotice (const QString &color)
258- {
259- d->lblNotice ->setText (QStringLiteral (" <font color=\" %1\" >%2</font>" ).arg (color, d->lblNotice ->text ()));
260- }
261-
262228QPushButton* SignatureDialog::itemButton (const QString &text, QTreeWidget *view)
263229{
264230 auto *button = new QPushButton (text, view);
265- #ifdef Q_OS_MAC
266- QFont font = Styles::font (Styles::Regular, 13 );
267- #else
268- QFont font = Styles::font (Styles::Regular, 14 );
269- #endif
270- font.setUnderline (true );
271- button->setFont (font);
272231 button->setCursor (QCursor (Qt::PointingHandCursor));
273- button->setStyleSheet (QStringLiteral (" margin-left: 1px; border: none; text-align: left; color: #509B00" ));
274232 return button;
275233}
276234
277235QLabel* SignatureDialog::itemLabel (const QString &text, QTreeWidget *view)
278236{
279237 auto *label = new QLabel (text, view);
280238 label->setToolTip (text);
281- #ifdef Q_OS_MAC
282- label->setFont (Styles::font (Styles::Regular, 13 ));
283- #else
284- label->setFont (Styles::font (Styles::Regular, 14 ));
285- #endif
286239 label->setFocusPolicy (Qt::TabFocus);
287- label->setStyleSheet (QStringLiteral (" border: none;" ));
288240 label->setTextInteractionFlags (Qt::TextBrowserInteraction);
289241 return label;
290242}
0 commit comments