diff --git a/client/dialogs/MobileDialog.cpp b/client/dialogs/MobileDialog.cpp index d218f1d89..2c42fc2c5 100644 --- a/client/dialogs/MobileDialog.cpp +++ b/client/dialogs/MobileDialog.cpp @@ -32,7 +32,7 @@ MobileDialog::MobileDialog(QWidget *parent) : static const QStringList countryCodes {QStringLiteral("372"), QStringLiteral("370")}; new Overlay(this, parent); ui->setupUi(this); - setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); + setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); setFixedSize(size()); #ifdef Q_OS_WIN ui->buttonLayout->setDirection(QBoxLayout::RightToLeft); @@ -58,6 +58,7 @@ MobileDialog::MobileDialog(QWidget *parent) : ui->phoneNo->setValidator(new NumberValidator(ui->phoneNo)); ui->phoneNo->setText(Settings::MOBILEID_NUMBER.value(countryCodes[0])); ui->phoneNo->setAttribute(Qt::WA_MacShowFocusRect, false); + ui->phoneNo->setFocus(); ui->cbRemember->setChecked(Settings::MOBILEID_REMEMBER); ui->cbRemember->setAttribute(Qt::WA_MacShowFocusRect, false); auto saveSettings = [this] { @@ -66,45 +67,33 @@ MobileDialog::MobileDialog(QWidget *parent) : Settings::MOBILEID_CODE = checked ? ui->idCode->text() : QString(); Settings::MOBILEID_NUMBER = checked ? ui->phoneNo->text() : QString(); }; + auto setError = [](QLineEdit *input, QLabel *error, const QString &msg) { + input->setStyleSheet(msg.isEmpty() ? QString() :QStringLiteral("border-color: #c53e3e")); + error->setFocusPolicy(msg.isEmpty() ? Qt::NoFocus : Qt::TabFocus); + error->setText(msg); + }; connect(ui->idCode, &QLineEdit::returnPressed, ui->sign, &QPushButton::click); connect(ui->idCode, &QLineEdit::textEdited, this, saveSettings); - connect(ui->idCode, &QLineEdit::textEdited, ui->errorCode, [this] { - ui->errorCode->clear(); - ui->idCode->setStyleSheet({}); + connect(ui->idCode, &QLineEdit::textEdited, ui->errorCode, [this, setError] { + setError(ui->idCode, ui->errorCode, {}); }); connect(ui->phoneNo, &QLineEdit::returnPressed, ui->sign, &QPushButton::click); connect(ui->phoneNo, &QLineEdit::textEdited, this, saveSettings); - connect(ui->phoneNo, &QLineEdit::textEdited, ui->errorPhone, [this] { - ui->errorPhone->clear(); - ui->phoneNo->setStyleSheet({}); + connect(ui->phoneNo, &QLineEdit::textEdited, ui->errorPhone, [this, setError] { + setError(ui->phoneNo, ui->errorPhone, {}); }); connect(ui->cbRemember, &QCheckBox::clicked, this, saveSettings); - connect(ui->sign, &QPushButton::clicked, this, [this] { + connect(ui->sign, &QPushButton::clicked, this, [this, setError] { if(!IKValidator::isValid(idCode())) - { - ui->idCode->setStyleSheet(QStringLiteral("border-color: #c53e3e")); - ui->errorCode->setText(tr("Personal code is not valid")); - } + setError(ui->idCode, ui->errorCode, tr("Personal code is not valid")); else - { - ui->idCode->setStyleSheet({}); - ui->errorCode->clear(); - } + setError(ui->idCode, ui->errorCode, {}); if(phoneNo().size() < 8 || countryCodes.contains(phoneNo())) - { - ui->phoneNo->setStyleSheet(QStringLiteral("border-color: #c53e3e")); - ui->errorPhone->setText(tr("Phone number is not entered")); - } + setError(ui->phoneNo, ui->errorPhone, 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")); - } + setError(ui->phoneNo, ui->errorPhone, tr("Invalid country code")); else - { - ui->phoneNo->setStyleSheet({}); - ui->errorPhone->clear(); - } + setError(ui->phoneNo, ui->errorPhone, {}); if(ui->errorCode->text().isEmpty() && ui->errorPhone->text().isEmpty()) accept(); }); diff --git a/client/dialogs/MobileDialog.ui b/client/dialogs/MobileDialog.ui index ec938a779..16f252047 100644 --- a/client/dialogs/MobileDialog.ui +++ b/client/dialogs/MobileDialog.ui @@ -2,6 +2,9 @@ MobileDialog + + Qt::WindowModal + 0 @@ -162,9 +165,6 @@ background-color: #BEDBED; 12 - - Qt::TabFocus - @@ -203,9 +203,6 @@ background-color: #BEDBED; 12 - - Qt::TabFocus - diff --git a/client/dialogs/PinPopup.cpp b/client/dialogs/PinPopup.cpp index 644e174ec..656532f2a 100644 --- a/client/dialogs/PinPopup.cpp +++ b/client/dialogs/PinPopup.cpp @@ -46,7 +46,7 @@ PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidg , ui(new Ui::PinPopup) { ui->setupUi(this); - setWindowFlag(Qt::FramelessWindowHint); + setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); for(QLineEdit *w: findChildren()) w->setAttribute(Qt::WA_MacShowFocusRect, false); diff --git a/client/dialogs/PinPopup.ui b/client/dialogs/PinPopup.ui index cba325cfa..784c2fcd7 100644 --- a/client/dialogs/PinPopup.ui +++ b/client/dialogs/PinPopup.ui @@ -2,6 +2,9 @@ PinPopup + + Qt::WindowModal + 0 @@ -214,7 +217,7 @@ QPushButton:disabled { } - OK + OK true diff --git a/client/dialogs/PinUnblock.cpp b/client/dialogs/PinUnblock.cpp index 877714b12..6ca01cba0 100644 --- a/client/dialogs/PinUnblock.cpp +++ b/client/dialogs/PinUnblock.cpp @@ -34,8 +34,11 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t #if defined (Q_OS_WIN) ui->buttonLayout->setDirection(QBoxLayout::RightToLeft); #endif - setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); - for(QLineEdit *w: findChildren()) + setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); + auto list = findChildren(); + if(!list.isEmpty()) + list.first()->setFocus(); + for(QLineEdit *w: list) w->setAttribute(Qt::WA_MacShowFocusRect, false); new Overlay(this, parent); @@ -98,10 +101,10 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t ? 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")) + 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), + type == QSmartCardData::Pin2Type ? tr("signing") : tr("identification"), + type == QSmartCardData::Pin2Type ? tr("digital signing") : tr("verify identification")) ); } setWindowTitle(ui->labelNameId->text()); @@ -125,28 +128,29 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t for(int i = 1; i < 4; i++) { bool isHidden = true; - if(QLabel *text = findChild(QStringLiteral("line%1_text").arg(i))) + if(auto *text = findChild(QStringLiteral("line%1_text").arg(i))) text->setHidden(isHidden = text->text().isEmpty()); - if(QLabel *bullet = findChild(QStringLiteral("line%1_bullet").arg(i))) + 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: #c53e3e")); + error->setFocusPolicy(msg.isEmpty() ? Qt::NoFocus : Qt::TabFocus); + error->setText(msg); + }; 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->pin, &QLineEdit::textEdited, ui->errorPin, [this] { - ui->errorPin->clear(); - ui->pin->setStyleSheet({}); + connect(ui->pin, &QLineEdit::textEdited, ui->errorPin, [this, setError] { + setError(ui->pin, ui->errorPin, {}); }); connect(ui->repeat, &QLineEdit::returnPressed, ui->change, &QPushButton::click); - connect(ui->repeat, &QLineEdit::textEdited, ui->errorRepeat, [this] { - ui->errorRepeat->clear(); - ui->repeat->setStyleSheet({}); + connect(ui->repeat, &QLineEdit::textEdited, ui->errorRepeat, [this, setError] { + setError(ui->repeat, ui->errorRepeat, {}); }); connect(ui->puk, &QLineEdit::returnPressed, ui->change, &QPushButton::click); - connect(ui->puk, &QLineEdit::textEdited, ui->errorPuk, [this] { - ui->errorPuk->clear(); - ui->puk->setStyleSheet({}); + connect(ui->puk, &QLineEdit::textEdited, ui->errorPuk, [this, setError] { + setError(ui->puk, ui->errorPuk, {}); }); connect(ui->change, &QPushButton::clicked, this, [=] { const static QString SEQUENCE_ASCENDING = QStringLiteral("1234567890123456789012"); @@ -157,10 +161,7 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t 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)); diff --git a/client/dialogs/PinUnblock.ui b/client/dialogs/PinUnblock.ui index 0440567fc..8deb034a6 100644 --- a/client/dialogs/PinUnblock.ui +++ b/client/dialogs/PinUnblock.ui @@ -335,9 +335,6 @@ line-height: 24px; 12 - - Qt::TabFocus - color: #c53e3e @@ -413,9 +410,6 @@ line-height: 24px; 12 - - Qt::TabFocus - color: #c53e3e @@ -479,9 +473,6 @@ line-height: 24px; 12 - - Qt::TabFocus - color: #c53e3e diff --git a/client/dialogs/RoleAddressDialog.cpp b/client/dialogs/RoleAddressDialog.cpp index 22ef7afc1..f8c5a469b 100644 --- a/client/dialogs/RoleAddressDialog.cpp +++ b/client/dialogs/RoleAddressDialog.cpp @@ -26,7 +26,6 @@ #include #include -#include class RoleAddressDialog::Private: public Ui::RoleAddressDialog {}; @@ -47,23 +46,22 @@ RoleAddressDialog::RoleAddressDialog(QWidget *parent) connect( d->cancel, &QPushButton::clicked, this, &RoleAddressDialog::reject ); d->cancel->setFont(condensed); - d->cancel->setText(tr("CANCEL")); - d->cancel->setCursor(QCursor(Qt::PointingHandCursor)); connect( d->sign, &QPushButton::clicked, this, &RoleAddressDialog::accept ); d->sign->setFont(condensed); - d->sign->setText(tr("SIGN")); - d->sign->setCursor(QCursor(Qt::PointingHandCursor)); - for(QLabel *label: findChildren()) + for(auto *label: findChildren()) label->setFont(regularFont); d->title->setFont(Styles::font(Styles::Regular, 16, QFont::DemiBold)); - for(QLineEdit *line: findChildren()) + auto list = findChildren(); + if(!list.isEmpty()) + list.first()->setFocus(); + for(QLineEdit *line: list) { Settings::Option s{line->objectName()}; - QCompleter *completer = new QCompleter(s, line); + auto *completer = new QCompleter(s, line); completer->setMaxVisibleItems(10); completer->setCompletionMode(QCompleter::PopupCompletion); completer->setCaseSensitivity(Qt::CaseInsensitive); @@ -79,7 +77,7 @@ RoleAddressDialog::RoleAddressDialog(QWidget *parent) s.clear(); // Uses on Windows MULTI_STRING registry s = list; }); - completer->popup()->setStyleSheet("background-color:#FFFFFF; color: #000000;"); + completer->popup()->setStyleSheet(QStringLiteral("background-color:#FFFFFF; color: #000000;")); } } diff --git a/client/dialogs/RoleAddressDialog.ui b/client/dialogs/RoleAddressDialog.ui index cbb240dba..1f5bdf47c 100644 --- a/client/dialogs/RoleAddressDialog.ui +++ b/client/dialogs/RoleAddressDialog.ui @@ -308,6 +308,12 @@ QLabel { 34 + + PointingHandCursor + + + Cancel + QPushButton { border-radius: 2px; @@ -326,7 +332,7 @@ QPushButton:disabled { } - Cancel + CANCEL @@ -344,9 +350,15 @@ QPushButton:disabled { 34 - + + PointingHandCursor + + Sign + + SIGN + true diff --git a/client/dialogs/SmartIDDialog.cpp b/client/dialogs/SmartIDDialog.cpp index 4f22b950d..e6da8d5b2 100644 --- a/client/dialogs/SmartIDDialog.cpp +++ b/client/dialogs/SmartIDDialog.cpp @@ -33,7 +33,7 @@ SmartIDDialog::SmartIDDialog(QWidget *parent) new Overlay(this, parent); ui->setupUi(this); - setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); + setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); setFixedSize(size()); #ifdef Q_OS_WIN ui->buttonLayout->setDirection(QBoxLayout::RightToLeft); @@ -48,13 +48,14 @@ SmartIDDialog::SmartIDDialog(QWidget *parent) ui->errorCountry->setFont(regularFont); ui->idCode->setFont(regularFont); ui->idCode->setAttribute(Qt::WA_MacShowFocusRect, false); + ui->idCode->setFocus(); ui->idCountry->setFont(regularFont); ui->cbRemember->setFont(regularFont); ui->cbRemember->setAttribute(Qt::WA_MacShowFocusRect, false); ui->sign->setFont(condensed); ui->cancel->setFont(condensed); - QValidator *ik = new NumberValidator(ui->idCode); + auto *ik = new NumberValidator(ui->idCode); ui->idCode->setValidator(ik); ui->idCode->setText(Settings::SMARTID_CODE); for(int i = 0, count = Settings::SMARTID_COUNTRY_LIST.size(); i < count; ++i) @@ -67,26 +68,26 @@ SmartIDDialog::SmartIDDialog(QWidget *parent) Settings::SMARTID_CODE = checked ? idCode() : QString(); Settings::SMARTID_COUNTRY = checked ? country() : EE; }; + auto setError = [](QLineEdit *input, QLabel *error, const QString &msg) { + input->setStyleSheet(msg.isEmpty() ? QString() :QStringLiteral("border-color: #c53e3e")); + error->setFocusPolicy(msg.isEmpty() ? Qt::NoFocus : Qt::TabFocus); + error->setText(msg); + }; connect(ui->idCode, &QLineEdit::returnPressed, ui->sign, &QPushButton::click); connect(ui->idCode, &QLineEdit::textEdited, this, saveSettings); - connect(ui->idCode, &QLineEdit::textEdited, ui->errorCode, [this] { - ui->errorCode->clear(); - ui->idCode->setStyleSheet({}); + connect(ui->idCode, &QLineEdit::textEdited, ui->errorCode, [this, setError] { + setError(ui->idCode, ui->errorCode, {}); }); 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] { + connect(ui->sign, &QPushButton::clicked, this, [this, ik, setError] { 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")); - } + setError(ui->idCode, ui->errorCode, tr("Personal code is not valid")); else { - ui->idCode->setStyleSheet({}); - ui->errorCode->clear(); + setError(ui->idCode, ui->errorCode, {}); accept(); } }); diff --git a/client/dialogs/SmartIDDialog.ui b/client/dialogs/SmartIDDialog.ui index 11ee14ab4..2d8ed51c0 100644 --- a/client/dialogs/SmartIDDialog.ui +++ b/client/dialogs/SmartIDDialog.ui @@ -2,6 +2,9 @@ SmartIDDialog + + Qt::WindowModal + 0 @@ -223,9 +226,6 @@ image: url(:/images/icon_checkbox_check.png); 12 - - Qt::TabFocus - diff --git a/client/translations/en.ts b/client/translations/en.ts index a9aca2190..ebf6c59f4 100644 --- a/client/translations/en.ts +++ b/client/translations/en.ts @@ -1914,10 +1914,6 @@ and enter Smart-ID PIN2-code. CANCEL CANCEL - - OK - OK - PIN will be locked next failed attempt PIN will be locked next failed attempt diff --git a/client/translations/et.ts b/client/translations/et.ts index be5a795b3..4a2e06932 100644 --- a/client/translations/et.ts +++ b/client/translations/et.ts @@ -1914,10 +1914,6 @@ ja sisesta nutiseadmes Smart-ID PIN2-kood. CANCEL KATKESTA - - OK - OK - PIN will be locked next failed attempt Vale koodi sisestamisel PIN lukustub diff --git a/client/translations/ru.ts b/client/translations/ru.ts index 776b2a94f..908a522a6 100644 --- a/client/translations/ru.ts +++ b/client/translations/ru.ts @@ -1915,10 +1915,6 @@ and enter Smart-ID PIN2-code. CANCEL ОТМЕНА - - OK - OK - PIN will be locked next failed attempt PIN будет заблокирован при следующей неудачной попытке