Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/controller/command-handlers/certificatereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ EidCertificateAndPinInfo getCertificateWithStatusAndInfo(ElectronicID::ptr&& eid
subject = QStringLiteral("%1, %2, %3").arg(surName, givenName, serialNumber);
}

CertificateInfo certInfo {
certificateType, certificate.expiryDate() < QDateTime::currentDateTimeUtc(),
certificate.effectiveDate() > QDateTime::currentDateTimeUtc(), std::move(subject)};
auto info = certificateType.isAuthentication() ? eid->authPinInfo() : eid->signingPinInfo();
PinInfo pinInfo {.pinMinMaxLength = certificateType.isAuthentication()
? eid->authPinMinMaxLength()
Expand All @@ -83,7 +80,13 @@ EidCertificateAndPinInfo getCertificateWithStatusAndInfo(ElectronicID::ptr&& eid
.eid = std::move(eid),
.certificateBytesInDer = std::move(certificateDer),
.certificate = certificate,
.certInfo = std::move(certInfo),
.certInfo =
{
.type = certificateType,
.isExpired = certificate.expiryDate() < QDateTime::currentDateTimeUtc(),
.notEffective = certificate.effectiveDate() > QDateTime::currentDateTimeUtc(),
.subject = std::move(subject),
},
.pinInfo = std::move(pinInfo),
.pin1Active = pin1Active,
.pin2Active = pin2Active,
Expand Down
78 changes: 39 additions & 39 deletions src/ui/certificatewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,36 @@
#include "application.hpp"

#include <QEvent>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QLabel>
#include <QPainter>
#include <QStyleOption>

namespace
{

inline QString displayInRed(const QString& text)
{
return QStringLiteral("<span style=\"color: #CD2541\">%1</span>").arg(text);
}

} // namespace

// We use two separate widgets, CertificateWidget and CertificateButton, for accessibility, to
// support screen readers.

CertificateWidgetInfo::CertificateWidgetInfo(QWidget* self) :
icon(new QLabel(self)), info(new QLabel(self)),
warn(new QLabel(CertificateWidget::tr("Pin locked"), self))
icon(new QLabel(self)), info(new QLabel(self)), issuer(new QLabel(self)),
status(new QLabel(self))
{
warn->setObjectName(QStringLiteral("warn"));
warn->hide();
auto* layout = new QHBoxLayout(self);
layout->setContentsMargins(20, 0, 20, 0);
layout->setSpacing(10);
layout->addWidget(icon);
layout->addWidget(info, 1);
auto* warnLayout = new QHBoxLayout;
warnLayout->setSpacing(6);
warnLayout->addWidget(warn);
layout->addItem(warnLayout);
info->setObjectName(QStringLiteral("certificateName"));
info->setTextFormat(Qt::PlainText);
info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
issuer->setObjectName(QStringLiteral("certificateIssuer"));
issuer->setTextFormat(Qt::PlainText);
issuer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
status->setObjectName(QStringLiteral("certificateStatus"));
status->setTextFormat(Qt::PlainText);
issuer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
auto* layout = new QGridLayout(self);
layout->setContentsMargins(16, 16, 16, 16);
layout->setHorizontalSpacing(16);
layout->setVerticalSpacing(2);
layout->addWidget(icon, 0, 0, 3, 1, Qt::AlignVCenter);
layout->addWidget(info, 0, 1);
layout->addWidget(issuer, 1, 1);
layout->addWidget(status, 2, 1, Qt::AlignLeft);
layout->setColumnStretch(1, 1);
}

EidCertificateAndPinInfo CertificateWidgetInfo::certificateInfo() const
Expand All @@ -67,35 +64,36 @@ EidCertificateAndPinInfo CertificateWidgetInfo::certificateInfo() const

std::tuple<QString, QString, QString, QString> CertificateWidgetInfo::certData() const
{
return {certAndPinInfo.certInfo.subject.toHtmlEscaped(),
certAndPinInfo.certificate.issuerInfo(QSslCertificate::CommonName)
.join(' ')
.toHtmlEscaped(),
return {certAndPinInfo.certInfo.subject,
certAndPinInfo.certificate.issuerInfo(QSslCertificate::CommonName).join(' '),
certAndPinInfo.certificate.effectiveDate().date().toString(Qt::ISODate),
certAndPinInfo.certificate.expiryDate().date().toString(Qt::ISODate)};
}

void CertificateWidgetInfo::setCertificateInfo(const EidCertificateAndPinInfo& cardCertPinInfo)
{
warn->setText(CertificateWidget::tr("Pin locked"));
certAndPinInfo = cardCertPinInfo;
const auto& certInfo = cardCertPinInfo.certInfo;
QString warning;
auto [subject, issuer, effectiveDate, expiryDate] = certData();
const auto& [subject, issuerName, effectiveDate, expiryDate] = certData();
Q_UNUSED(effectiveDate)
bool isError =
certInfo.notEffective || certInfo.isExpired || cardCertPinInfo.pinInfo.pinIsBlocked();
if (certInfo.notEffective) {
effectiveDate = displayInRed(effectiveDate);
warning = displayInRed(CertificateWidget::tr(" (Not effective)"));
warning = CertificateWidget::tr(" (Not effective)");
}
if (certInfo.isExpired) {
expiryDate = displayInRed(expiryDate);
warning = displayInRed(CertificateWidget::tr(" (Expired)"));
warning = CertificateWidget::tr(" (Expired)");
}
info->setText(CertificateWidget::tr("<b>%1</b><br />Issuer: %2<br />Valid: %3 to %4%5")
.arg(subject, issuer, effectiveDate, expiryDate, warning));
info->setText(subject);
issuer->setText(CertificateWidget::tr("Issuer: %1").arg(issuerName));
status->setText(cardCertPinInfo.pinInfo.pinIsBlocked()
? CertificateWidget::tr("Pin locked")
: CertificateWidget::tr("Valid until: %1%2").arg(expiryDate, warning));
status->setProperty("warning", isError);
status->style()->unpolish(status);
status->style()->polish(status);
info->parentWidget()->setDisabled(isError);
warn->setVisible(warning.isEmpty() && cardCertPinInfo.pinInfo.pinIsBlocked());
if (isError) {
icon->setPixmap(Application::isDarkTheme() ? QStringLiteral(":/images/id-card-err_dark.svg")
: QStringLiteral(":/images/id-card-err.svg"));
Expand Down Expand Up @@ -132,14 +130,16 @@ CertificateButton::CertificateButton(const EidCertificateAndPinInfo& cardCertPin
setAutoExclusive(true);
CertificateWidgetInfo::icon->setAttribute(Qt::WA_TransparentForMouseEvents);
info->setAttribute(Qt::WA_TransparentForMouseEvents);
issuer->setAttribute(Qt::WA_TransparentForMouseEvents);
setCertificateInfo(cardCertPinInfo);
}

void CertificateButton::setCertificateInfo(const EidCertificateAndPinInfo& cardCertPinInfo)
{
CertificateWidgetInfo::setCertificateInfo(cardCertPinInfo);
auto [subject, issuer, effectiveDate, expiryDate] = certData();
setText(tr("%1 Issuer: %2 Valid: %3 to %4").arg(subject, issuer, effectiveDate, expiryDate));
auto [subject, issuerName, effectiveDate, expiryDate] = certData();
setText(
tr("%1 Issuer: %2 Valid: %3 to %4").arg(subject, issuerName, effectiveDate, expiryDate));
}

void CertificateButton::paintEvent(QPaintEvent* /*event*/)
Expand Down
3 changes: 2 additions & 1 deletion src/ui/certificatewidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class CertificateWidgetInfo

QLabel* icon;
QLabel* info;
QLabel* warn;
QLabel* issuer;
QLabel* status;
EidCertificateAndPinInfo certAndPinInfo;
};

Expand Down
21 changes: 14 additions & 7 deletions src/ui/dark.qss
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@ CertificateButton:checked {
border-color: #008EEA;
}
/* CertificateButton QWidget:disabled, CertificateWidget QWidget:disabled */
CertificateButton #warn, CertificateWidget #warn {
color: #F54A67;
#certificateStatus {
color: white;
background-color: #415982;
}
#certificateStatus[warning="true"] {
color: #FF5C79;
background-color: #4A2830;
}
QLineEdit {
background-color: rgba(255,255,255,0.1);
border-color: #008EEA;
border-color: #909299;
color: #FFFFFF;
}
QLineEdit[warning="true"] {
border-color: #F54A67;
color: #F54A67;
border-color: #FF5C79;
}
QProgressBar {
background-color: rgba(255,255,255,0.1);
Expand All @@ -51,8 +55,11 @@ color: #FFFFFF;
#selectCertificateOriginLabel, #pinInputOriginLabel {
color: white;
}
#pinTitleLabel {
color: white;
}
#pinErrorLabel {
color: #F54A67;
color: #FF5C79;
}
#aboutContent {
border-color: #4E4E53;
Expand Down
85 changes: 31 additions & 54 deletions src/ui/dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,35 @@ background-color: transparent;
CertificateButton QWidget:disabled, CertificateWidget QWidget:disabled {
color: #76767B;
}
CertificateButton #warn, CertificateWidget #warn {
color: #CD2541;
#certificateName {
font-weight: 700;
}
#certificateIssuer {
font-size: 12px;
}
#certificateStatus {
color: #091A36;
background-color: #F3F5F7;
border-radius: 8px;
font-size: 12px;
font-weight: 400;
padding: 2px 8px;
}
#certificateStatus[warning=&quot;true&quot;] {
color: #AD2A45;
background-color: #F5EBED;
}
QLineEdit {
border: 2px solid #113F8E;
color: #113F8E;
border-radius: 3px;
min-width: 200px;
min-height: 45px;
max-width: 200px;
max-height: 45px;
font-size: 26px;
font-weight: bold;
padding-right: 14px;
padding-left: 14px;
padding-top: 0px;
padding-bottom: 0px;
border: 1px solid #C4CBD8;
color: #607496;
border-radius: 8px;
font-size: 16px;
padding: 10px 14px;
lineedit-password-character: 42;
}
QLineEdit[warning=&quot;true&quot;] {
border: 2px solid #CD2541;
color: #CD2541;
border: 1px solid #BE7884;
color: #07142A;
}
QProgressBar {
height: 30px;
Expand All @@ -132,11 +139,13 @@ color: #003168;
font-weight: bold;
max-height: 20px;
}
#pinTitleLabel, #pinErrorLabel {
max-height: 20px;
#pinTitleLabel {
font-size: 14px;
color: #07142A;
}
#pinErrorLabel {
color: #CD2541;
font-size: 14px;
color: #AD2A45;
}
#fatalError {
border: 1px solid rgba(240,78,35,0.1);
Expand Down Expand Up @@ -569,29 +578,19 @@ border-radius: 4px;</string>
<item>
<layout class="QVBoxLayout" name="pinLayout">
<property name="spacing">
<number>10</number>
<number>6</number>
</property>
<item>
<widget class="QLabel" name="pinTitleLabel">
<property name="font">
<font>
<family>Roboto</family>
<pointsize>-1</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Enter PIN1 for authentication</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="buddy">
<cstring>pinInput</cstring>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<item>
<widget class="QLineEdit" name="pinInput">
<property name="maxLength">
<number>12</number>
Expand All @@ -603,21 +602,12 @@ border-radius: 4px;</string>
</item>
<item>
<widget class="QLabel" name="pinErrorLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>36</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="text">
<string notr="true">2 tries left</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
Expand All @@ -640,19 +630,6 @@ border-radius: 4px;</string>
</property>
</widget>
</item>
<item>
<spacer name="pinSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
Expand Down
3 changes: 3 additions & 0 deletions src/ui/images/alert.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/ui/images/alert_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions src/ui/translations/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
<translation> (Platnost vypršela)</translation>
</message>
<message>
<source>&lt;b&gt;%1&lt;/b&gt;&lt;br /&gt;Issuer: %2&lt;br /&gt;Valid: %3 to %4%5</source>
<translation>&lt;b&gt;%1&lt;/b&gt;&lt;br /&gt;Vydavatel: %2&lt;br /&gt;Platný: %3 až %4%5</translation>
<source>Issuer: %1</source>
<translation>Vydavatel: %1</translation>
</message>
<message>
<source>Valid until: %1%2</source>
<translation>Platný do: %1%2</translation>
</message>
<message>
<source>Pin locked</source>
Expand Down
8 changes: 6 additions & 2 deletions src/ui/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
<translation> (Abgelaufen)</translation>
</message>
<message>
<source>&lt;b&gt;%1&lt;/b&gt;&lt;br /&gt;Issuer: %2&lt;br /&gt;Valid: %3 to %4%5</source>
<translation>&lt;b&gt;%1&lt;/b&gt;&lt;br /&gt;Aussteller: %2&lt;br /&gt;Gültig: %3 bis %4%5</translation>
<source>Issuer: %1</source>
<translation>Aussteller: %1</translation>
</message>
<message>
<source>Valid until: %1%2</source>
<translation>Gültig bis: %1%2</translation>
</message>
<message>
<source>Pin locked</source>
Expand Down
Loading
Loading