2021-03-24 16:28:59 +00:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
2021-03-25 18:22:04 +00:00
|
|
|
Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2021-03-25 19:01:59 +00:00
|
|
|
ButtonGroup {
|
|
|
|
id: languageGroup
|
|
|
|
}
|
|
|
|
|
2021-07-30 12:52:09 +00:00
|
|
|
Loader {
|
2021-07-28 17:54:40 +00:00
|
|
|
id: languageChangeConfirmationDialog
|
2021-07-30 12:52:09 +00:00
|
|
|
active: Qt.platform.os === Constants.linux
|
|
|
|
sourceComponent: ConfirmationDialog {
|
|
|
|
property string newLocale
|
2021-09-09 09:10:29 +00:00
|
|
|
header.title: qsTr("Change language")
|
2021-07-30 12:52:09 +00:00
|
|
|
confirmationText: qsTr("Display language has been changed. You must restart the application for changes to take effect.")
|
|
|
|
showCancelButton: true
|
|
|
|
confirmButtonLabel: qsTr("Close the app now")
|
|
|
|
cancelButtonLabel: qsTr("I'll do that later")
|
|
|
|
onConfirmButtonClicked: {
|
|
|
|
profileModel.changeLocale(newLocale)
|
|
|
|
Qt.quit();
|
|
|
|
}
|
|
|
|
onCancelButtonClicked: {
|
|
|
|
languageChangeConfirmationDialog.item.close()
|
|
|
|
popup.close()
|
|
|
|
}
|
2021-07-28 17:54:40 +00:00
|
|
|
}
|
2021-07-30 12:52:09 +00:00
|
|
|
|
2021-07-28 17:54:40 +00:00
|
|
|
}
|
2021-07-30 12:52:09 +00:00
|
|
|
|
2021-07-28 17:54:40 +00:00
|
|
|
|
2021-03-25 18:22:04 +00:00
|
|
|
ScrollView {
|
|
|
|
width: parent.width
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: Style.current.bigPadding
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: languagesListView
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.rightMargin: Style.current.padding
|
2021-03-25 19:01:59 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2021-03-25 18:22:04 +00:00
|
|
|
model: Locales_JSON.locales
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
delegate: Component {
|
|
|
|
StatusRadioButtonRow {
|
|
|
|
height: 64
|
2021-03-25 19:01:59 +00:00
|
|
|
anchors.rightMargin: 0
|
2021-03-25 18:22:04 +00:00
|
|
|
text: modelData.name
|
|
|
|
buttonGroup: languageGroup
|
2021-04-15 11:41:14 +00:00
|
|
|
checked: globalSettings.locale === modelData.locale
|
2021-03-25 18:22:04 +00:00
|
|
|
onRadioCheckedChanged: {
|
2021-04-15 11:41:14 +00:00
|
|
|
if (checked && globalSettings.locale !== modelData.locale) {
|
|
|
|
globalSettings.locale = modelData.locale
|
2021-07-30 12:52:09 +00:00
|
|
|
if (Qt.platform.os === Constants.linux) {
|
|
|
|
languageChangeConfirmationDialog.item.newLocale = modelData.locale
|
|
|
|
languageChangeConfirmationDialog.item.open()
|
2021-07-28 17:54:40 +00:00
|
|
|
} else {
|
|
|
|
profileModel.changeLocale(modelData.locale)
|
|
|
|
}
|
2021-03-25 18:22:04 +00:00
|
|
|
}
|
|
|
|
}
|
2021-03-24 16:28:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|