2024-04-29 12:02:19 +00:00
import QtQuick 2.15
import QtQuick . Controls 2.15
import QtQuick . Layouts 1.15
2021-10-06 09:16:39 +00:00
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
2024-04-29 12:02:19 +00:00
import StatusQ 0.1
2021-10-06 09:16:39 +00:00
import StatusQ . Core 0.1
import StatusQ . Core . Theme 0.1
2022-07-22 11:57:48 +00:00
import StatusQ . Core . Utils 0.1 as StatusQUtils
2021-10-06 09:16:39 +00:00
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
2022-10-25 13:57:04 +00:00
import AppLayouts . Profile . stores 1.0
2021-10-06 09:16:39 +00:00
import "../popups"
2022-07-22 11:57:48 +00:00
import SortFilterProxyModel 0.2
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
2024-04-29 12:02:19 +00:00
property bool languageSelectionEnabled
2022-04-01 10:30:55 +00:00
2022-08-11 13:27:13 +00:00
objectName: "languageView"
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 ( )
}
2022-04-01 10:30:55 +00:00
2022-04-01 10:30:55 +00:00
function setViewIdleState ( ) {
currencyPicker . close ( )
languagePicker . close ( )
}
2022-08-11 13:27:13 +00:00
function changeLanguage ( key ) {
languagePicker . newKey = key
2023-04-27 11:30:15 +00:00
Qt . callLater ( root . languageStore . changeLanguage , languagePicker . newKey )
2022-08-11 13:27:13 +00:00
}
2022-05-07 11:45:15 +00:00
ColumnLayout {
spacing: Constants . settingsSection . itemSpacing
width: root . contentWidth
2021-10-06 09:16:39 +00:00
2023-01-12 22:39:46 +00:00
RowLayout {
2022-05-07 11:45:15 +00:00
Layout.fillWidth: true
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" )
}
2023-01-12 22:39:46 +00:00
Item { Layout.fillWidth: true }
2022-05-07 11:45:15 +00:00
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
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
2023-01-12 22:39:46 +00:00
RowLayout {
2022-05-07 11:45:15 +00:00
Layout.fillWidth: true
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" )
}
2023-01-12 22:39:46 +00:00
Item { Layout.fillWidth: true }
2022-05-07 11:45:15 +00:00
StatusListPicker {
id: languagePicker
2024-04-29 12:02:19 +00:00
button.interactive: root . languageSelectionEnabled
StatusToolTip {
y: parent . height + Style . current . padding
margins: 0
visible: ! root . languageSelectionEnabled && languagePicker . button . hovered
orientation: StatusToolTip . Orientation . Bottom
text: qsTr ( "Translations coming soon" )
}
2022-05-07 11:45:15 +00:00
property string newKey
2022-04-01 10:30:55 +00:00
2022-07-28 17:52:19 +00:00
function descriptionForState ( state ) {
2022-09-05 09:39:59 +00:00
if ( state === Constants . translationsState . alpha ) return qsTr ( "Alpha languages" )
if ( state === Constants . translationsState . beta ) return qsTr ( "Beta languages" )
2022-07-28 17:52:19 +00:00
return ""
}
2022-08-11 13:27:13 +00:00
objectName: "languagePicker"
2022-07-28 17:52:19 +00:00
inputList: SortFilterProxyModel {
sourceModel: root . languageStore . languageModel
// "category" is the only role that can't be mocked by StatusListPicker::proxy
// due to StatusListPicker internal implementation limitation (ListView's section.property)
proxyRoles: [
2024-04-29 12:02:19 +00:00
FastExpressionRole {
2022-07-28 17:52:19 +00:00
name: "category"
expression: languagePicker . descriptionForState ( model . state )
2024-04-29 12:02:19 +00:00
expectedRoles: [ "state" ]
2022-07-28 17:52:19 +00:00
}
]
sorters: [
RoleSorter {
roleName: "state"
sortOrder: Qt . DescendingOrder
} ,
StringSorter {
roleName: "name"
}
]
}
2022-07-28 16:52:29 +00:00
proxy {
key: ( model ) = > model . locale
name: ( model ) = > model . name
2024-04-29 12:02:19 +00:00
shortName: ( model ) = > model . native || model . shortName
2022-07-28 16:52:29 +00:00
symbol: ( model ) = > ""
imageSource: ( model ) = > StatusQUtils . Emoji . iconSource ( model . flag )
selected: ( model ) = > model . locale === root . languageStore . currentLanguage
setSelected: ( model , val ) = > null // readonly
2022-07-22 11:57:48 +00:00
}
2022-04-01 10:30:55 +00:00
z: root . z + 1
2022-05-07 11:45:15 +00:00
placeholderSearchText: qsTr ( "Search Languages" )
2022-04-01 10:30:55 +00:00
maxPickerHeight: 350
2022-05-07 11:45:15 +00:00
onItemPickerChanged: {
2022-07-26 18:46:07 +00:00
if ( selected && root . languageStore . currentLanguage !== key ) {
2023-04-27 11:30:15 +00:00
root . changeLanguage ( key )
2024-04-29 12:02:19 +00:00
Global . openPopup ( languageConfirmationDialog )
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
2024-04-29 12:02:19 +00:00
StatusWarningBox {
Layout.fillWidth: true
Layout.bottomMargin: Style . current . padding
borderColor: Theme . palette . baseColor2
textColor: Theme . palette . directColor1
icon: "group-chat"
iconColor: Theme . palette . baseColor1
text: qsTr ( "We need your help to translate Status, so that together we can bring privacy and free speech to the people everywhere, including those who need it most." )
extraContentComponent: StatusFlatButton {
icon.name: "external-link"
text: qsTr ( "Learn more" )
size: StatusBaseButton . Size . Small
onClicked: Global . openLinkWithConfirmation ( Constants . externalStatusLinkWithHttps + '/translations' , Constants . externalStatusLinkWithHttps )
}
}
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
}
// Time format options:
Column {
Layout.fillWidth: true
2024-04-29 12:02:19 +00:00
spacing: Constants . settingsSection . itemSpacing
2022-04-01 10:30:55 +00:00
StatusBaseText {
text: qsTr ( "Time Format" )
}
2023-01-12 22:39:46 +00:00
StatusCheckBox {
id: use24hDefault
text: qsTr ( "Use System Settings" )
2022-04-01 10:30:55 +00:00
font.pixelSize: 13
2023-01-12 22:39:46 +00:00
checked: LocaleUtils . settings . timeFormatUsesDefaults
onToggled: {
LocaleUtils . settings . timeFormatUsesDefaults = checked
if ( checked )
LocaleUtils . settings . timeFormatUses24Hours = LocaleUtils . is24hTimeFormatDefault ( )
}
2022-04-01 10:30:55 +00:00
}
2023-01-12 22:39:46 +00:00
StatusCheckBox {
text: qsTr ( "Use 24-Hour Time" )
2022-04-01 10:30:55 +00:00
font.pixelSize: 13
2023-01-12 22:39:46 +00:00
enabled: ! use24hDefault . checked
checked: LocaleUtils . settings . timeFormatUses24Hours
onToggled: LocaleUtils . settings . timeFormatUses24Hours = checked
2022-04-01 10:30:55 +00:00
}
}
2022-04-01 10:30:55 +00:00
2024-04-29 12:02:19 +00:00
Component {
2023-04-27 11:30:15 +00:00
id: languageConfirmationDialog
2024-04-29 12:02:19 +00:00
ConfirmationDialog {
destroyOnClose: true
2023-05-23 12:46:16 +00:00
headerSettings.title: qsTr ( "Change language" )
2022-05-07 11:45:15 +00:00
confirmationText: qsTr ( "Display language has been changed. You must restart the application for changes to take effect." )
2024-02-22 15:16:47 +00:00
confirmButtonLabel: qsTr ( "Restart" )
2022-05-07 11:45:15 +00:00
onConfirmButtonClicked: {
2024-02-22 15:16:47 +00:00
Utils . restartApplication ( )
2022-05-07 11:45:15 +00:00
}
}
}
2021-10-06 09:16:39 +00:00
}
}