Skip to content

Commit 8f73e1b

Browse files
committed
Implement new Language selection menu
WE2-990 Signed-off-by: Raul Metsma <[email protected]>
1 parent eee1522 commit 8f73e1b

File tree

19 files changed

+641
-80
lines changed

19 files changed

+641
-80
lines changed

src/ui/CMakeLists.txt

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
add_library(ui STATIC
22
certificatewidget.cpp
33
certificatewidget.hpp
4+
languageselect.cpp
5+
languageselect.hpp
6+
languageselect.ui
47
punycode.hpp
58
ui.cpp
69
webeiddialog.cpp
710
webeiddialog.hpp
811
web-eid-resources.qrc
912
dialog.ui
1013
)
11-
qt_add_translations(ui TS_FILES
12-
translations/en.ts
13-
translations/et.ts
14-
translations/fi.ts
15-
translations/hr.ts
16-
translations/ru.ts
17-
translations/de.ts
18-
translations/fr.ts
19-
translations/nl.ts
20-
translations/cs.ts
21-
translations/sk.ts
22-
RESOURCE_PREFIX /translations
23-
)
14+
qt_add_resources(ui qss PREFIX / FILES dark.qss languageselect.qss)
15+
file(GLOB TRANSLATIONS translations/*.ts)
16+
qt_add_translations(ui TS_FILES ${TRANSLATIONS} RESOURCE_PREFIX /translations)
2417
set_target_properties(ui PROPERTIES
2518
AUTORCC ON
2619
AUTOUIC ON

src/ui/dark.qss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ background-image: url(:images/down_dark.svg);
4141
#langButton::hover {
4242
background-color: #4E4E53;
4343
}
44-
#langMenu {
45-
border-color: #4E4E53;
46-
background-color: #4E4E53;
47-
}
48-
#langMenu > QPushButton {
49-
color: #FFFFFF;
50-
}
5144
CertificateButton, CertificateWidget {
5245
border-color: #4E4E53;
5346
}

src/ui/dialog.ui

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,6 @@ background-image: url(:images/down.svg);
8383
#langButton::hover {
8484
background-color: #EFEFEF;
8585
}
86-
#langMenu {
87-
border: 3px solid #EFEFEF;
88-
border-radius: 3px;
89-
background-color: #EFEFEF;
90-
}
91-
#langMenu &gt; QPushButton {
92-
color: #003168;
93-
border: 0px;
94-
max-height: 22px;
95-
padding-left: 7px;
96-
padding-right: 6px;
97-
font-size: 14px;
98-
text-align: left;
99-
}
100-
#langMenu &gt; QPushButton:checked {
101-
font-weight: bold;
102-
}
10386
CertificateButton, CertificateWidget {
10487
border: 1px solid rgba(0,49,104,0.1);
10588
border-radius: 4px;

src/ui/languageselect.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2020-2024 Estonian Information System Authority
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
#include "languageselect.hpp"
24+
#include "ui_languageselect.h"
25+
26+
#include "application.hpp"
27+
28+
#include <QFile>
29+
#include <QSettings>
30+
#include <QStyle>
31+
32+
LanguageSelect::LanguageSelect(QWidget* parent) : QDialog(parent)
33+
{
34+
Ui::LanguageSelect ui;
35+
ui.setupUi(this);
36+
if (Application::isDarkTheme()) {
37+
if (QFile f(QStringLiteral(":languageselect.qss")); f.open(QFile::ReadOnly | QFile::Text)) {
38+
style()->unpolish(this);
39+
setStyleSheet(styleSheet() + QTextStream(&f).readAll());
40+
style()->polish(this);
41+
}
42+
}
43+
if(auto *btn = findChild<QToolButton*>(QSettings().value(QStringLiteral("lang")).toString()))
44+
btn->setChecked(true);
45+
connect(ui.select, &QPushButton::clicked, this, &LanguageSelect::accept);
46+
connect(ui.cancel, &QPushButton::clicked, this, &LanguageSelect::reject);
47+
connect(ui.langGroup, qOverload<QAbstractButton*>(&QButtonGroup::buttonClicked), this,
48+
[](QAbstractButton* action) {
49+
QSettings().setValue(QStringLiteral("lang"), action->objectName());
50+
qApp->loadTranslations();
51+
});
52+
}

src/ui/languageselect.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2020-2024 Estonian Information System Authority
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
#pragma once
24+
25+
#include <QDialog>
26+
27+
class LanguageSelect : public QDialog
28+
{
29+
Q_OBJECT
30+
public:
31+
explicit LanguageSelect(QWidget* parent = nullptr);
32+
};

src/ui/languageselect.qss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
#LanguageSelect {
3+
background-color: #232325;
4+
}
5+
#label {
6+
color: white;
7+
}
8+
QPushButton {
9+
color: #FF5C79;
10+
border-color: #FF5C79;
11+
}
12+
QPushButton:hover, QPushButton:pressed {
13+
background-color: #232325;
14+
}
15+
QToolButton {
16+
color: white;
17+
border-color: #92A0B7;
18+
}
19+
QToolButton:checked {
20+
background-color: #415982;
21+
}

0 commit comments

Comments
 (0)