2021-10-06 09:16:39 +00:00
import QtQuick 2.13
import QtQuick . Controls 2.13
import QtQuick . Layouts 1.13
import utils 1.0
2022-04-01 10:30:55 +00:00
import shared . panels 1.0
import shared . popups 1.0
2021-10-06 09:16:39 +00:00
import StatusQ . Core 0.1
import StatusQ . Core . Theme 0.1
import StatusQ . Components 0.1
2022-04-01 10:30:55 +00:00
import StatusQ . Controls 0.1
2021-10-06 09:16:39 +00:00
import "../popups"
2021-12-30 12:39:47 +00:00
import "../stores"
2021-10-06 09:16:39 +00:00
2022-05-07 11:45:15 +00:00
SettingsContentBase {
2022-04-01 10:30:55 +00:00
id: root
2021-10-06 09:16:39 +00:00
2021-12-30 12:39:47 +00:00
property LanguageStore languageStore
2022-04-01 10:30:55 +00:00
property var currencyStore
2022-04-01 10:30:55 +00:00
2022-04-01 10:30:55 +00:00
onVisibleChanged: { if ( ! visible ) root . setViewIdleState ( ) }
onBaseAreaClicked: { root . setViewIdleState ( ) }
2022-04-01 10:30:55 +00:00
2022-04-01 10:30:55 +00:00
Component.onCompleted: {
root . currencyStore . updateCurrenciesModel ( )
root . languageStore . initializeLanguageModel ( )
}
2022-04-01 10:30:55 +00:00
2022-04-01 10:30:55 +00:00
function setViewIdleState ( ) {
currencyPicker . close ( )
languagePicker . close ( )
}
2022-05-07 11:45:15 +00:00
ColumnLayout {
spacing: Constants . settingsSection . itemSpacing
width: root . contentWidth
2021-10-06 09:16:39 +00:00
2022-05-07 11:45:15 +00:00
Item {
id: currency
Layout.fillWidth: true
Layout.leftMargin: Style . current . padding
Layout.rightMargin: Style . current . padding
height: 38
2022-04-01 10:30:55 +00:00
z: root . z + 2
2021-10-06 09:16:39 +00:00
2022-05-07 11:45:15 +00:00
StatusBaseText {
text: qsTr ( "Set Display Currency" )
anchors.left: parent . left
font.pixelSize: 15
color: Theme . palette . directColor1
}
StatusListPicker {
id: currencyPicker
2022-04-01 10:30:55 +00:00
2022-05-07 11:45:15 +00:00
property string newKey
Timer {
id: currencyPause
interval: 100
onTriggered: {
// updateCurrency function operation blocks a little bit the UI so getting around it with a small pause (timer) in order to get the desired visual behavior
root . currencyStore . updateCurrency ( currencyPicker . newKey )
2022-04-01 10:30:55 +00:00
}
2022-05-07 11:45:15 +00:00
}
2022-04-01 10:30:55 +00:00
2022-04-01 10:30:55 +00:00
z: root . z + 2
2022-05-07 11:45:15 +00:00
width: 104
height: parent . height
anchors.right: parent . right
inputList: root . currencyStore . currenciesModel
printSymbol: true
placeholderSearchText: qsTr ( "Search Currencies" )
2022-04-01 10:30:55 +00:00
maxPickerHeight: 350
2022-05-07 11:45:15 +00:00
onItemPickerChanged: {
if ( selected ) {
currencyPicker . newKey = key
currencyPause . start ( )
2021-10-06 09:16:39 +00:00
}
2022-04-01 10:30:55 +00:00
}
2022-04-01 10:30:55 +00:00
}
2022-05-07 11:45:15 +00:00
}
2022-04-01 10:30:55 +00:00
2022-05-07 11:45:15 +00:00
Item {
id: language
Layout.fillWidth: true
Layout.leftMargin: Style . current . padding
Layout.rightMargin: Style . current . padding
height: 38
2022-04-01 10:30:55 +00:00
z: root . z + 1
2022-04-01 10:30:55 +00:00
2022-05-07 11:45:15 +00:00
StatusBaseText {
text: qsTr ( "Language" )
anchors.left: parent . left
font.pixelSize: 15
color: Theme . palette . directColor1
}
StatusListPicker {
id: languagePicker
2022-04-01 10:30:55 +00:00
2022-05-07 11:45:15 +00:00
property string newKey
2022-04-01 10:30:55 +00:00
2022-05-07 11:45:15 +00:00
Timer {
id: languagePause
interval: 100
onTriggered: {
// changeLocale function operation blocks a little bit the UI so getting around it with a small pause (timer) in order to get the desired visual behavior
root . languageStore . changeLocale ( languagePicker . newKey )
2022-04-01 10:30:55 +00:00
}
2022-05-07 11:45:15 +00:00
}
2022-04-01 10:30:55 +00:00
2022-04-01 10:30:55 +00:00
z: root . z + 1
2022-05-07 11:45:15 +00:00
width: 104
height: parent . height
anchors.right: parent . right
inputList: root . languageStore . languageModel
placeholderSearchText: qsTr ( "Search Languages" )
2022-04-01 10:30:55 +00:00
maxPickerHeight: 350
2022-05-07 11:45:15 +00:00
onItemPickerChanged: {
if ( selected && localAppSettings . locale !== key ) {
// TEMPORARY: It should be removed as it is only used in Linux OS but it must be investigated how to change language in execution time, as well, in Linux (will be addressed in another task)
if ( Qt . platform . os === Constants . linux ) {
linuxConfirmationDialog . active = true
linuxConfirmationDialog . item . newLocale = key
linuxConfirmationDialog . item . open ( )
}
else {
languagePicker . newKey = key
languagePause . start ( )
2022-04-01 10:30:55 +00:00
}
}
}
2021-10-06 09:16:39 +00:00
}
2022-05-07 11:45:15 +00:00
}
2022-04-01 10:30:55 +00:00
2022-05-07 11:45:15 +00:00
Separator {
Layout.fillWidth: true
2022-04-01 10:30:55 +00:00
Layout.bottomMargin: Style . current . padding
}
// Date format options:
Column {
Layout.fillWidth: true
Layout.leftMargin: Style . current . padding
Layout.rightMargin: Style . current . padding
spacing: Style . current . padding
StatusBaseText {
text: qsTr ( "Date Format" )
anchors.left: parent . left
font.pixelSize: 15
color: Theme . palette . directColor1
}
StatusRadioButton {
id: ddmmyyFormat
ButtonGroup.group: dateFormatGroup
text: qsTr ( "DD/MM/YY" )
font.pixelSize: 13
checked: root . languageStore . isDDMMYYDateFormat
onCheckedChanged: root . languageStore . setIsDDMMYYDateFormat ( checked )
}
StatusRadioButton {
id: mmddyyFormat
ButtonGroup.group: dateFormatGroup
text: qsTr ( "MM/DD/YY" )
font.pixelSize: 13
checked: ! root . languageStore . isDDMMYYDateFormat
}
ButtonGroup { id: dateFormatGroup }
2022-04-01 10:30:55 +00:00
}
2022-04-01 10:30:55 +00:00
// Time format options:
Column {
Layout.fillWidth: true
Layout.leftMargin: Style . current . padding
Layout.rightMargin: Style . current . padding
Layout.topMargin: Style . current . padding
spacing: Style . current . padding
StatusBaseText {
text: qsTr ( "Time Format" )
anchors.left: parent . left
font.pixelSize: 15
color: Theme . palette . directColor1
}
StatusRadioButton {
id: h24Format
ButtonGroup.group: timeFormatGroup
text: qsTr ( "24-Hour Time" )
font.pixelSize: 13
checked: root . languageStore . is24hTimeFormat
onCheckedChanged: root . languageStore . setIs24hTimeFormat ( checked )
}
StatusRadioButton {
id: h12Format
ButtonGroup.group: timeFormatGroup
text: qsTr ( "12-Hour Time" )
font.pixelSize: 13
checked: ! root . languageStore . is24hTimeFormat
}
ButtonGroup { id: timeFormatGroup }
}
2022-04-01 10:30:55 +00:00
2022-05-07 11:45:15 +00:00
// TEMPORARY: It should be removed as it is only used in Linux OS but it must be investigated how to change language in execution time, as well, in Linux (will be addressed in another task)
Loader {
id: linuxConfirmationDialog
active: false
sourceComponent: ConfirmationDialog {
property string newLocale
header.title: qsTr ( "Change language" )
confirmationText: qsTr ( "Display language has been changed. You must restart the application for changes to take effect." )
confirmButtonLabel: qsTr ( "Close the app now" )
onConfirmButtonClicked: {
root . languageStore . changeLocale ( newLocale )
loader . active = false
Qt . quit ( )
}
}
}
2021-10-06 09:16:39 +00:00
}
}
2022-04-01 10:30:55 +00:00