status-desktop/ui/app/AppLayouts/Profile/Sections/LanguageContainer.qml

76 lines
2.6 KiB
QML
Raw Normal View History

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"
import "../../../../shared"
import "./Data/locales.js" as Locales_JSON
2020-05-27 21:28:25 +00:00
Item {
id: languageContainer
Layout.fillHeight: true
Layout.fillWidth: true
Item {
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 {
//% "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
}
}
}
}
}
}
2020-05-27 21:28:25 +00:00
}