From c2582fa68970e4064fc5189bbe9463d3fe9ec2a3 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Thu, 9 Feb 2023 11:09:33 +0200 Subject: [PATCH] More verbose error messages (#1103) IB-7308 Signed-off-by: Raul Metsma --- client/IKValidator.cpp | 24 +- client/IKValidator.h | 6 +- client/dialogs/AddRecipients.cpp | 2 +- client/dialogs/CertificateDetails.cpp | 4 +- client/dialogs/KeyDialog.cpp | 2 +- client/dialogs/MobileDialog.cpp | 89 +-- client/dialogs/MobileDialog.h | 6 +- client/dialogs/MobileDialog.ui | 59 +- client/dialogs/PinUnblock.cpp | 301 ++++----- client/dialogs/PinUnblock.h | 26 +- client/dialogs/PinUnblock.ui | 900 ++++++++++---------------- client/dialogs/SettingsDialog.cpp | 2 +- client/dialogs/SignatureDialog.cpp | 2 +- client/dialogs/SmartIDDialog.cpp | 47 +- client/dialogs/SmartIDDialog.ui | 69 +- client/effects/Overlay.cpp | 15 +- client/effects/Overlay.h | 6 +- client/translations/en.ts | 12 +- client/translations/et.ts | 12 +- client/translations/ru.ts | 12 +- client/widgets/ContainerPage.cpp | 6 +- 21 files changed, 667 insertions(+), 935 deletions(-) diff --git a/client/IKValidator.cpp b/client/IKValidator.cpp index facef3c07..c77a951c2 100644 --- a/client/IKValidator.cpp +++ b/client/IKValidator.cpp @@ -22,10 +22,6 @@ #include #include -IKValidator::IKValidator(QObject *parent) - : QValidator(parent) -{} - QDate IKValidator::birthDate(const QString &ik) { if(ik.size() != 11) return {}; @@ -41,9 +37,9 @@ QDate IKValidator::birthDate(const QString &ik) } QDate date( - ik.mid(1, 2).toUInt() + year, - ik.mid(3, 2).toUInt(), - ik.mid(5, 2).toUInt() ); + ik.mid(1, 2).toInt() + year, + ik.mid(3, 2).toInt(), + ik.mid(5, 2).toInt()); return date.isValid() ? date : QDate(); } @@ -76,8 +72,8 @@ bool IKValidator::isValid(const QString &ik) int sum1 = 0, sum2 = 0; for(int i = 0, pos1 = 1, pos2 = 3; i < 10; ++i) { - sum1 += ik.mid(i, 1).toUInt() * pos1; - sum2 += ik.mid(i, 1).toUInt() * pos2; + sum1 += ik.mid(i, 1).toInt() * pos1; + sum2 += ik.mid(i, 1).toInt() * pos2; pos1 = pos1 == 9 ? 1 : pos1 + 1; pos2 = pos2 == 9 ? 1 : pos2 + 1; } @@ -90,16 +86,6 @@ bool IKValidator::isValid(const QString &ik) return ik.right( 1 ).toInt() == result; } -QValidator::State IKValidator::validate(QString &input, int &/*pos*/) const -{ - input = input.trimmed(); - if(input.size() > 11 || !QRegularExpression(QStringLiteral("\\d{0,11}")).match(input).hasMatch()) - return Invalid; - if(input.size() == 11) - return isValid(input) ? Acceptable : Invalid; - return Intermediate; -} - NumberValidator::NumberValidator(QObject *parent) diff --git a/client/IKValidator.h b/client/IKValidator.h index f766a06ed..e0cc24f81 100644 --- a/client/IKValidator.h +++ b/client/IKValidator.h @@ -21,15 +21,11 @@ #include -class IKValidator: public QValidator +class IKValidator { - Q_OBJECT public: - explicit IKValidator(QObject *parent); - static QDate birthDate(const QString &ik); static bool isValid(const QString &ik); - State validate(QString &input, int &pos) const; }; diff --git a/client/dialogs/AddRecipients.cpp b/client/dialogs/AddRecipients.cpp index 5fea4e874..498c083d7 100644 --- a/client/dialogs/AddRecipients.cpp +++ b/client/dialogs/AddRecipients.cpp @@ -56,7 +56,7 @@ AddRecipients::AddRecipients(ItemList* itemList, QWidget *parent) ui->actionLayout->setDirection(QBoxLayout::RightToLeft); #endif setWindowFlags( Qt::Dialog | Qt::CustomizeWindowHint ); - new Overlay(this, parent->topLevelWidget()); + new Overlay(this, parent); ui->leftPane->init(ria::qdigidoc4::ToAddAdresses, QT_TRANSLATE_NOOP("ItemList", "Add recipients")); ui->leftPane->setFont(Styles::font(Styles::Regular, 20)); diff --git a/client/dialogs/CertificateDetails.cpp b/client/dialogs/CertificateDetails.cpp index d26b03612..0cc402303 100644 --- a/client/dialogs/CertificateDetails.cpp +++ b/client/dialogs/CertificateDetails.cpp @@ -46,9 +46,7 @@ CertificateDetails::CertificateDetails(const SslCertificate &cert, QWidget *pare #else setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); #endif - Overlay *overlay = new Overlay(parent->topLevelWidget()); - overlay->show(); - connect(this, &CertificateDetails::destroyed, overlay, &Overlay::deleteLater); + new Overlay(this, parent); QFont headerFont = Styles::font( Styles::Regular, 18 ); QFont regularFont = Styles::font( Styles::Regular, 14 ); diff --git a/client/dialogs/KeyDialog.cpp b/client/dialogs/KeyDialog.cpp index 28392635e..b9b8060cc 100644 --- a/client/dialogs/KeyDialog.cpp +++ b/client/dialogs/KeyDialog.cpp @@ -37,7 +37,7 @@ KeyDialog::KeyDialog( const CKey &k, QWidget *parent ) d->buttonLayout->setDirection(QBoxLayout::RightToLeft); #endif setWindowFlag(Qt::CustomizeWindowHint); - new Overlay(this, parent->topLevelWidget()); + new Overlay(this, parent); QFont condensed = Styles::font(Styles::Condensed, 12); QFont regular = Styles::font(Styles::Regular, 14); diff --git a/client/dialogs/MobileDialog.cpp b/client/dialogs/MobileDialog.cpp index 84cf86c26..e9c39d99b 100644 --- a/client/dialogs/MobileDialog.cpp +++ b/client/dialogs/MobileDialog.cpp @@ -19,6 +19,7 @@ #include "MobileDialog.h" #include "ui_MobileDialog.h" + #include "IKValidator.h" #include "Styles.h" #include "dialogs/SettingsDialog.h" @@ -33,24 +34,21 @@ MobileDialog::MobileDialog(QWidget *parent) : QDialog(parent), ui(new Ui::MobileDialog) { - new Overlay(this, parent->topLevelWidget()); + new Overlay(this, parent); ui->setupUi(this); - setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint ); - setFixedSize( size() ); -#if defined (Q_OS_WIN) + setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); + setFixedSize(size()); +#ifdef Q_OS_WIN ui->buttonLayout->setDirection(QBoxLayout::RightToLeft); #endif - connect( ui->sign, &QPushButton::clicked, this, &MobileDialog::accept ); - connect( ui->cancel, &QPushButton::clicked, this, &MobileDialog::reject ); - connect( this, &MobileDialog::finished, this, &MobileDialog::close ); - QFont condensed = Styles::font(Styles::Condensed, 14); - QFont header = Styles::font(Styles::Regular, 16, QFont::DemiBold); QFont regularFont = Styles::font(Styles::Regular, 14); - ui->labelNameId->setFont(header); + ui->labelNameId->setFont(Styles::font(Styles::Regular, 16, QFont::DemiBold)); ui->labelPhone->setFont(regularFont); ui->labelCode->setFont(regularFont); + ui->errorCode->setFont(regularFont); + ui->errorPhone->setFont(regularFont); ui->phoneNo->setFont(regularFont); ui->idCode->setFont(regularFont); ui->cbRemember->setFont(regularFont); @@ -58,25 +56,57 @@ MobileDialog::MobileDialog(QWidget *parent) : ui->cancel->setFont(condensed); // Mobile - ui->idCode->setValidator( new IKValidator( ui->idCode ) ); + ui->idCode->setValidator(new NumberValidator(ui->idCode)); ui->idCode->setText(QSettings().value(QStringLiteral("MobileCode")).toString()); ui->idCode->setAttribute(Qt::WA_MacShowFocusRect, false); - ui->phoneNo->setValidator( new NumberValidator( ui->phoneNo ) ); + ui->phoneNo->setValidator(new NumberValidator(ui->phoneNo)); ui->phoneNo->setText(QSettings().value(QStringLiteral("MobileNumber"), COUNTRY_CODE_EST).toString()); ui->phoneNo->setAttribute(Qt::WA_MacShowFocusRect, false); - connect(ui->idCode, &QLineEdit::returnPressed, ui->sign, &QPushButton::click); - connect(ui->phoneNo, &QLineEdit::returnPressed, ui->sign, &QPushButton::click); ui->cbRemember->setChecked(QSettings().value(QStringLiteral("MobileSettings"), true).toBool()); ui->cbRemember->setAttribute(Qt::WA_MacShowFocusRect, false); - connect(ui->idCode, &QLineEdit::textEdited, this, &MobileDialog::enableSign); - connect(ui->phoneNo, &QLineEdit::textEdited, this, &MobileDialog::enableSign); - connect(ui->cbRemember, &QCheckBox::clicked, this, [=](bool checked) { + auto saveSettings = [this] { + bool checked = ui->cbRemember->isChecked(); + SettingsDialog::setValueEx(QStringLiteral("MobileSettings"), checked, true); SettingsDialog::setValueEx(QStringLiteral("MobileCode"), checked ? ui->idCode->text() : QString()); SettingsDialog::setValueEx(QStringLiteral("MobileNumber"), checked ? ui->phoneNo->text() : QString()); - SettingsDialog::setValueEx(QStringLiteral("MobileSettings"), checked, true); + }; + connect(ui->idCode, &QLineEdit::returnPressed, ui->sign, &QPushButton::click); + connect(ui->idCode, &QLineEdit::textEdited, this, saveSettings); + connect(ui->phoneNo, &QLineEdit::returnPressed, ui->sign, &QPushButton::click); + connect(ui->phoneNo, &QLineEdit::textEdited, this, saveSettings); + connect(ui->cbRemember, &QCheckBox::clicked, this, saveSettings); + connect(ui->sign, &QPushButton::clicked, this, [this] { + static const QStringList countryCodes {COUNTRY_CODE_EST, COUNTRY_CODE_LTU}; + if(!IKValidator::isValid(idCode())) + { + ui->idCode->setStyleSheet(QStringLiteral("border-color: #c53e3e")); + ui->errorCode->setText(tr("Personal code is not valid")); + } + else + { + ui->idCode->setStyleSheet({}); + ui->errorCode->clear(); + } + if(phoneNo().size() < 8 || countryCodes.contains(phoneNo())) + { + ui->phoneNo->setStyleSheet(QStringLiteral("border-color: #c53e3e")); + ui->errorPhone->setText(tr("Phone number is not entered")); + } + else if(!countryCodes.contains(phoneNo().left(3))) + { + ui->phoneNo->setStyleSheet(QStringLiteral("border-color: #c53e3e")); + ui->errorPhone->setText(tr("Invalid country code")); + } + else + { + ui->phoneNo->setStyleSheet({}); + ui->errorPhone->clear(); + } + if(ui->errorCode->text().isEmpty() && ui->errorPhone->text().isEmpty()) + accept(); }); - - enableSign(); + connect(ui->cancel, &QPushButton::clicked, this, &MobileDialog::reject); + connect(this, &MobileDialog::finished, this, &MobileDialog::close); } MobileDialog::~MobileDialog() @@ -84,25 +114,6 @@ MobileDialog::~MobileDialog() delete ui; } -void MobileDialog::enableSign() -{ - static const QStringList countryCodes {COUNTRY_CODE_EST, COUNTRY_CODE_LTU}; - if( ui->cbRemember->isChecked() ) - { - SettingsDialog::setValueEx(QStringLiteral("MobileCode"), ui->idCode->text()); - SettingsDialog::setValueEx(QStringLiteral("MobileNumber"), ui->phoneNo->text(), - ui->phoneNo->text() == COUNTRY_CODE_EST ? COUNTRY_CODE_EST : QString()); - } - ui->sign->setToolTip(QString()); - if( !IKValidator::isValid( ui->idCode->text() ) ) - ui->sign->setToolTip( tr("Personal code is not valid") ); - if(ui->phoneNo->text().size() < 8 || countryCodes.contains(ui->phoneNo->text())) - ui->sign->setToolTip( tr("Phone number is not entered") ); - if(!countryCodes.contains(ui->phoneNo->text().left(3))) - ui->sign->setToolTip(tr("Invalid country code")); - ui->sign->setEnabled( ui->sign->toolTip().isEmpty() ); -} - QString MobileDialog::idCode() { return ui->idCode->text(); diff --git a/client/dialogs/MobileDialog.h b/client/dialogs/MobileDialog.h index 088574c9d..7875dba7d 100644 --- a/client/dialogs/MobileDialog.h +++ b/client/dialogs/MobileDialog.h @@ -21,9 +21,7 @@ #include -namespace Ui { -class MobileDialog; -} +namespace Ui { class MobileDialog; } class MobileDialog final : public QDialog { @@ -37,8 +35,6 @@ class MobileDialog final : public QDialog QString phoneNo(); private: - void enableSign(); - Ui::MobileDialog *ui; }; diff --git a/client/dialogs/MobileDialog.ui b/client/dialogs/MobileDialog.ui index 43bf598bb..da86d71ea 100644 --- a/client/dialogs/MobileDialog.ui +++ b/client/dialogs/MobileDialog.ui @@ -2,15 +2,12 @@ MobileDialog - - Qt::WindowModal - 0 0 - 380 - 282 + 382 + 301 @@ -22,6 +19,12 @@ background-color: #FFFFFF; color: #000000; border-radius: 2px; } +#labelCode, #labelPhone { +color: #353739 +} +#errorCode, #errorPhone { +color: #c53e3e +} QLineEdit { padding: 0px 10px; border: 1px solid #DEE4E9; @@ -118,7 +121,7 @@ background-color: #BEDBED; 20 - 67 + 8 @@ -131,9 +134,6 @@ background-color: #BEDBED; 12 - - color: #353739; - Country code and phone number @@ -155,6 +155,15 @@ background-color: #BEDBED; + + + + + 12 + + + + @@ -163,10 +172,6 @@ background-color: #BEDBED; 12 - - color: #353739; -padding-top: 8px; - Personal code @@ -189,20 +194,13 @@ padding-top: 8px; - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - + + + + 12 + - + @@ -219,7 +217,7 @@ padding-top: 8px; 20 - 66 + 8 @@ -233,7 +231,7 @@ padding-top: 8px; - 120 + 0 30 @@ -258,12 +256,9 @@ padding-top: 8px; - - false - - 120 + 0 30 diff --git a/client/dialogs/PinUnblock.cpp b/client/dialogs/PinUnblock.cpp index 9b5ab820d..c5acb8a36 100644 --- a/client/dialogs/PinUnblock.cpp +++ b/client/dialogs/PinUnblock.cpp @@ -23,111 +23,177 @@ #include "Styles.h" #include "effects/Overlay.h" -#include -#include #include - -PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType type, short leftAttempts, - QDate birthDate, QString personalCode) +PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType type, + short leftAttempts, QDate birthDate, const QString &personalCode) : QDialog(parent) , ui(new Ui::PinUnblock) - , birthDate(birthDate) - , personalCode(std::move(personalCode)) { ui->setupUi(this); #if defined (Q_OS_WIN) - ui->horizontalLayout->setDirection(QBoxLayout::RightToLeft); + ui->buttonLayout->setDirection(QBoxLayout::RightToLeft); #endif setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); for(QLineEdit *w: findChildren()) w->setAttribute(Qt::WA_MacShowFocusRect, false); - new Overlay(this, parent->topLevelWidget()); - - ui->unblock->setEnabled(false); - connect(ui->unblock, &QPushButton::clicked, this, &PinUnblock::accept); - connect(ui->cancel, &QPushButton::clicked, this, &PinUnblock::reject); - connect(this, &PinUnblock::finished, this, &PinUnblock::close); + new Overlay(this, parent); + QFont condensed14 = Styles::font(Styles::Condensed, 14); QFont condensed12 = Styles::font(Styles::Condensed, 12); + QFont regular14 = Styles::font(Styles::Regular, 14); + QFont regular12 = Styles::font(Styles::Regular, 12); + ui->errorPuk->setFont(regular12); + ui->errorPin->setFont(regular12); + ui->errorRepeat->setFont(regular12); ui->labelPuk->setFont(condensed12); ui->labelPin->setFont(condensed12); ui->labelRepeat->setFont(condensed12); + ui->labelNameId->setFont(Styles::font(Styles::Regular, 20, QFont::DemiBold)); + ui->cancel->setFont(condensed14); + ui->change->setFont(condensed14); + for(QLabel *text: findChildren(QRegularExpression(QStringLiteral("line\\d_[text,bullet]")))) + text->setFont(regular14); - if(mode == PinUnblock::ChangePinWithPuk) - { - ui->labelNameId->setText(tr("%1 code change").arg(QSmartCardData::typeString(type))); - regexpFirstCode.setPattern(QStringLiteral("^\\d{8,12}$")); - regexpNewCode.setPattern((type == QSmartCardData::Pin1Type) ? QStringLiteral("^\\d{4,12}$") : QStringLiteral("^\\d{5,12}$")); - ui->unblock->setText(tr("CHANGE")); - } - if(mode == PinUnblock::UnBlockPinWithPuk) + auto pattern = [](QSmartCardData::PinType type) { + return QStringLiteral("^\\d{%1,12}$").arg(QSmartCardData::minPinLen(type)); + }; + + QRegularExpression regexpValidateCode; + QRegularExpression regexpNewCode; + regexpNewCode.setPattern(pattern(type)); + switch(mode) { + case PinUnblock::UnBlockPinWithPuk: ui->labelNameId->setText(tr("%1 unblocking").arg(QSmartCardData::typeString(type))); - regexpFirstCode.setPattern(QStringLiteral("^\\d{8,12}$")); - regexpNewCode.setPattern((type == QSmartCardData::Pin1Type) ? QStringLiteral("^\\d{4,12}$") : QStringLiteral("^\\d{5,12}$")); - } - else if(mode == PinUnblock::PinChange) - { + ui->change->setText(tr("UNBLOCK")); + regexpValidateCode.setPattern(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 " + "" + "the Police and Border Guard Board service center to obtain new PIN codes.")); + break; + case PinUnblock::ChangePinWithPuk: + ui->labelNameId->setText(tr("%1 code change").arg(QSmartCardData::typeString(type))); + regexpValidateCode.setPattern(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.")); + ui->line2_text->setText(tr("If you have forgotten PIN%1, but know PUK, then here you can enter new PIN%1.").arg(type)); + ui->line3_text->setText(tr("PUK code is written in the envelope, that is given with the ID-card.")); + break; + case PinUnblock::PinChange: ui->labelNameId->setText(tr("%1 code change").arg(QSmartCardData::typeString(type))); ui->labelPuk->setText(tr("VALID %1 CODE").arg(QSmartCardData::typeString(type))); - regexpFirstCode.setPattern((type == QSmartCardData::Pin1Type) ? QStringLiteral("^\\d{4,12}$") : - (type == QSmartCardData::Pin2Type) ? QStringLiteral("^\\d{5,12}$") : QStringLiteral("^\\d{8,12}$")); - regexpNewCode.setPattern((type == QSmartCardData::Pin1Type) ? QStringLiteral("^\\d{4,12}$") : - (type == QSmartCardData::Pin2Type) ? QStringLiteral("^\\d{5,12}$") : QStringLiteral("^\\d{8,12}$")); - ui->unblock->setText(tr("CHANGE")); + regexpValidateCode.setPattern(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.")); + ui->line2_text->setText(tr("If you forget the PUK code or the certificates remain blocked, you have to visit the " + "service center to obtain new codes.")); + break; + } + 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.")); + ui->line2_text->setText( + tr("If %1 is inserted incorrectly 3 times the %2 certificate will be blocked and it will be impossible to use ID-card to %3, until it is unblocked via the PUK code.") + .arg(QSmartCardData::typeString(type)) + .arg(type == QSmartCardData::Pin2Type ? tr("signing") : tr("identification")) + .arg(type == QSmartCardData::Pin2Type ? tr("digital signing") : tr("verify identification")) + ); } setWindowTitle(ui->labelNameId->text()); ui->labelPin->setText(tr("NEW %1 CODE").arg(QSmartCardData::typeString(type))); ui->labelRepeat->setText(tr("NEW %1 CODE AGAIN").arg(QSmartCardData::typeString(type))); ui->pin->setAccessibleName(ui->labelPin->text().toLower()); + ui->pin->setValidator(new QRegularExpressionValidator(regexpNewCode, ui->pin)); ui->repeat->setAccessibleName(ui->labelRepeat->text().toLower()); + ui->repeat->setValidator(new QRegularExpressionValidator(regexpNewCode, ui->repeat)); ui->puk->setAccessibleName(ui->labelPuk->text().toLower()); - ui->unblock->setAccessibleName(ui->unblock->text().toLower()); + ui->puk->setValidator(new QRegularExpressionValidator(regexpValidateCode, ui->puk)); + ui->change->setAccessibleName(ui->change->text().toLower()); - ui->puk->setValidator(new QRegularExpressionValidator(regexpFirstCode, ui->puk)); - ui->pin->setValidator(new QRegularExpressionValidator(regexpFirstCode, ui->pin)); - ui->repeat->setValidator(new QRegularExpressionValidator(regexpFirstCode, ui->repeat)); - - QFont condensed14(Styles::font(Styles::Condensed, 14)); - QFont headerFont(Styles::font(Styles::Regular, 18)); - QFont regular13(Styles::font(Styles::Regular, 13)); - headerFont.setWeight(QFont::Bold); - ui->labelNameId->setFont(headerFont); - ui->cancel->setFont(condensed14); - ui->unblock->setFont(condensed14); - ui->labelAttemptsLeft->setFont(regular13); - ui->labelPinValidation->setFont(regular13); - ui->labelPinValidation->hide(); - if(mode == PinUnblock::ChangePinWithPuk || mode == PinUnblock::UnBlockPinWithPuk) - ui->labelAttemptsLeft->setText(tr("PUK remaining attempts: %1").arg(leftAttempts)); + if(leftAttempts == 3) + ui->errorPuk->clear(); + else if(mode == PinUnblock::PinChange) + ui->errorPuk->setText(tr("Remaining attempts: %1").arg(leftAttempts)); else - ui->labelAttemptsLeft->setText(tr("Remaining attempts: %1").arg(leftAttempts)); - ui->labelAttemptsLeft->setVisible(leftAttempts < 3); + ui->errorPuk->setText(tr("PUK remaining attempts: %1").arg(leftAttempts)); - initIntro(mode, type); + for(int i = 1; i < 4; i++) + { + bool isHidden = true; + if(QLabel *text = findChild(QStringLiteral("line%1_text").arg(i))) + text->setHidden(isHidden = text->text().isEmpty()); + if(QLabel *bullet = findChild(QStringLiteral("line%1_bullet").arg(i))) + bullet->setHidden(isHidden); + } - connect(ui->puk, &QLineEdit::textChanged, this, [this](const QString &text) { - isFirstCodeOk = regexpFirstCode.match(text).hasMatch(); - setUnblockEnabled(); - }); - connect(ui->pin, &QLineEdit::textChanged, this, [this, type, mode](const QString &text) { - ui->labelPinValidation->hide(); - isNewCodeOk = regexpNewCode.match(text).hasMatch() && validatePin(text, type, mode); - isRepeatCodeOk = !text.isEmpty() && ui->pin->text() == ui->repeat->text(); - setUnblockEnabled(); - }); - connect(ui->repeat, &QLineEdit::textChanged, this, [this] { - isRepeatCodeOk = !ui->pin->text().isEmpty() && ui->pin->text() == ui->repeat->text(); - setUnblockEnabled(); + connect(ui->cancel, &QPushButton::clicked, this, &PinUnblock::reject); + connect(this, &PinUnblock::finished, this, &PinUnblock::close); + connect(ui->pin, &QLineEdit::returnPressed, ui->change, &QPushButton::click); + connect(ui->repeat, &QLineEdit::returnPressed, ui->change, &QPushButton::click); + connect(ui->puk, &QLineEdit::returnPressed, ui->change, &QPushButton::click); + connect(ui->change, &QPushButton::clicked, this, [=] { + const static QString SEQUENCE_ASCENDING = QStringLiteral("1234567890123456789012"); + const static QString SEQUENCE_DESCENDING = QStringLiteral("0987654321098765432109"); + ui->puk->setStyleSheet({}); + ui->pin->setStyleSheet({}); + ui->repeat->setStyleSheet({}); + ui->errorPuk->clear(); + ui->errorPin->clear(); + ui->errorRepeat->clear(); + auto setError = [](QLineEdit *input, QLabel *error, const QString &msg) { + input->setStyleSheet(QStringLiteral("border-color: #c53e3e")); + error->setText(msg); + }; + auto pinError = [](auto type) { + return tr("%1 length has to be between %2 and 12") + .arg(QSmartCardData::typeString(type)).arg(QSmartCardData::minPinLen(type)); + }; + + // Verify checks + if(!regexpValidateCode.match(ui->puk->text()).hasMatch()) + setError(ui->puk, ui->errorPuk, pinError(mode == PinUnblock::PinChange ? type : QSmartCardData::PukType)); + + // PIN checks + QString pin = ui->pin->text(); + if(!regexpNewCode.match(pin).hasMatch()) + return setError(ui->pin, ui->errorPin, pinError(type)); + if(SEQUENCE_ASCENDING.contains(pin)) + return setError(ui->pin, ui->errorPin, + tr("New %1 code can't be increasing sequence").arg(QSmartCardData::typeString(type))); + if(SEQUENCE_DESCENDING.contains(pin)) + return setError(ui->pin, ui->errorPin, + tr("New %1 code can't be decreasing sequence").arg(QSmartCardData::typeString(type))); + if(pin.count(pin[1]) == pin.length()) + return setError(ui->pin, ui->errorPin, + tr("New %1 code can't be sequence of same numbers").arg(QSmartCardData::typeString(type))); + if(personalCode.contains(pin)) + return setError(ui->pin, ui->errorPin, + tr("New %1 code can't be part of your personal code").arg(QSmartCardData::typeString(type))); + if(pin == birthDate.toString(QStringLiteral("yyyy")) || + pin == birthDate.toString(QStringLiteral("ddMM")) || + pin == birthDate.toString(QStringLiteral("MMdd")) || + pin == birthDate.toString(QStringLiteral("yyyyMMdd")) || + pin == birthDate.toString(QStringLiteral("ddMMyyyy"))) + return setError(ui->pin, ui->errorPin, + tr("New %1 code can't be your date of birth").arg(QSmartCardData::typeString(type))); + if(mode == PinUnblock::PinChange && pin == ui->puk->text()) + return setError(ui->pin, ui->errorPin, + tr("Current %1 code and new %1 code must be different").arg(QSmartCardData::typeString(type))); + + // Repeat checks + QString repeat = ui->repeat->text(); + if(!regexpNewCode.match(repeat).hasMatch()) + return setError(ui->repeat, ui->errorRepeat, pinError(type)); + if(pin != repeat) + return setError(ui->repeat, ui->errorRepeat, + tr("New %1 codes doesn't match").arg(QSmartCardData::typeString(type))); + accept(); }); - QSizePolicy sp_retain = ui->labelPinValidation->sizePolicy(); - sp_retain.setRetainSizeWhenHidden(true); - ui->labelPinValidation->setSizePolicy(sp_retain); - ui->labelNameId->setFont(Styles::font(Styles::Regular, 20, QFont::DemiBold)); - connect(ui->pin, &QLineEdit::returnPressed, ui->unblock, &QPushButton::click); - connect(ui->repeat, &QLineEdit::returnPressed, ui->unblock, &QPushButton::click); - connect(ui->puk, &QLineEdit::returnPressed, ui->unblock, &QPushButton::click); adjustSize(); setFixedSize(size()); } @@ -137,98 +203,7 @@ PinUnblock::~PinUnblock() delete ui; } -void PinUnblock::initIntro(WorkMode mode, QSmartCardData::PinType type) -{ - switch(mode) - { - case PinUnblock::ChangePinWithPuk: - 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.")); - ui->line2_text->setText(tr("If you have forgotten PIN%1, but know PUK, then here you can enter new PIN%1.").arg(type)); - ui->line3_text->setText(tr("PUK code is written in the envelope, that is given with the ID-card.")); - break; - case PinUnblock::UnBlockPinWithPuk: - 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 " - "" - "the Police and Border Guard Board service center to obtain new PIN codes.")); - break; - default: - if(type == QSmartCardData::Pin2Type || type == QSmartCardData::Pin1Type) - { - 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.")); - ui->line2_text->setText( - tr("If PIN%1 is inserted incorrectly 3 times the %2 certificate will be blocked and it will be impossible to use ID-card to %3, until it is unblocked via the PUK code.") - .arg(type) - .arg(type == QSmartCardData::Pin2Type ? tr("signing") : tr("identification")) - .arg(type == QSmartCardData::Pin2Type ? tr("digital signing") : tr("verify identification")) - ); - } - else 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.")); - ui->line2_text->setText(tr("If you forget the PUK code or the certificates remain blocked, you have to visit the " - "service center to obtain new codes.")); - } - break; - } - QFont font = Styles::font(Styles::Regular, 14); - for(int i = 0; i < 4; i++) - { - bool isHidden = true; - if(QLabel *text = findChild(QStringLiteral("line%1_text").arg(i + 1))) - { - text->setFont(font); - text->setHidden(isHidden = text->text().isEmpty()); - } - if(QLabel *bullet = findChild(QStringLiteral("line%1_bullet").arg(i + 1))) - { - bullet->setFont(font); - bullet->setHidden(isHidden); - } - } -} - -void PinUnblock::setUnblockEnabled() -{ - ui->iconLabelPuk->load(isFirstCodeOk ? QStringLiteral(":/images/icon_check.svg") : QString()); - ui->iconLabelPin->load(isNewCodeOk ? QStringLiteral(":/images/icon_check.svg") : QString()); - ui->iconLabelRepeat->load(isRepeatCodeOk ? QStringLiteral(":/images/icon_check.svg") : QString()); - ui->unblock->setEnabled( isFirstCodeOk && isNewCodeOk && isRepeatCodeOk ); -} - QString PinUnblock::firstCodeText() const { return ui->puk->text(); } QString PinUnblock::newCodeText() const { return ui->pin->text(); } -bool PinUnblock::validatePin(const QString& pin, QSmartCardData::PinType type, WorkMode mode) -{ - const static QString SEQUENCE_ASCENDING = QStringLiteral("1234567890123456789012"); - const static QString SEQUENCE_DESCENDING = QStringLiteral("0987654321098765432109"); - QString pinType = type == QSmartCardData::Pin1Type ? QStringLiteral("PIN1") : (type == QSmartCardData::Pin2Type ? QStringLiteral("PIN2") : QStringLiteral("PUK")); - - auto setError = [&](const QString &msg) { - ui->labelPinValidation->setHidden(msg.isEmpty()); - ui->labelPinValidation->setText(msg); - return false; - }; - if(mode == PinUnblock::PinChange && pin == ui->puk->text()) - return setError(tr("Current %1 code and new %1 code must be different").arg(pinType)); - if(SEQUENCE_ASCENDING.contains(pin)) - return setError(tr("New %1 code can't be increasing sequence").arg(pinType)); - if(SEQUENCE_DESCENDING.contains(pin)) - return setError(tr("New %1 code can't be decreasing sequence").arg(pinType)); - if(pin.count(pin[1]) == pin.length()) - return setError(tr("New %1 code can't be sequence of same numbers").arg(pinType)); - if(personalCode.contains(pin)) - return setError(tr("New %1 code can't be part of your personal code").arg(pinType)); - if(pin == birthDate.toString(QStringLiteral("yyyy")) || pin == birthDate.toString(QStringLiteral("ddMM")) || - pin == birthDate.toString(QStringLiteral("MMdd")) || pin == birthDate.toString(QStringLiteral("yyyyMMdd")) || - pin == birthDate.toString(QStringLiteral("ddMMyyyy"))) - return setError(tr("New %1 code can't be your date of birth").arg(pinType)); - return true; -} diff --git a/client/dialogs/PinUnblock.h b/client/dialogs/PinUnblock.h index 4bbb5f015..3f82eb443 100644 --- a/client/dialogs/PinUnblock.h +++ b/client/dialogs/PinUnblock.h @@ -25,9 +25,7 @@ #include #include -namespace Ui { -class PinUnblock; -} +namespace Ui { class PinUnblock; } class PinUnblock final : public QDialog { @@ -36,29 +34,19 @@ class PinUnblock final : public QDialog public: enum WorkMode { - UnBlockPinWithPuk = 1, - ChangePinWithPuk = 2, - PinChange = 4, - PukChange = 8 + UnBlockPinWithPuk, + ChangePinWithPuk, + PinChange, }; - PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType type, short leftAttempts, - QDate birthDate, QString personalCode); + PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType type, + short leftAttempts, QDate birthDate, const QString &personalCode); ~PinUnblock() final; QString firstCodeText() const; QString newCodeText() const; private: - void initIntro(WorkMode mode, QSmartCardData::PinType type); - void setUnblockEnabled(); - bool validatePin(const QString& pin, QSmartCardData::PinType type, WorkMode mode); + bool validatePin(QSmartCardData::PinType type, WorkMode mode); Ui::PinUnblock *ui; - QDate birthDate; - QString personalCode; - QRegularExpression regexpFirstCode; - QRegularExpression regexpNewCode; - bool isFirstCodeOk = false; - bool isNewCodeOk = false; - bool isRepeatCodeOk = false; }; diff --git a/client/dialogs/PinUnblock.ui b/client/dialogs/PinUnblock.ui index db7094dd5..79e810576 100644 --- a/client/dialogs/PinUnblock.ui +++ b/client/dialogs/PinUnblock.ui @@ -10,26 +10,17 @@ 0 0 460 - 513 + 446 - - - 0 - 0 - - - - - 460 - 474 - - QDialog { border-radius: 2px; background-color: #FFFFFF; } +QLabel { + color: #353739; +} QLineEdit { border: 1px solid #DEE4E9; border-radius: 2px; @@ -63,7 +54,6 @@ QLineEdit { Roboto 20 - 50 false @@ -76,7 +66,7 @@ color: #041E42; line-height: 24px; - TextLabel + %1 code change Qt::AlignCenter @@ -84,602 +74,407 @@ line-height: 24px; - - - color: #353739; + + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 15 - 0 - - - - - 15 - 16777215 - - - - &bull; - - - Qt::RichText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - Roboto - 14 - 50 - false - - - - Qt::TabFocus - - - Qt::RichText - - - true - - - true - - - - - - - - 15 - 0 - - - - - 15 - 16777215 - - - - &bull; - - - Qt::RichText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - Roboto - 14 - 50 - false - - - - Qt::TabFocus - - - Qt::RichText - - - true - - - true - - - - - - - - 15 - 0 - - - - - 15 - 16777215 - - - - &bull; - - - Qt::RichText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - Roboto - 14 - 50 - false - - - - Qt::TabFocus - - - Qt::RichText - - - true - - - true - - - - - - - - 15 - 0 - - - - - 15 - 16777215 - - - - &bull; - - - Qt::RichText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - Roboto - 14 - 50 - false - - - - Qt::TabFocus - - - Qt::RichText - - - true - - - true - - - - - - - - - - Qt::Vertical + + 0 - - QSizePolicy::Fixed + + 0 - - - 20 - 7 - + + 0 - - - - - 2 - - - 61 - - - 61 + 0 - - - - - 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - Roboto Condensed - 12 - - - - Valid puk code - - - color: #353739; - - - VALID PUK CODE - - - puk - - - - - - - - 15 - 15 - - - - - 15 - 15 - - - - - - - - Qt::Horizontal - - - - 1 - 1 - - - - - - - - - + + - + 0 0 - 0 - 34 + 15 + 0 - 16777215 + 15 16777215 - - Qt::LeftToRight - - + &bull; - - QLineEdit::Password + + Qt::RichText - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - 2 - - - 61 - - - 61 - - - - - - 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - Roboto Condensed - 12 - - - - color: #353739; - - - pin - - - pin - - - - - - - - 15 - 15 - - - - - 15 - 15 - - - - - - - - Qt::Horizontal - - - - 1 - 1 - - - - - + + + + + Roboto + 14 + false + + + + Qt::TabFocus + + + Qt::RichText + + + true + + + true + - - - - - 0 - 0 - + + + + + 15 + 0 + + + + + 15 + 16777215 + + + + &bull; + + + Qt::RichText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + Roboto + 14 + false + + + + Qt::TabFocus + + Qt::RichText + + + true + + + true + + + + + - 0 - 32 + 15 + 0 - 16777215 + 15 16777215 - - QLineEdit::Password + + &bull; + + + Qt::RichText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + Roboto + 14 + false + + + + Qt::TabFocus + + + Qt::RichText + + + true + + + true - - - 2 + + + Qt::Vertical - - 61 + + QSizePolicy::Fixed - - 61 + + + 20 + 7 + + + + + + + + 2 - - - - 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - Roboto Condensed - 12 - - - - color: #353739; - - - repeat - - - repeat - - - - - - - - 15 - 15 - - - - - 15 - 15 - - - - - - - - Qt::Horizontal - - - - 1 - 1 - - - - - - + + + 2 + + + 60 + + + 60 + + + + + + 12 + + + + Valid puk code + + + VALID PUK CODE + + + puk + + + + + + + + 0 + 0 + + + + + 0 + 34 + + + + + 16777215 + 16777215 + + + + Qt::LeftToRight + + + + + + QLineEdit::Password + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + - - - - 0 - 34 - + + + + 12 + + + + color: #c53e3e - - QLineEdit::Password + + Qt::AlignCenter - + 2 - - - Qt::TabFocus + + + 2 + + + 60 + + + 60 + + + + + + 12 + + + + NEW %1 CODE + + + pin + + + + + + + + 0 + 0 + + + + + 0 + 32 + + + + + 16777215 + 16777215 + + + + QLineEdit::Password + + + + + + + + + + 12 + - height: 14px; - font-size: 13px; - color: #c53e3e; - font-weight: 400; - - - Katseid jäänud: + color: #c53e3e Qt::AlignCenter + + + + + + 2 + + + + + 2 + + + 60 + + + 60 + + + + + + 12 + + + + NEW %1 CODE AGAIN + + + repeat + + + + + + + + 0 + 34 + + + + QLineEdit::Password + + + + + - - - Qt::TabFocus + + + + 12 + - height: 14px; - font-size: 13px; - color: #c53e3e; - font-weight: 400; + color: #c53e3e Qt::AlignCenter @@ -689,7 +484,7 @@ line-height: 24px; - + 40 @@ -704,12 +499,6 @@ line-height: 24px; - - - 0 - 0 - - 120 @@ -751,16 +540,7 @@ line-height: 24px; - - - false - - - - 0 - 0 - - + 120 @@ -797,7 +577,7 @@ line-height: 24px; } - UNBLOCK + CHANGE true @@ -808,14 +588,6 @@ line-height: 24px; - - - QSvgWidget - QWidget -
QSvgWidget.h
- 1 -
-
diff --git a/client/dialogs/SettingsDialog.cpp b/client/dialogs/SettingsDialog.cpp index 48efd4562..f3bd1ba8f 100644 --- a/client/dialogs/SettingsDialog.cpp +++ b/client/dialogs/SettingsDialog.cpp @@ -60,7 +60,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent) , ui(new Ui::SettingsDialog) { - new Overlay(this, parent->topLevelWidget()); + new Overlay(this, parent); ui->setupUi(this); setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); diff --git a/client/dialogs/SignatureDialog.cpp b/client/dialogs/SignatureDialog.cpp index 3bd8a7801..aaa2ece5b 100644 --- a/client/dialogs/SignatureDialog.cpp +++ b/client/dialogs/SignatureDialog.cpp @@ -46,7 +46,7 @@ SignatureDialog::SignatureDialog(const DigiDocSignature &signature, QWidget *par connect(d->showRole, &AccordionTitle::opened, d->showErrors, &AccordionTitle::openSection); connect(d->showRole, &AccordionTitle::closed, this, [this] { d->showErrors->setSectionOpen(); }); - new Overlay(this, parent->topLevelWidget()); + new Overlay(this, parent); SslCertificate c = signature.cert(); QString style = QStringLiteral(""); diff --git a/client/dialogs/SmartIDDialog.cpp b/client/dialogs/SmartIDDialog.cpp index f8b37689a..7f93714e1 100644 --- a/client/dialogs/SmartIDDialog.cpp +++ b/client/dialogs/SmartIDDialog.cpp @@ -31,21 +31,23 @@ SmartIDDialog::SmartIDDialog(QWidget *parent) : QDialog(parent) , ui(new Ui::SmartIDDialog) { - new Overlay(this, parent->topLevelWidget()); + static QString EE = QStringLiteral("EE"); + new Overlay(this, parent); ui->setupUi(this); setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); setFixedSize(size()); -#if defined (Q_OS_WIN) +#ifdef Q_OS_WIN ui->buttonLayout->setDirection(QBoxLayout::RightToLeft); #endif QFont condensed = Styles::font(Styles::Condensed, 14); - QFont header = Styles::font(Styles::Regular, 16, QFont::DemiBold); QFont regularFont = Styles::font(Styles::Regular, 14); - ui->labelNameId->setFont(header); + ui->labelNameId->setFont(Styles::font(Styles::Regular, 16, QFont::DemiBold)); ui->labelCode->setFont(regularFont); ui->labelCountry->setFont(regularFont); + ui->errorCode->setFont(regularFont); + ui->errorCountry->setFont(regularFont); ui->idCode->setFont(regularFont); ui->idCode->setAttribute(Qt::WA_MacShowFocusRect, false); ui->idCountry->setFont(regularFont); @@ -55,7 +57,7 @@ SmartIDDialog::SmartIDDialog(QWidget *parent) ui->cancel->setFont(condensed); QSettings s; - QValidator *ik = new IKValidator(ui->idCode); + QValidator *ik = new NumberValidator(ui->idCode); ui->idCode->setValidator(ik); ui->idCode->setText(s.value(QStringLiteral("SmartID")).toString()); ui->idCountry->setItemData(0, "EE"); @@ -63,26 +65,31 @@ SmartIDDialog::SmartIDDialog(QWidget *parent) ui->idCountry->setItemData(2, "LV"); ui->idCountry->setCurrentIndex(ui->idCountry->findData(s.value(QStringLiteral("SmartIDCountry"), QStringLiteral("EE")).toString())); ui->cbRemember->setChecked(s.value(QStringLiteral("SmartIDSettings"), true).toBool()); - connect(ui->sign, &QPushButton::clicked, this, &QDialog::accept); - connect(ui->idCode, &QLineEdit::returnPressed, ui->sign, &QPushButton::click); - connect(ui->cancel, &QPushButton::clicked, this, &QDialog::reject); - - auto enableSign = [=] { - const QString EE = QStringLiteral("EE"); - ui->idCode->setValidator(country() == EE ? ik : nullptr); + auto saveSettings = [this]{ bool checked = ui->cbRemember->isChecked(); SettingsDialog::setValueEx(QStringLiteral("SmartIDSettings"), checked, true); SettingsDialog::setValueEx(QStringLiteral("SmartID"), checked ? idCode() : QString()); SettingsDialog::setValueEx(QStringLiteral("SmartIDCountry"), checked ? country() : EE, EE); - ui->sign->setToolTip(QString()); - if(!idCode().isEmpty() && country() == EE && !IKValidator::isValid(idCode())) - ui->sign->setToolTip(tr("Personal code is not valid")); - ui->sign->setEnabled(!idCode().isEmpty() && ui->sign->toolTip().isEmpty()); }; - connect(ui->idCode, &QLineEdit::textEdited, this, enableSign); - connect(ui->idCountry, &QComboBox::currentTextChanged, this, enableSign); - connect(ui->cbRemember, &QCheckBox::clicked, this, enableSign); - enableSign(); + connect(ui->idCode, &QLineEdit::returnPressed, ui->sign, &QPushButton::click); + connect(ui->idCode, &QLineEdit::textEdited, this, saveSettings); + connect(ui->idCountry, &QComboBox::currentTextChanged, this, saveSettings); + connect(ui->cbRemember, &QCheckBox::clicked, this, saveSettings); + connect(ui->cancel, &QPushButton::clicked, this, &QDialog::reject); + connect(ui->sign, &QPushButton::clicked, this, [this,ik] { + ui->idCode->setValidator(country() == EE ? ik : nullptr); + if(ui->idCode->validator() && !IKValidator::isValid(idCode())) + { + ui->idCode->setStyleSheet(QStringLiteral("border-color: #c53e3e")); + ui->errorCode->setText(tr("Personal code is not valid")); + } + else + { + ui->idCode->setStyleSheet({}); + ui->errorCode->clear(); + accept(); + } + }); } SmartIDDialog::~SmartIDDialog() diff --git a/client/dialogs/SmartIDDialog.ui b/client/dialogs/SmartIDDialog.ui index 74b69b630..1bf66337e 100644 --- a/client/dialogs/SmartIDDialog.ui +++ b/client/dialogs/SmartIDDialog.ui @@ -2,15 +2,12 @@ SmartIDDialog - - Qt::WindowModal - 0 0 - 380 - 282 + 382 + 301 @@ -27,6 +24,12 @@ padding: 0px 10px; border: 1px solid #DEE4E9; border-radius: 2px; } +#labelCode, #labelCountry { +color: #353739 +} +#errorCode, #errorCountry { +color: #c53e3e +} QComboBox QWidget#popup { background-color: transparent; } @@ -88,13 +91,13 @@ image: url(:/images/icon_checkbox_check.png); 0 - 50 + 30 30 - 50 + 30 30 @@ -130,8 +133,8 @@ image: url(:/images/icon_checkbox_check.png); - 20 - 67 + 0 + 8 @@ -140,13 +143,9 @@ image: url(:/images/icon_checkbox_check.png); - Roboto Condensed 12 - - color: #353739; - Country @@ -181,16 +180,20 @@ image: url(:/images/icon_checkbox_check.png); - + - Roboto Condensed 12 - - color: #353739; -padding-top: 8px; + + + + + + + 12 + Personal code @@ -214,20 +217,13 @@ padding-top: 8px; - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - + + + + 12 + - + @@ -246,8 +242,8 @@ padding-top: 8px; - 20 - 66 + 0 + 8 @@ -261,7 +257,7 @@ padding-top: 8px; - 120 + 0 30 @@ -300,12 +296,9 @@ QPushButton:hover:!pressed { - - false - - 120 + 0 30 diff --git a/client/effects/Overlay.cpp b/client/effects/Overlay.cpp index 23202ae69..c4c910bb8 100644 --- a/client/effects/Overlay.cpp +++ b/client/effects/Overlay.cpp @@ -21,24 +21,19 @@ #include #include -#include Overlay::Overlay(QWidget *runner, QWidget *parent) - : Overlay(parent) + : QWidget(parent->topLevelWidget()) { connect(runner, &QWidget::destroyed, this, &Overlay::deleteLater); - show(); -} - -Overlay::Overlay(QWidget *parent): QWidget(parent) -{ setPalette(Qt::transparent); setAttribute(Qt::WA_TransparentForMouseEvents); - if(parent) + if(parentWidget()) { - setMinimumSize(parent->size()); - parent->setGraphicsEffect(new QGraphicsBlurEffect); + setMinimumSize(parentWidget()->size()); + parentWidget()->setGraphicsEffect(new QGraphicsBlurEffect); } + show(); } Overlay::~Overlay() diff --git a/client/effects/Overlay.h b/client/effects/Overlay.h index 806b92546..ff63607b9 100644 --- a/client/effects/Overlay.h +++ b/client/effects/Overlay.h @@ -21,16 +21,12 @@ #include -class QPaintEvent; - class Overlay final : public QWidget { Q_OBJECT public: Overlay(QWidget *runner, QWidget *parent); - Overlay(QWidget *parent); - - ~Overlay() override; + ~Overlay() final; protected: void paintEvent(QPaintEvent *event) final; diff --git a/client/translations/en.ts b/client/translations/en.ts index b615d231f..bbf7302b0 100644 --- a/client/translations/en.ts +++ b/client/translations/en.ts @@ -2142,8 +2142,8 @@ and enter Smart-ID PIN2-code. PUK code is written in the envelope, that is given with the ID-card. - If PIN%1 is inserted incorrectly 3 times the %2 certificate will be blocked and it will be impossible to use ID-card to %3, until it is unblocked via the PUK code. - If PIN%1 is inserted incorrectly 3 times the %2 certificate will be blocked and it will be impossible to use ID-card to %3, until it is unblocked via the PUK code. + If %1 is inserted incorrectly 3 times the %2 certificate will be blocked and it will be impossible to use ID-card to %3, until it is unblocked via the PUK code. + If %1 is inserted incorrectly 3 times the %2 certificate will be blocked and it will be impossible to use ID-card to %3, until it is unblocked via the PUK code. signing @@ -2161,10 +2161,18 @@ and enter Smart-ID PIN2-code. verify identification verify identification + + New %1 codes doesn't match + New %1 codes don't match + If you have forgotten PIN%1, but know PUK, then here you can enter new PIN%1. If you have forgotten PIN%1, but know PUK, then here you can enter new PIN%1. + + %1 length has to be between %2 and 12 + %1 length has to be between %2 and 12 + PrintSheet diff --git a/client/translations/et.ts b/client/translations/et.ts index b6d277383..3cdb0e7a4 100644 --- a/client/translations/et.ts +++ b/client/translations/et.ts @@ -2142,8 +2142,8 @@ ja sisesta nutiseadmes Smart-ID PIN2-kood. PUK-koodi leiad ID-kaardi koodiümbrikus, kui sa pole seda vahepeal muutnud. - If PIN%1 is inserted incorrectly 3 times the %2 certificate will be blocked and it will be impossible to use ID-card to %3, until it is unblocked via the PUK code. - Kui sisestad PIN%1-koodi kolm korda valesti, siis %2 sertifikaat blokeeritakse ning ID-kaarti pole võimalik %3 kasutada enne blokeeringu tühistamist PUK-koodi abil. + If %1 is inserted incorrectly 3 times the %2 certificate will be blocked and it will be impossible to use ID-card to %3, until it is unblocked via the PUK code. + Kui sisestad %1-koodi kolm korda valesti, siis %2 sertifikaat blokeeritakse ning ID-kaarti pole võimalik %3 kasutada enne blokeeringu tühistamist PUK-koodi abil. signing @@ -2161,10 +2161,18 @@ ja sisesta nutiseadmes Smart-ID PIN2-kood. verify identification isikutuvastamiseks + + New %1 codes doesn't match + Uued %1-koodid on erinevad + If you have forgotten PIN%1, but know PUK, then here you can enter new PIN%1. Kui oled unustanud PIN%1-koodi, kuid tead PUK-koodi, siis siin saad määrata uue PIN%1-koodi. + + %1 length has to be between %2 and 12 + %1-koodi pikkus peab olema %2-12 numbrit + PrintSheet diff --git a/client/translations/ru.ts b/client/translations/ru.ts index fd81bdf5c..ace9160fe 100644 --- a/client/translations/ru.ts +++ b/client/translations/ru.ts @@ -2145,8 +2145,8 @@ and enter Smart-ID PIN2-code. Ваш PUK-код находится в конверте с кодами. - If PIN%1 is inserted incorrectly 3 times the %2 certificate will be blocked and it will be impossible to use ID-card to %3, until it is unblocked via the PUK code. - Если PIN%1 введён 3 раза неверно, тогда блокируется %2 и использовать ID-карту для %3 невозможно, пока блокировка не снята PUK-кодом. + If %1 is inserted incorrectly 3 times the %2 certificate will be blocked and it will be impossible to use ID-card to %3, until it is unblocked via the PUK code. + Если %1 введён 3 раза неверно, тогда блокируется %2 и использовать ID-карту для %3 невозможно, пока блокировка не снята PUK-кодом. signing @@ -2164,10 +2164,18 @@ and enter Smart-ID PIN2-code. verify identification идентификации личности + + New %1 codes doesn't match + Новые %1-коды не сходятся + If you have forgotten PIN%1, but know PUK, then here you can enter new PIN%1. Если вы забыли PIN%1-код, но знаете PUK-код, тогда здесь вы можете ввести новый PIN%1-код. + + %1 length has to be between %2 and 12 + Длина %1 должна быть %2-12 номера + PrintSheet diff --git a/client/widgets/ContainerPage.cpp b/client/widgets/ContainerPage.cpp index a55217256..1a3f14db5 100644 --- a/client/widgets/ContainerPage.cpp +++ b/client/widgets/ContainerPage.cpp @@ -92,7 +92,7 @@ ContainerPage::~ContainerPage() void ContainerPage::addressSearch() { - AddRecipients dlg(ui->rightPane, topLevelWidget()); + AddRecipients dlg(ui->rightPane, this); if(dlg.exec() && dlg.isUpdated()) emit keysSelected(dlg.keys()); } @@ -179,7 +179,7 @@ void ContainerPage::forward(int code) { case SignatureMobile: { - MobileDialog dlg(topLevelWidget()); + MobileDialog dlg(this); QString newCode = QSettings().value(QStringLiteral("MobileCode")).toString(); if(dlg.exec() == QDialog::Accepted) { @@ -196,7 +196,7 @@ void ContainerPage::forward(int code) } case SignatureSmartID: { - SmartIDDialog dlg(topLevelWidget()); + SmartIDDialog dlg(this); QString newCode = QSettings().value(QStringLiteral("SmartID")).toString(); if(dlg.exec() == QDialog::Accepted) {