2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-05-27 21:28:25 +00:00
|
|
|
import "../../../../imports"
|
2020-06-19 18:06:58 +00:00
|
|
|
import "../../../../shared"
|
2020-07-21 21:03:22 +00:00
|
|
|
import "./Data/locales.js" as Locales_JSON
|
2020-05-27 21:28:25 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: languageContainer
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-07-21 21:03:22 +00:00
|
|
|
id: title
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Language settings"
|
|
|
|
text: qsTrId("language-settings")
|
2020-05-27 21:28:25 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 24
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: 20
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
property string currentLocale: appSettings.locale
|
|
|
|
id: languageSetting
|
|
|
|
anchors.top: title.bottom
|
|
|
|
anchors.topMargin: 20
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
StyledText {
|
2020-08-26 15:52:26 +00:00
|
|
|
//% "Language"
|
|
|
|
text: qsTrId("language")
|
2020-07-21 21:03:22 +00:00
|
|
|
}
|
|
|
|
Select {
|
2020-07-30 05:18:54 +00:00
|
|
|
id: select
|
2020-07-21 21:03:22 +00:00
|
|
|
anchors.right: undefined
|
|
|
|
anchors.left: undefined
|
|
|
|
width: 100
|
|
|
|
Layout.leftMargin: Style.current.padding
|
2020-07-30 05:18:54 +00:00
|
|
|
model: Locales_JSON.locales
|
2020-08-03 05:36:54 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2020-07-30 05:18:54 +00:00
|
|
|
menu.delegate: Component {
|
|
|
|
MenuItem {
|
|
|
|
id: menuItem
|
|
|
|
height: itemText.height + 4
|
|
|
|
width: parent.width
|
|
|
|
padding: 10
|
|
|
|
onTriggered: function () {
|
|
|
|
const locale = Locales_JSON.locales[index]
|
2020-07-21 21:03:22 +00:00
|
|
|
profileModel.changeLocale(locale)
|
2020-09-15 19:47:13 +00:00
|
|
|
appSettings.locale = locale
|
2020-07-21 21:03:22 +00:00
|
|
|
}
|
2020-07-30 05:18:54 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 21:28:25 +00:00
|
|
|
}
|