feat: save locale in qt settings and switch to it on load

This commit is contained in:
Jonathan Rainville 2020-07-16 18:04:47 -04:00 committed by Iuri Matias
parent 489ad7052f
commit 5268484114
2 changed files with 14 additions and 9 deletions

View File

@ -74,7 +74,7 @@ Item {
} }
RowLayout { RowLayout {
property string currentLocale: "en" // TODO get from settings property string currentLocale: appSettings.locale
id: languageSetting id: languageSetting
anchors.top: compactModeSetting.bottom anchors.top: compactModeSetting.bottom
anchors.topMargin: 20 anchors.topMargin: 20
@ -94,7 +94,7 @@ Item {
text: locale, text: locale,
onClicked: function () { onClicked: function () {
profileModel.changeLocale(locale) profileModel.changeLocale(locale)
languageSetting.currentLocale = locale appSettings.locale = locale
} }
} }
}) })

View File

@ -34,6 +34,10 @@ ApplicationWindow {
visible: true visible: true
Component.onCompleted: { Component.onCompleted: {
if (settings.locale !== "en") {
profileModel.changeLocale(settings.locale)
}
setX(Qt.application.screens[0].width / 2 - width / 2); setX(Qt.application.screens[0].width / 2 - width / 2);
setY(Qt.application.screens[0].height / 2 - height / 2); setY(Qt.application.screens[0].height / 2 - height / 2);
} }
@ -57,13 +61,14 @@ ApplicationWindow {
} }
Settings { Settings {
id: settings id: settings
property var chatSplitView property var chatSplitView
property var walletSplitView property var walletSplitView
property var profileSplitView property var profileSplitView
property bool displayChatImages: false property bool displayChatImages: false
property bool compactMode property bool compactMode
} property string locale: "en"
}
SystemTrayIcon { SystemTrayIcon {
visible: true visible: true