diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 7df12a6e..52a0d6cb 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -1,6 +1,9 @@ add_library(ui STATIC certificatewidget.cpp certificatewidget.hpp + languageselect.cpp + languageselect.hpp + languageselect.ui punycode.hpp ui.cpp webeiddialog.cpp @@ -12,6 +15,7 @@ file(GLOB FONTS fonts/*.ttf) qt_add_resources(ui resources BASE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX / FILES ../../install/appicon_128.png dark.qss + languageselect.qss ${IMAGES} ${FONTS} ) diff --git a/src/ui/dark.qss b/src/ui/dark.qss index eb12ec47..c40ee360 100644 --- a/src/ui/dark.qss +++ b/src/ui/dark.qss @@ -41,13 +41,6 @@ background-image: url(:images/down_dark.svg); #langButton::hover { background-color: #4E4E53; } -#langMenu { -border-color: #4E4E53; -background-color: #4E4E53; -} -#langMenu > QPushButton { -color: #FFFFFF; -} CertificateButton, CertificateWidget { border-color: #4E4E53; } diff --git a/src/ui/dialog.ui b/src/ui/dialog.ui index 19bfd744..f202d3b6 100644 --- a/src/ui/dialog.ui +++ b/src/ui/dialog.ui @@ -83,23 +83,6 @@ background-image: url(:images/down.svg); #langButton::hover { background-color: #EFEFEF; } -#langMenu { -border: 3px solid #EFEFEF; -border-radius: 3px; -background-color: #EFEFEF; -} -#langMenu > QPushButton { -color: #003168; -border: 0px; -max-height: 22px; -padding-left: 7px; -padding-right: 6px; -font-size: 14px; -text-align: left; -} -#langMenu > QPushButton:checked { -font-weight: bold; -} CertificateButton, CertificateWidget { border: 1px solid rgba(0,49,104,0.1); border-radius: 4px; diff --git a/src/ui/languageselect.cpp b/src/ui/languageselect.cpp new file mode 100644 index 00000000..f2349be9 --- /dev/null +++ b/src/ui/languageselect.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2020-2024 Estonian Information System Authority + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "languageselect.hpp" +#include "ui_languageselect.h" + +#include "application.hpp" + +#include +#include +#include + +LanguageSelect::LanguageSelect(QWidget* parent) : QDialog(parent) +{ + Ui::LanguageSelect ui; + ui.setupUi(this); + if (Application::isDarkTheme()) { + if (QFile f(QStringLiteral(":languageselect.qss")); f.open(QFile::ReadOnly | QFile::Text)) { + style()->unpolish(this); + setStyleSheet(styleSheet() + QTextStream(&f).readAll()); + style()->polish(this); + } + } + if (auto* btn = findChild(QSettings().value(QStringLiteral("lang")).toString())) + btn->setChecked(true); + connect(ui.select, &QPushButton::clicked, this, [this, langGroup = ui.langGroup] { + if (auto* btn = langGroup->checkedButton()) { + QSettings().setValue(QStringLiteral("lang"), btn->objectName()); + qApp->loadTranslations(); + } + accept(); + }); + connect(ui.cancel, &QPushButton::clicked, this, &LanguageSelect::reject); +} diff --git a/src/ui/languageselect.hpp b/src/ui/languageselect.hpp new file mode 100644 index 00000000..b5a4db4d --- /dev/null +++ b/src/ui/languageselect.hpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020-2024 Estonian Information System Authority + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include + +class LanguageSelect : public QDialog +{ + Q_OBJECT +public: + explicit LanguageSelect(QWidget* parent = nullptr); +}; diff --git a/src/ui/languageselect.qss b/src/ui/languageselect.qss new file mode 100644 index 00000000..844970bf --- /dev/null +++ b/src/ui/languageselect.qss @@ -0,0 +1,21 @@ + +#LanguageSelect { +background-color: #232325; +} +#label { +color: white; +} +QPushButton { +color: #FF5C79; +border-color: #FF5C79; +} +QPushButton:hover, QPushButton:pressed { +background-color: #232325; +} +QToolButton { +color: white; +border-color: #92A0B7; +} +QToolButton:checked { +background-color: #415982; +} diff --git a/src/ui/languageselect.ui b/src/ui/languageselect.ui new file mode 100644 index 00000000..a657ed75 --- /dev/null +++ b/src/ui/languageselect.ui @@ -0,0 +1,372 @@ + + + LanguageSelect + + + + 0 + 0 + 540 + 438 + + + + Select language + + + #LanguageSelect { +background-color: white; +} +#label { +font-family: Roboto, Helvetica; +font-size: 20px; +font-weight: 700; +color: #003168; +} +QAbstractButton { +font-family: Roboto, Helvetica; +font-size: 14px; +font-weight: 700; +} +QToolButton { +color: #07142A; +border: 1px solid #AEB9CA; +border-radius: 5px; +padding: 16px; +} +QToolButton:checked { +border-color: #003168; +background-color: #EAF1F8 +} +QPushButton { +color: #AD2A45; +border: 1px solid #AD2A45; +border-radius: 4px; +padding: 11px 12px; +} +QPushButton:hover { +background-color: #F5EBED; +} +QPushButton:pressed { +background-color: #E1C1C6; +} +QPushButton::default { +color: white; +border-color: #2F70B6; +background-color: #2F70B6; +} +QPushButton::default:hover { +border-color: #2B66A6; +background-color: #2B66A6; +} +QPushButton::default:pressed { +border-color: #215081; +background-color: #215081; +} + + + + QLayout::SetFixedSize + + + 40 + + + 32 + + + 40 + + + 32 + + + 0 + + + 40 + + + + + Select language + + + Qt::AlignCenter + + + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Eesti keel + + + true + + + true + + + langGroup + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + English + + + true + + + langGroup + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Русский + + + true + + + langGroup + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Suomi + + + true + + + langGroup + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Hrvatska + + + true + + + langGroup + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Deutsch + + + true + + + langGroup + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Française + + + true + + + langGroup + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Nederlands + + + true + + + langGroup + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Čeština + + + true + + + langGroup + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Slovenština + + + true + + + langGroup + + + + + + + + + PointingHandCursor + + + Cancel + + + false + + + + + + + Qt::Horizontal + + + + 317 + 20 + + + + + + + + PointingHandCursor + + + Select + + + true + + + + + + + + + + + diff --git a/src/ui/translations/cs.ts b/src/ui/translations/cs.ts index 1039c78f..53d33e44 100644 --- a/src/ui/translations/cs.ts +++ b/src/ui/translations/cs.ts @@ -27,6 +27,21 @@ PIN zablokován + + LanguageSelect + + Cancel + Zrušit + + + Select language + Vyberte jazyk + + + Select + Vybrat + + WebEidDialog @@ -274,5 +289,14 @@ Active language CS + + PIN entry disabled + Zadávání PINu je zakázáno. + + + English + Active language accessible + Čeština + diff --git a/src/ui/translations/de.ts b/src/ui/translations/de.ts index 1475cb5b..3aed6033 100644 --- a/src/ui/translations/de.ts +++ b/src/ui/translations/de.ts @@ -27,6 +27,21 @@ PIN gesperrt + + LanguageSelect + + Cancel + Abbrechen + + + Select language + Sprache auswählen + + + Select + Auswählen + + WebEidDialog @@ -272,5 +287,14 @@ Active language DE + + PIN entry disabled + PIN-Eingabe deaktiviert. + + + English + Active language accessible + Deutsch + diff --git a/src/ui/translations/en.ts b/src/ui/translations/en.ts index 38ec43ac..42ea059e 100644 --- a/src/ui/translations/en.ts +++ b/src/ui/translations/en.ts @@ -27,6 +27,21 @@ Pin locked + + LanguageSelect + + Cancel + Cancel + + + Select language + Select language + + + Select + Select + + WebEidDialog @@ -272,5 +287,14 @@ Active language EN + + PIN entry disabled + PIN entry disabled + + + English + Active language accessible + English + diff --git a/src/ui/translations/et.ts b/src/ui/translations/et.ts index 97d7d4df..cabef2e3 100644 --- a/src/ui/translations/et.ts +++ b/src/ui/translations/et.ts @@ -27,6 +27,21 @@ PIN-kood on lukus + + LanguageSelect + + Cancel + Katkesta + + + Select language + Vali keel + + + Select + Vali + + WebEidDialog @@ -272,5 +287,14 @@ Active language ET + + PIN entry disabled + PIN'i sisestamine on keelatud. + + + English + Active language accessible + Eesti + diff --git a/src/ui/translations/fi.ts b/src/ui/translations/fi.ts index 120ca47e..6cd37a02 100644 --- a/src/ui/translations/fi.ts +++ b/src/ui/translations/fi.ts @@ -27,6 +27,21 @@ Pin lukittu + + LanguageSelect + + Cancel + Peruuta + + + Select language + Valitse kieli + + + Select + Valitse + + WebEidDialog @@ -177,7 +192,7 @@ https://www.id.ee/en/article/how-to-check-that-your-id-card-reader-is-working/ - https://www.id.ee/en/article/how-to-check-that-your-id-card-reader-is-working/ + https://www.id.ee/en/article/how-to-check-that-your-id-card-reader-is-working/ By signing, I agree to the transfer of my name and personal identification code to the service provider. @@ -257,20 +272,29 @@ The inserted ID-card does not contain a certificate for the requested operation. Please insert an ID-card that supports the requested operation. - Asennettu henkilökortti ei sisällä varmennetta pyydettyä toimintoa varten. Aseta sisään henkilökortti, joka tukee pyydettyä toimintoa. + Asennettu henkilökortti ei sisällä varmennetta pyydettyä toimintoa varten. Aseta sisään henkilökortti, joka tukee pyydettyä toimintoa. Please enter PIN for authentication in the PIN dialog window that opens. - Syötä PIN todennusta varten avautuvaan PIN-valintaikkunaan. + Syötä PIN todennusta varten avautuvaan PIN-valintaikkunaan. Please enter PIN for signing in the PIN dialog window that opens. - Syötä PIN kirjautumista varten avautuvaan PIN-valintaikkunaan. + Syötä PIN allekirjoittamista varten avautuvaan PIN-valintaikkunaan. EN Active language FI + + PIN entry disabled + PIN-koodin syöttö ei ole käytössä. + + + English + Active language accessible + Suomi + diff --git a/src/ui/translations/fr.ts b/src/ui/translations/fr.ts index 72220236..07abfae2 100644 --- a/src/ui/translations/fr.ts +++ b/src/ui/translations/fr.ts @@ -27,6 +27,21 @@ Pin bloquée + + LanguageSelect + + Cancel + Annuler + + + Select language + Sélectionner la langue + + + Select + Sélectionner + + WebEidDialog @@ -272,5 +287,14 @@ Active language FR + + PIN entry disabled + Saisie du code PIN désactivée. + + + English + Active language accessible + Française + diff --git a/src/ui/translations/hr.ts b/src/ui/translations/hr.ts index 8bf5c112..0b63b3a4 100644 --- a/src/ui/translations/hr.ts +++ b/src/ui/translations/hr.ts @@ -27,6 +27,21 @@ <b>%1</b><br />Izdavatelj: %2<br />Vrijedi: %3 do %4%5 + + LanguageSelect + + Cancel + Prekid + + + Select language + Odabir jezika + + + Select + Odabir + + WebEidDialog @@ -99,7 +114,7 @@ https://www.id.ee/en/article/how-to-check-that-your-id-card-reader-is-working/ - https://www.id.ee/en/article/how-to-check-that-your-id-card-reader-is-working/ + https://www.id.ee/en/article/how-to-check-that-your-id-card-reader-is-working/ Time remaining: <b>%1</b> @@ -259,20 +274,29 @@ The inserted ID-card does not contain a certificate for the requested operation. Please insert an ID-card that supports the requested operation. - Umetnuta iskaznica ne sadrži potvrdu za traženu operaciju. Molimo umetnite osobnu iskaznicu koja podržava traženu operaciju. + Umetnuta iskaznica ne sadrži potvrdu za traženu operaciju. Molimo umetnite osobnu iskaznicu koja podržava traženu operaciju. Please enter PIN for authentication in the PIN dialog window that opens. - Unesite PIN za autentifikaciju u dijaloški prozor PIN-a koji se otvara. + Unesite PIN za autentifikaciju u dijaloški prozor PIN-a koji se otvara. Please enter PIN for signing in the PIN dialog window that opens. - Unesite PIN za prijavu u dijaloški prozor PIN-a koji se otvara. + Unesite PIN za potpisivanje u dijaloški prozor PIN-a koji se otvara. EN Active language HR + + PIN entry disabled + Unos PIN-a onemogućen. + + + English + Active language accessible + Hrvatska + diff --git a/src/ui/translations/nl.ts b/src/ui/translations/nl.ts index 643a5cf4..0a7b311e 100644 --- a/src/ui/translations/nl.ts +++ b/src/ui/translations/nl.ts @@ -27,6 +27,21 @@ PIN geblokkeerd + + LanguageSelect + + Cancel + Annuleer + + + Select language + Selecteer taal + + + Select + Selecteer + + WebEidDialog @@ -272,5 +287,14 @@ Active language NL + + PIN entry disabled + PIN-invoer uitgeschakeld. + + + English + Active language accessible + Nederlands + diff --git a/src/ui/translations/ru.ts b/src/ui/translations/ru.ts index d0041855..562a8a4a 100644 --- a/src/ui/translations/ru.ts +++ b/src/ui/translations/ru.ts @@ -27,6 +27,21 @@ PIN-код заблокирован + + LanguageSelect + + Cancel + Прервать + + + Select language + Выберите язык + + + Select + Выбрать + + WebEidDialog @@ -274,5 +289,14 @@ Active language RU + + PIN entry disabled + Ввод PIN запрещён. + + + English + Active language accessible + Русский + diff --git a/src/ui/translations/sk.ts b/src/ui/translations/sk.ts index 5fa57401..69e7789a 100644 --- a/src/ui/translations/sk.ts +++ b/src/ui/translations/sk.ts @@ -27,6 +27,21 @@ PIN zablokovaný + + LanguageSelect + + Cancel + Zrušiť + + + Select language + Vyberte jazyk + + + Select + Vybrať + + WebEidDialog @@ -274,5 +289,14 @@ Active language SK + + PIN entry disabled + Zadávanie PIN je zakázané. + + + English + Active language accessible + Slovenština + diff --git a/src/ui/webeiddialog.cpp b/src/ui/webeiddialog.cpp index dd30e2d0..0f94f66d 100644 --- a/src/ui/webeiddialog.cpp +++ b/src/ui/webeiddialog.cpp @@ -22,6 +22,7 @@ #include "webeiddialog.hpp" #include "application.hpp" +#include "languageselect.hpp" #include "punycode.hpp" #include "ui_dialog.h" @@ -43,8 +44,6 @@ #include #endif -#include - #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) constexpr inline QLatin1String operator"" _L1(const char* str, size_t size) noexcept { @@ -91,62 +90,9 @@ WebEidDialog::WebEidDialog(QWidget* parent) : WebEidUI(parent), ui(new Private) ui->langButton = new QToolButton(this); ui->langButton->setObjectName("langButton"); - static const std::vector> LANG_LIST { - {QStringLiteral("et"), QStringLiteral("Eesti")}, - {QStringLiteral("en"), QStringLiteral("English")}, - {QStringLiteral("ru"), QStringLiteral("Русский")}, - {QStringLiteral("fi"), QStringLiteral("Suomi")}, - {QStringLiteral("hr"), QStringLiteral("Hrvatska")}, - {QStringLiteral("de"), QStringLiteral("Deutsch")}, - {QStringLiteral("fr"), QStringLiteral("Française")}, - {QStringLiteral("nl"), QStringLiteral("Nederlands")}, - {QStringLiteral("cs"), QStringLiteral("Čeština")}, - {QStringLiteral("sk"), QStringLiteral("Slovenština")}}; ui->langButton->setText(tr("EN", "Active language")); - if (auto i = std::find_if(LANG_LIST.cbegin(), LANG_LIST.cend(), - [lang = ui->langButton->text().toLower()](const auto& elem) { - return elem.first == lang; - }); - i != LANG_LIST.cend()) { - ui->langButton->setAccessibleName(i->second); - } - connect(ui->langButton, &QToolButton::clicked, this, [this] { - if (auto* menu = findChild(QStringLiteral("langMenu"))) { - menu->deleteLater(); - return; - } - auto* menu = new QWidget(this); - menu->setObjectName("langMenu"); - auto* layout = new QGridLayout(menu); - layout->setContentsMargins(1, 1, 1, 1); - layout->setSpacing(1); - layout->setSizeConstraint(QLayout::SetFixedSize); - auto* langGroup = new QButtonGroup(menu); - langGroup->setExclusive(true); - int i {}; - for (const auto& [lang, title] : LANG_LIST) { - auto* action = new QPushButton(menu); - action->setText(title); - action->setProperty("lang", lang); - action->setAutoDefault(false); - layout->addWidget(action, i / 2, i % 2); - langGroup->addButton(action); - action->setCheckable(true); - action->setChecked(lang == ui->langButton->text().toLower()); - action->setMinimumSize(action->sizeHint() + QSize(1, 0)); - ++i; - } - menu->show(); - menu->move(ui->langButton->geometry().bottomRight() - menu->geometry().topRight() - + QPoint(0, 2)); - connect(langGroup, qOverload(&QButtonGroup::buttonClicked), menu, - [this, menu](QAbstractButton* action) { - QSettings().setValue(QStringLiteral("lang"), action->property("lang")); - ui->langButton->setText(action->property("lang").toString().toUpper()); - qApp->loadTranslations(); - menu->deleteLater(); - }); - }); + ui->langButton->setAccessibleName(tr("English", "Active language accessible")); + connect(ui->langButton, &QToolButton::clicked, this, [] { LanguageSelect().exec(); }); ui->pinInput->setAttribute(Qt::WA_MacShowFocusRect, false); auto pinInputFont = ui->pinInput->font(); @@ -509,14 +455,11 @@ bool WebEidDialog::event(QEvent* event) switch (event->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); + ui->langButton->setText(tr("EN", "Active language")); + ui->langButton->setAccessibleName(tr("English", "Active language accessible")); emit languageChange(); resizeHeight(); break; - case QEvent::MouseButtonRelease: - if (auto* w = findChild(QStringLiteral("langMenu"))) { - w->deleteLater(); - } - break; case QEvent::Resize: ui->langButton->move(width() - ui->langButton->width() - 20, 5); break;