feat: introduce global settings
This commit introces global settings that apply across accounts used inside the application. This is useful when settings like the selected locale should b the same across all accounts. Closes #2144
This commit is contained in:
parent
9e6bd7a2da
commit
aeedc87368
|
@ -86,6 +86,16 @@ QtObject:
|
|||
read = getProfileSettingsFile
|
||||
notify = profileSettingsFileChanged
|
||||
|
||||
proc getGlobalSettingsFile(self: ProfileView): string {.slot.} =
|
||||
return os.joinPath(accountConstants.DATADIR, "qt", "global")
|
||||
|
||||
proc globalSettingsFileChanged*(self: ProfileView) {.signal.}
|
||||
|
||||
QtProperty[string] globalSettingsFile:
|
||||
read = getGlobalSettingsFile
|
||||
notify = globalSettingsFileChanged
|
||||
|
||||
|
||||
proc initialized*(self: ProfileView) {.signal.}
|
||||
|
||||
proc getProfile(self: ProfileView): QVariant {.slot.} =
|
||||
|
|
|
@ -8,12 +8,12 @@ StyledText {
|
|||
id: chatTime
|
||||
visible: isMessage
|
||||
color: isImage ? Style.current.white : Style.current.secondaryText
|
||||
text: formatDateTime ? Utils.formatDateTime(timestamp, appSettings.locale) : Utils.formatTime(timestamp, appSettings.locale)
|
||||
text: formatDateTime ? Utils.formatDateTime(timestamp, globalSettings.locale) : Utils.formatTime(timestamp, globalSettings.locale)
|
||||
font.pixelSize: Style.current.asideTextFontSize
|
||||
|
||||
StatusToolTip {
|
||||
visible: hhandler.hovered
|
||||
text: new Date(parseInt(timestamp, 10)).toLocaleString(Qt.locale(appSettings.locale))
|
||||
text: new Date(parseInt(timestamp, 10)).toLocaleString(Qt.locale(globalSettings.locale))
|
||||
maxWidth: 350
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ Item {
|
|||
StyledText {
|
||||
id: contactTime
|
||||
visible: !isCompact
|
||||
text: Utils.formatDateTime(wrapper.timestamp, appSettings.locale)
|
||||
text: Utils.formatDateTime(wrapper.timestamp, globalSettings.locale)
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Style.current.padding
|
||||
anchors.top: parent.top
|
||||
|
|
|
@ -30,7 +30,7 @@ Item {
|
|||
//% "Language"
|
||||
text: qsTrId("language")
|
||||
//% "Default"
|
||||
currentValue: appSettings.locale === "" ? qsTrId("default") : appSettings.locale
|
||||
currentValue: globalSettings.locale === "" ? qsTrId("default") : globalSettings.locale
|
||||
onClicked: languagePopup.createObject(languageContainer).open()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,11 +46,11 @@ ModalPopup {
|
|||
anchors.rightMargin: 0
|
||||
text: modelData.name
|
||||
buttonGroup: languageGroup
|
||||
checked: appSettings.locale === modelData.locale
|
||||
checked: globalSettings.locale === modelData.locale
|
||||
onRadioCheckedChanged: {
|
||||
if (checked && appSettings.locale !== modelData.locale) {
|
||||
if (checked && globalSettings.locale !== modelData.locale) {
|
||||
profileModel.changeLocale(modelData.locale)
|
||||
appSettings.locale = modelData.locale
|
||||
globalSettings.locale = modelData.locale
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ Item {
|
|||
StyledText {
|
||||
id: assetFiatValue
|
||||
color: Style.current.secondaryText
|
||||
text: Utils.toLocaleString(fiatBalance, appSettings.locale) + " " + walletModel.defaultCurrency.toUpperCase()
|
||||
text: Utils.toLocaleString(fiatBalance, globalSettings.locale) + " " + walletModel.defaultCurrency.toUpperCase()
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 0
|
||||
anchors.bottom: parent.bottom
|
||||
|
|
|
@ -43,7 +43,7 @@ Rectangle {
|
|||
StyledTextEdit {
|
||||
id: walletAmountValue
|
||||
color: Style.current.textColor
|
||||
text: Utils.toLocaleString(walletModel.totalFiatBalance, appSettings.locale) + " " + walletModel.defaultCurrency.toUpperCase()
|
||||
text: Utils.toLocaleString(walletModel.totalFiatBalance, globalSettings.locale) + " " + walletModel.defaultCurrency.toUpperCase()
|
||||
selectByMouse: true
|
||||
cursorVisible: true
|
||||
readOnly: true
|
||||
|
@ -141,7 +141,7 @@ Rectangle {
|
|||
}
|
||||
StyledText {
|
||||
id: walletBalance
|
||||
text: isLoading ? "..." : Utils.toLocaleString(fiatBalance, appSettings.locale) + " " + walletModel.defaultCurrency.toUpperCase()
|
||||
text: isLoading ? "..." : Utils.toLocaleString(fiatBalance, globalSettings.locale) + " " + walletModel.defaultCurrency.toUpperCase()
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: Style.current.smallPadding
|
||||
anchors.right: parent.right
|
||||
|
|
|
@ -115,7 +115,6 @@ RowLayout {
|
|||
property bool displayChatImages: false
|
||||
property bool useCompactMode: true
|
||||
property bool timelineEnabled: true
|
||||
property string locale: "en"
|
||||
property var recentEmojis: []
|
||||
property var hiddenCommunityWelcomeBanners: []
|
||||
property real volume: 0.2
|
||||
|
@ -151,6 +150,13 @@ RowLayout {
|
|||
property bool compatibilityMode: true
|
||||
}
|
||||
|
||||
Settings {
|
||||
id: globalSettings
|
||||
category: "global"
|
||||
fileName: profileModel.globalSettingsFile
|
||||
property string locale: "en"
|
||||
}
|
||||
|
||||
ErrorSound {
|
||||
id: errorSound
|
||||
}
|
||||
|
@ -175,7 +181,8 @@ RowLayout {
|
|||
Connections {
|
||||
target: profileModel
|
||||
onProfileSettingsFileChanged: {
|
||||
profileModel.changeLocale(appSettings.locale)
|
||||
profileModel.changeLocale(globalSettings.locale)
|
||||
|
||||
|
||||
// Since https://github.com/status-im/status-desktop/commit/93668ff75
|
||||
// we're hiding the setting to change appearance for compact normal mode
|
||||
|
|
Loading…
Reference in New Issue