From 558ee635d1f3cd3c058b5d08fb360993f8ac8d35 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Wed, 27 Nov 2024 11:47:07 +0200 Subject: [PATCH] UI feedback fixes IB-8249 Signed-off-by: Raul Metsma --- client/QPCSC.cpp | 24 ++++++++-------- client/QSmartCard.cpp | 4 +-- client/dialogs/MobileDialog.ui | 11 ++++---- client/dialogs/MobileProgress.cpp | 1 + client/dialogs/MobileProgress.ui | 15 +++++----- client/dialogs/PinPopup.ui | 17 ++++++------ client/dialogs/PinUnblock.cpp | 25 ++++++++--------- client/dialogs/PinUnblock.ui | 43 +++++++++++++++-------------- client/dialogs/RoleAddressDialog.ui | 11 ++++---- client/dialogs/SmartIDDialog.ui | 11 ++++---- client/dialogs/SmartIDProgress.cpp | 1 + client/translations/en.ts | 4 +++ client/translations/et.ts | 4 +++ client/translations/ru.ts | 4 +++ 14 files changed, 97 insertions(+), 78 deletions(-) diff --git a/client/QPCSC.cpp b/client/QPCSC.cpp index 3f56cdbf1..97830c639 100644 --- a/client/QPCSC.cpp +++ b/client/QPCSC.cpp @@ -38,7 +38,7 @@ Q_LOGGING_CATEGORY(SCard,"QPCSC.SCard") static quint16 toUInt16(const QByteArray &data, int size) { - return size >= 2 ? quint16((quint16(data[size - 2]) << 8) | quint16(data[size - 1])) : 0; + return size >= 2 ? quint16((quint16(data[size - 2]) << 8) | quint8(data[size - 1])) : 0; } static QStringList stateToString(DWORD state) @@ -58,31 +58,31 @@ static QStringList stateToString(DWORD state) return result; } -template -static auto SCCall(const char *file, int line, const char *function, Func func, Args... args) +template +static auto SCCall(const char *file, int line, const char *function, Args... args) { - auto err = func(args...); + auto err = Func(args...); if(SCard().isDebugEnabled()) QMessageLogger(file, line, function, SCard().categoryName()).debug() << function << Qt::hex << (unsigned long)err; return err; } -#define SC(API, ...) SCCall(__FILE__, __LINE__, "SCard"#API, SCard##API, __VA_ARGS__) +#define SC(API, ...) SCCall(__FILE__, __LINE__, "SCard"#API, __VA_ARGS__) QHash QPCSCReader::Private::features() { if(!featuresList.isEmpty()) return featuresList; DWORD size = 0; - std::array feature{}; - if(SC(Control, card, DWORD(CM_IOCTL_GET_FEATURE_REQUEST), nullptr, 0U, feature.data(), DWORD(feature.size()), &size)) + std::array feature{}; + if(SC(Control, card, DWORD(CM_IOCTL_GET_FEATURE_REQUEST), nullptr, 0U, feature.data(), DWORD(feature.size() * sizeof(PCSC_TLV_STRUCTURE)), &size)) return featuresList; - for(auto p = feature.cbegin(); std::distance(feature.cbegin(), p) < size; ) + if(size % sizeof(PCSC_TLV_STRUCTURE)) + return featuresList; + for(const auto &f: feature) { - unsigned int tag = *p++, len = *p++, value = 0; - for(unsigned int i = 0; i < len; ++i) - value |= *p++ << 8 * i; - featuresList[DRIVER_FEATURES(tag)] = qFromBigEndian(value); + if(f.tag) + featuresList[DRIVER_FEATURES(f.tag)] = qFromBigEndian(f.value); } return featuresList; } diff --git a/client/QSmartCard.cpp b/client/QSmartCard.cpp index 16dcec7a3..83c91f3dd 100644 --- a/client/QSmartCard.cpp +++ b/client/QSmartCard.cpp @@ -383,7 +383,7 @@ QSmartCard::ErrorType QSmartCard::pinChange(QSmartCardData::PinType type, QWidge else { SslCertificate cert = d->t.authCert(); - title = cert.toString(cert.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber")); + title = cert.toString(cert.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber")); textBody = tr("To change %1 on a PinPad reader the old %1 code has to be entered first and then the new %1 code twice.").arg(QSmartCardData::typeString(type)); } return change(type, parent, newPin, oldPin, title, textBody); @@ -407,7 +407,7 @@ QSmartCard::ErrorType QSmartCard::pinUnblock(QSmartCardData::PinType type, bool else { SslCertificate cert = d->t.authCert(); - title = cert.toString(cert.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber")); + title = cert.toString(cert.showCN() ? QStringLiteral("CN, serialNumber") : QStringLiteral("GN SN, serialNumber")); textBody = isForgotPin ? tr("To change %1 code with the PUK code on a PinPad reader the PUK code has to be entered first and then the %1 code twice.").arg(QSmartCardData::typeString(type)) : tr("To unblock the %1 code on a PinPad reader the PUK code has to be entered first and then the %1 code twice.").arg(QSmartCardData::typeString(type)); diff --git a/client/dialogs/MobileDialog.ui b/client/dialogs/MobileDialog.ui index 7e29d64bf..7e22a88fb 100644 --- a/client/dialogs/MobileDialog.ui +++ b/client/dialogs/MobileDialog.ui @@ -3,7 +3,7 @@ MobileDialog - Qt::WindowModality::WindowModal + Qt::WindowModal @@ -41,6 +41,7 @@ padding: 10px 14px; border: 1px solid #C4CBD8; border-radius: 4px; color: #07142A; +background-color: white; placeholder-text-color: #607496; font-size: 16px; } @@ -107,7 +108,7 @@ background-color: #2F70B6; 40 - QLayout::SizeConstraint::SetFixedSize + QLayout::SetDefaultConstraint 40 @@ -130,13 +131,13 @@ background-color: #2F70B6; - Qt::FocusPolicy::TabFocus + Qt::TabFocus Enter your phone number to sign with mobile-ID - Qt::AlignmentFlag::AlignCenter + Qt::AlignCenter true @@ -264,7 +265,7 @@ background-color: #2F70B6; - Qt::Orientation::Horizontal + Qt::Horizontal diff --git a/client/dialogs/MobileProgress.cpp b/client/dialogs/MobileProgress.cpp index aee2e5a3e..0bfa1fe5a 100644 --- a/client/dialogs/MobileProgress.cpp +++ b/client/dialogs/MobileProgress.cpp @@ -70,6 +70,7 @@ MobileProgress::MobileProgress(QWidget *parent) d->setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint); d->setupUi(d); d->code->setBuddy(d->signProgressBar); + d->code->clear(); #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) const auto styleSheet = R"(QProgressBar { background-color: #d3d3d3; diff --git a/client/dialogs/MobileProgress.ui b/client/dialogs/MobileProgress.ui index a043f8025..5bc2a796a 100644 --- a/client/dialogs/MobileProgress.ui +++ b/client/dialogs/MobileProgress.ui @@ -3,7 +3,7 @@ MobileProgress - Qt::WindowModality::WindowModal + Qt::WindowModal @@ -35,6 +35,7 @@ padding: 10px 14px; border: 1px solid #C4CBD8; border-radius: 4px; color: #07142A; +background-color: white; placeholder-text-color: #607496; font-size: 16px; } @@ -168,20 +169,20 @@ background-color: #2F70B6; Control code: - Qt::AlignmentFlag::AlignCenter + Qt::AlignCenter - Qt::FocusPolicy::TabFocus + Qt::TabFocus 1234 - Qt::AlignmentFlag::AlignCenter + Qt::AlignCenter @@ -191,7 +192,7 @@ background-color: #2F70B6; Make sure control code matches with one in phone screen and enter mobile-ID PIN2-code. - Qt::AlignmentFlag::AlignCenter + Qt::AlignCenter true @@ -218,7 +219,7 @@ background-color: #2F70B6; 0 - Qt::AlignmentFlag::AlignCenter + Qt::AlignCenter false @@ -232,7 +233,7 @@ background-color: #2F70B6; - + PointingHandCursor diff --git a/client/dialogs/PinPopup.ui b/client/dialogs/PinPopup.ui index a4f254fe0..07d7f4947 100644 --- a/client/dialogs/PinPopup.ui +++ b/client/dialogs/PinPopup.ui @@ -3,7 +3,7 @@ PinPopup - Qt::WindowModality::WindowModal + Qt::WindowModal @@ -38,6 +38,7 @@ padding: 10px 14px; border: 1px solid #C4CBD8; border-radius: 4px; color: #07142A; +background-color: white; placeholder-text-color: #607496; font-size: 16px; } @@ -74,7 +75,7 @@ background-color: #2F70B6; 40 - QLayout::SizeConstraint::SetFixedSize + QLayout::SetDefaultConstraint 40 @@ -97,13 +98,13 @@ background-color: #2F70B6; - Qt::FocusPolicy::TabFocus + Qt::TabFocus <b>Mari Maasikas,</b> 48405050123 - Qt::AlignmentFlag::AlignCenter + Qt::AlignCenter true @@ -118,13 +119,13 @@ background-color: #2F70B6; - Qt::FocusPolicy::TabFocus + Qt::TabFocus You need to use a personal identification certificate for the selected activity. - Qt::AlignmentFlag::AlignCenter + Qt::AlignCenter true @@ -149,7 +150,7 @@ background-color: #2F70B6; - QLineEdit::EchoMode::Password + QLineEdit::Password @@ -194,7 +195,7 @@ background-color: #2F70B6; - Qt::Orientation::Horizontal + Qt::Horizontal diff --git a/client/dialogs/PinUnblock.cpp b/client/dialogs/PinUnblock.cpp index af9780643..9fc413e8c 100644 --- a/client/dialogs/PinUnblock.cpp +++ b/client/dialogs/PinUnblock.cpp @@ -45,18 +45,17 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t new Overlay(this); auto pattern = [](QSmartCardData::PinType type) { - return QStringLiteral("^\\d{%1,12}$").arg(QSmartCardData::minPinLen(type)); + return QRegularExpression(QStringLiteral("^\\d{%1,12}$").arg(QSmartCardData::minPinLen(type))); }; QRegularExpression regexpValidateCode; - QRegularExpression regexpNewCode; - regexpNewCode.setPattern(pattern(type)); + QRegularExpression regexpNewCode = pattern(type); switch(mode) { case PinUnblock::UnBlockPinWithPuk: ui->label->setText(tr("%1 unblocking").arg(QSmartCardData::typeString(type))); ui->change->setText(tr("Unblock")); - regexpValidateCode.setPattern(pattern(QSmartCardData::PukType)); + regexpValidateCode = pattern(QSmartCardData::PukType); ui->line1_text->setText(tr("To unblock the certificate you have to enter the PUK code.")); ui->line2_text->setText(tr("You can find your PUK code inside the ID-card codes envelope.")); ui->line3_text->setText(tr("If you have forgotten the PUK code for your ID card, please visit " @@ -65,7 +64,7 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t break; case PinUnblock::ChangePinWithPuk: ui->label->setText(tr("%1 code change").arg(QSmartCardData::typeString(type))); - regexpValidateCode.setPattern(pattern(QSmartCardData::PukType)); + regexpValidateCode = pattern(QSmartCardData::PukType); ui->line1_text->setText(type == QSmartCardData::Pin2Type ? tr("PIN2 code is used to digitally sign documents.") : tr("PIN1 code is used for confirming the identity of a person.")); @@ -75,7 +74,7 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t case PinUnblock::PinChange: ui->label->setText(tr("%1 code change").arg(QSmartCardData::typeString(type))); ui->labelPuk->setText(tr("Valid %1 code").arg(QSmartCardData::typeString(type))); - regexpValidateCode.setPattern(pattern(type)); + regexpValidateCode = pattern(type); if(type == QSmartCardData::PukType) { ui->line1_text->setText(tr("PUK code is used for unblocking the certificates, when PIN1 or PIN2 has been entered 3 times incorrectly.")); @@ -100,8 +99,14 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t ui->repeat->setValidator(new QRegularExpressionValidator(regexpNewCode, ui->repeat)); ui->puk->setValidator(new QRegularExpressionValidator(regexpValidateCode, ui->puk)); + auto setError = [](QLineEdit *input, QLabel *error, const QString &msg) { + input->setStyleSheet(msg.isEmpty() ? QString() : QStringLiteral("border-color: #BE7884")); + error->setFocusPolicy(msg.isEmpty() ? Qt::NoFocus : Qt::TabFocus); + error->setText(msg); + error->setHidden(msg.isEmpty()); + }; if(leftAttempts < 3) - ui->errorPuk->setText(mode == PinUnblock::PinChange ? + setError(ui->puk, ui->errorPuk, mode == PinUnblock::PinChange ? tr("Remaining attempts: %1").arg(leftAttempts) : tr("PUK remaining attempts: %1").arg(leftAttempts)); @@ -113,12 +118,6 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t if(auto *bullet = findChild(QStringLiteral("line%1_bullet").arg(i))) bullet->setHidden(isHidden); } - auto setError = [](QLineEdit *input, QLabel *error, const QString &msg) { - input->setStyleSheet(msg.isEmpty() ? QString() : QStringLiteral("border-color: #BE7884")); - error->setFocusPolicy(msg.isEmpty() ? Qt::NoFocus : Qt::TabFocus); - error->setText(msg); - error->setHidden(msg.isEmpty()); - }; connect(ui->cancel, &QPushButton::clicked, this, &PinUnblock::reject); connect(this, &PinUnblock::finished, this, &PinUnblock::close); connect(ui->pin, &QLineEdit::returnPressed, ui->change, &QPushButton::click); diff --git a/client/dialogs/PinUnblock.ui b/client/dialogs/PinUnblock.ui index a59f540a7..ecda1bde7 100644 --- a/client/dialogs/PinUnblock.ui +++ b/client/dialogs/PinUnblock.ui @@ -3,7 +3,7 @@ PinUnblock - Qt::WindowModality::WindowModal + Qt::WindowModal @@ -38,6 +38,7 @@ padding: 10px 14px; border: 1px solid #C4CBD8; border-radius: 4px; color: #07142A; +background-color: white; placeholder-text-color: #607496; font-size: 16px; } @@ -74,7 +75,7 @@ background-color: #2F70B6; 40 - QLayout::SizeConstraint::SetFixedSize + QLayout::SetFixedSize 40 @@ -97,13 +98,13 @@ background-color: #2F70B6; - Qt::FocusPolicy::TabFocus + Qt::TabFocus %1 code change - Qt::AlignmentFlag::AlignCenter + Qt::AlignCenter @@ -135,20 +136,20 @@ background-color: #2F70B6; &bull; - Qt::TextFormat::RichText + Qt::RichText - Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - Qt::FocusPolicy::TabFocus + Qt::TabFocus - Qt::TextFormat::RichText + Qt::RichText true @@ -176,20 +177,20 @@ background-color: #2F70B6; &bull; - Qt::TextFormat::RichText + Qt::RichText - Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - Qt::FocusPolicy::TabFocus + Qt::TabFocus - Qt::TextFormat::RichText + Qt::RichText true @@ -217,20 +218,20 @@ background-color: #2F70B6; &bull; - Qt::TextFormat::RichText + Qt::RichText - Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - Qt::FocusPolicy::TabFocus + Qt::TabFocus - Qt::TextFormat::RichText + Qt::RichText true @@ -260,7 +261,7 @@ background-color: #2F70B6; - QLineEdit::EchoMode::Password + QLineEdit::Password @@ -287,7 +288,7 @@ background-color: #2F70B6; - QLineEdit::EchoMode::Password + QLineEdit::Password @@ -314,7 +315,7 @@ background-color: #2F70B6; - QLineEdit::EchoMode::Password + QLineEdit::Password @@ -346,7 +347,7 @@ background-color: #2F70B6; - Qt::Orientation::Horizontal + Qt::Horizontal @@ -362,7 +363,7 @@ background-color: #2F70B6; PointingHandCursor - Unblock + Change true diff --git a/client/dialogs/RoleAddressDialog.ui b/client/dialogs/RoleAddressDialog.ui index 4d32b2331..ef2b08ee1 100644 --- a/client/dialogs/RoleAddressDialog.ui +++ b/client/dialogs/RoleAddressDialog.ui @@ -3,7 +3,7 @@ RoleAddressDialog - Qt::WindowModality::WindowModal + Qt::WindowModal @@ -38,6 +38,7 @@ padding: 10px 14px; border: 1px solid #C4CBD8; border-radius: 4px; color: #07142A; +background-color: white; placeholder-text-color: #607496; font-size: 16px; } @@ -74,7 +75,7 @@ background-color: #2F70B6; 40 - QLayout::SizeConstraint::SetFixedSize + QLayout::SetFixedSize 40 @@ -97,13 +98,13 @@ background-color: #2F70B6; - Qt::FocusPolicy::TabFocus + Qt::TabFocus Enter your role and address info - Qt::AlignmentFlag::AlignCenter + Qt::AlignCenter @@ -232,7 +233,7 @@ background-color: #2F70B6; - Qt::Orientation::Horizontal + Qt::Horizontal diff --git a/client/dialogs/SmartIDDialog.ui b/client/dialogs/SmartIDDialog.ui index 00691b4d4..13bcdaccf 100644 --- a/client/dialogs/SmartIDDialog.ui +++ b/client/dialogs/SmartIDDialog.ui @@ -3,7 +3,7 @@ SmartIDDialog - Qt::WindowModality::WindowModal + Qt::WindowModal @@ -41,6 +41,7 @@ padding: 10px 14px; border: 1px solid #C4CBD8; border-radius: 4px; color: #07142A; +background-color: white; placeholder-text-color: #607496; font-size: 16px; } @@ -143,7 +144,7 @@ background-color: #2F70B6; 40 - QLayout::SizeConstraint::SetFixedSize + QLayout::SetFixedSize 40 @@ -166,13 +167,13 @@ background-color: #2F70B6; - Qt::FocusPolicy::TabFocus + Qt::TabFocus Enter your personal code to sign with Smart-ID - Qt::AlignmentFlag::AlignCenter + Qt::AlignCenter true @@ -302,7 +303,7 @@ background-color: #2F70B6; - Qt::Orientation::Horizontal + Qt::Horizontal diff --git a/client/dialogs/SmartIDProgress.cpp b/client/dialogs/SmartIDProgress.cpp index da2070fa8..c0e7dd2e1 100644 --- a/client/dialogs/SmartIDProgress.cpp +++ b/client/dialogs/SmartIDProgress.cpp @@ -83,6 +83,7 @@ SmartIDProgress::SmartIDProgress(QWidget *parent) d->setupUi(d); d->signProgressBar->setMaximum(100); d->code->setBuddy(d->signProgressBar); + d->code->clear(); #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) const auto styleSheet = R"(QProgressBar { background-color: #d3d3d3;; diff --git a/client/translations/en.ts b/client/translations/en.ts index a349a92c3..056a15907 100644 --- a/client/translations/en.ts +++ b/client/translations/en.ts @@ -2066,6 +2066,10 @@ ID-CARD Current PUK code Current PUK code + + Change + Change + PrintSheet diff --git a/client/translations/et.ts b/client/translations/et.ts index 91ef7c91f..8a37c76aa 100644 --- a/client/translations/et.ts +++ b/client/translations/et.ts @@ -2066,6 +2066,10 @@ ID-KAARDIGA Current PUK code Kehtiv PUK-kood + + Change + Muuda + PrintSheet diff --git a/client/translations/ru.ts b/client/translations/ru.ts index d8631c195..99f41bc65 100644 --- a/client/translations/ru.ts +++ b/client/translations/ru.ts @@ -2067,6 +2067,10 @@ ID-КАРТОЙ Current PUK code Действующий PUK-код + + Change + Поменять + PrintSheet