From dbe2d953700712c8f2974056b8cfef90604427a9 Mon Sep 17 00:00:00 2001 From: Mitternacht822 Date: Tue, 27 May 2025 15:54:44 +0400 Subject: [PATCH] added language selection and russian translation --- client/core/controllers/coreController.cpp | 6 +- client/resources.qrc | 1 + client/ui/controllers/pageController.h | 1 + .../ui/qml/DefaultVpn/Pages/PageSettings.qml | 58 ++++++++++- .../DefaultVpn/Pages/PageSettingsLanguage.qml | 97 +++++++++++++++++++ 5 files changed, 156 insertions(+), 7 deletions(-) create mode 100644 client/ui/qml/DefaultVpn/Pages/PageSettingsLanguage.qml diff --git a/client/core/controllers/coreController.cpp b/client/core/controllers/coreController.cpp index f47555bf..0f74dcf9 100644 --- a/client/core/controllers/coreController.cpp +++ b/client/core/controllers/coreController.cpp @@ -26,9 +26,9 @@ CoreController::CoreController(const QSharedPointer &vpnConnectio initNotificationHandler(); - // auto locale = m_settings->getAppLanguage(); - // m_translator.reset(new QTranslator()); - // updateTranslator(locale); + auto locale = m_settings->getAppLanguage(); + m_translator.reset(new QTranslator()); + updateTranslator(locale); } void CoreController::initModels() diff --git a/client/resources.qrc b/client/resources.qrc index 258be90c..fea1657c 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -267,6 +267,7 @@ ui/qml/DefaultVpn/Controls/BusyIndicatorType.qml images/controls/connect-button.svg fonts/VelaSans-GX.ttf + ui/qml/DefaultVpn/Pages/PageSettingsLanguage.qml images/flagKit/ZW.svg diff --git a/client/ui/controllers/pageController.h b/client/ui/controllers/pageController.h index 2aad835e..4a0afa6d 100644 --- a/client/ui/controllers/pageController.h +++ b/client/ui/controllers/pageController.h @@ -30,6 +30,7 @@ namespace PageLoader PageSettingsBackup, PageSettingsAbout, PageSettingsLogging, + PageSettingsLanguage, PageSettingsSplitTunneling, PageSettingsAppSplitTunneling, PageSettingsKillSwitch, diff --git a/client/ui/qml/DefaultVpn/Pages/PageSettings.qml b/client/ui/qml/DefaultVpn/Pages/PageSettings.qml index 54073f62..18a6a7e5 100644 --- a/client/ui/qml/DefaultVpn/Pages/PageSettings.qml +++ b/client/ui/qml/DefaultVpn/Pages/PageSettings.qml @@ -48,6 +48,56 @@ Page { Layout.rightMargin: 8 spacing: 2 + RadioButton { + id: languageRadioButton + Layout.fillWidth: true + background: Rectangle { + anchors.fill: parent + radius: 8 + color: languageRadioButton.hovered ? Style.color.gray1 : Style.color.transparent + } + + indicator: Item { } + + contentItem: RowLayout { + id: content + + anchors.left: parent.left + anchors.right: parent.right + implicitHeight: content.implicitHeight + + Header3TextType { + Layout.fillWidth: true + Layout.leftMargin: 8 + Layout.topMargin: 19 + Layout.bottomMargin: 19 + + text: qsTr("Language") + color: languageRadioButton.hovered ? Style.color.gray9 : Style.color.black + } + + Image { + Layout.rightMargin: 8 + source: "qrc:/images/controls/chevron-right.svg" + + layer { + enabled: true + effect: ColorOverlay { + color: Style.color.black + } + } + } + } + + onClicked: PageController.goToPage(PageEnum.PageSettingsLanguage) + + MouseArea { + anchors.fill: languageRadioButton + cursorShape: Qt.PointingHandCursor + enabled: false + } + } + RadioButton { id: loggingRadioButton Layout.fillWidth: true @@ -60,11 +110,11 @@ Page { indicator: Item { } contentItem: RowLayout { - id: content + id: content2 anchors.left: parent.left anchors.right: parent.right - implicitHeight: content.implicitHeight + implicitHeight: content2.implicitHeight Header3TextType { Layout.fillWidth: true @@ -110,7 +160,7 @@ Page { indicator: Item { } contentItem: RowLayout { - id: content2 + id: content3 anchors.left: parent.left anchors.right: parent.right @@ -153,4 +203,4 @@ Page { Layout.fillHeight: true } } -} \ No newline at end of file +} diff --git a/client/ui/qml/DefaultVpn/Pages/PageSettingsLanguage.qml b/client/ui/qml/DefaultVpn/Pages/PageSettingsLanguage.qml new file mode 100644 index 00000000..bc3b20a9 --- /dev/null +++ b/client/ui/qml/DefaultVpn/Pages/PageSettingsLanguage.qml @@ -0,0 +1,97 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +import PageEnum 1.0 +import Config 1.0 + +import "../Components" +import "../Controls" +import "../Controls/TextTypes" + +Page { + id: root + + ColumnLayout { + anchors.fill: parent + + RowLayout { + Layout.leftMargin: 8 + Layout.rightMargin: 8 + Layout.topMargin: 8 + + WhiteButtonNoBorder { + id: backButton + imageSource: "qrc:/images/controls/arrow-left.svg" + onClicked: PageController.closePage() + } + } + + Header1TextType { + Layout.topMargin: 8 + Layout.leftMargin: 16 + Layout.rightMargin: 16 + Layout.fillWidth: true + text: qsTr("Select Language") + horizontalAlignment: Qt.AlignLeft + verticalAlignment: Qt.AlignVCenter + } + + ButtonGroup { + id: languageButtonGroup + } + + ListView { + id: languageListView + + Layout.topMargin: 16 + Layout.fillHeight: true + Layout.fillWidth: true + + model: LanguageModel + currentIndex: LanguageModel.currentLanguageIndex + spacing: 8 + + ScrollBar.vertical: ScrollBar {} + + delegate: Item { + id: languageItem + required property string languageName + required property int languageIndex + required property int index + + width: languageListView.width + height: 60 + + Rectangle { + anchors.fill: parent + color: radioButton.checked ? Style.color.gray1 : Style.color.transparent + radius: 8 + + RowLayout { + anchors.fill: parent + anchors.margins: 8 + + RadioButton { + id: radioButton + ButtonGroup.group: languageButtonGroup + checked: languageIndex === LanguageModel.currentLanguageIndex + + text: languageName + font.pixelSize: 18 + Layout.fillWidth: true + Layout.alignment: Qt.AlignVCenter + + onClicked: { + if (languageIndex !== LanguageModel.currentLanguageIndex) { + LanguageModel.changeLanguage(languageIndex); + PageController.closePage(); + } + } + } + } + } + } + } + } +}