updated language modal

This commit is contained in:
Iuri Matias 2021-03-24 12:28:59 -04:00
parent 147d93815f
commit 5e0da7c1ec
4 changed files with 82 additions and 69 deletions

View File

@ -1,17 +1,17 @@
var locales = [
"en",
"ar",
"de",
"es",
"fil",
"fr",
"id",
"it",
"ko",
"pt_BR",
"ru",
"tr",
"ur",
"zh",
"zh_TW",
{locale: "en", name: "English"},
{locale: "ar", name: "Arabic"},
{locale: "de", name: "Dutch"},
{locale: "es", name: "Spanish"},
{locale: "fil", name: "Filipino"},
{locale: "fr", name: "French"},
{locale: "id", name: "Indonesian"},
{locale: "it", name: "Italian"},
{locale: "ko", name: "Korean"},
{locale: "pt_BR", name: "Portuguese (Brazil)"},
{locale: "ru", name: "Russian"},
{locale: "tr", name: "Turkish"},
{locale: "ur", name: "Urdu"},
{locale: "zh", name: "Chinese (Mainland China)"},
{locale: "zh_TW", name: "Chinese (Taiwan)"}
];

View File

@ -3,6 +3,7 @@ import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import "../../../../imports"
import "../../../../shared"
import "../../../../shared/status"
import "./Data/locales.js" as Locales_JSON
Item {
@ -10,65 +11,25 @@ Item {
Layout.fillHeight: true
Layout.fillWidth: true
property Component languagePopup: LanguageModal {}
Item {
anchors.top: parent.top
anchors.topMargin: topMargin
anchors.bottom: parent.bottom
width: contentMaxWidth
anchors.horizontalCenter: parent.horizontalCenter
RowLayout {
property string currentLocale: appSettings.locale
id: languageSetting
anchors.top: parent.top
anchors.topMargin: 24
anchors.left: parent.left
anchors.leftMargin: 24
StyledText {
Column {
id: generalColumn
width: parent.width
StatusSettingsLineButton {
//% "Language"
text: qsTrId("language")
}
Select {
id: select
anchors.right: undefined
anchors.left: undefined
width: 100
Layout.leftMargin: Style.current.padding
model: Locales_JSON.locales
selectedItemView: Item {
anchors.fill: parent
StyledText {
id: selectedTextField
text: languageSetting.currentLocale
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 15
verticalAlignment: Text.AlignVCenter
height: 22
}
}
menu.delegate: Component {
MenuItem {
id: menuItem
height: itemText.height + 4
width: parent.width
padding: 10
onTriggered: function () {
const locale = Locales_JSON.locales[index]
profileModel.changeLocale(locale)
appSettings.locale = locale
}
StyledText {
id: itemText
text: Locales_JSON.locales[index]
anchors.left: parent.left
anchors.leftMargin: 5
anchors.verticalCenter: parent.verticalCenter
}
background: Rectangle {
color: menuItem.highlighted ? Style.current.backgroundHover : Style.current.transparent
}
}
}
//% "Default"
currentValue: appSettings.locale === "" ? qsTrId("default") : appSettings.locale
onClicked: languagePopup.createObject(languageContainer).open()
}
}
}

View File

@ -0,0 +1,51 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import "../../../../imports"
import "../../../../shared"
import "../../../../shared/status"
import "./Data/locales.js" as Locales_JSON
ModalPopup {
id: popup
//% "Language"
title: qsTrId("Language")
onClosed: {
destroy()
}
Column {
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
anchors.leftMargin: Style.current.padding
height: 50
spacing: Style.current.padding
ButtonGroup {
id: languageGroup
}
Repeater {
model: Locales_JSON.locales
height: 50
StatusRadioButtonRow {
text: modelData.name
buttonGroup: languageGroup
checked: appSettings.locale === modelData.locale
onRadioCheckedChanged: {
if (checked) {
profileModel.changeLocale(modelData.locale)
appSettings.locale = modelData.locale
}
}
}
}
}
}

View File

@ -10,3 +10,4 @@ HelpContainer 1.0 HelpContainer.qml
AboutContainer 1.0 AboutContainer.qml
SignoutContainer 1.0 SignoutContainer.qml
BackupSeedModal 1.0 BackupSeedModal.qml
LanguageModal 1.0 LanguageModal.qml