feat: allow users to restore notification settings

Fixes #1280
This commit is contained in:
Pascal Precht 2020-11-19 16:07:52 +01:00
parent af1f03dc7c
commit ede6afff26
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 60 additions and 19 deletions

View File

@ -65,9 +65,11 @@ ScrollView {
Layout.alignment: Qt.AlignRight
ButtonGroup.group: notificationSetting
rightPadding: 0
checked: appSettings.notificationSetting === 0
checked: appSettings.notificationSetting === Constants.notifyAllMessages
onCheckedChanged: {
appSettings.notificationSetting = 0
if (checked) {
appSettings.notificationSetting = Constants.notifyAllMessages
}
}
}
}
@ -83,9 +85,11 @@ ScrollView {
Layout.alignment: Qt.AlignRight
ButtonGroup.group: notificationSetting
rightPadding: 0
checked: appSettings.notificationSetting === 1
checked: appSettings.notificationSetting === Constants.notifyJustMentions
onCheckedChanged: {
appSettings.notificationSetting = 1
if (checked) {
appSettings.notificationSetting = Constants.notifyJustMentions
}
}
}
}
@ -101,9 +105,11 @@ ScrollView {
Layout.alignment: Qt.AlignRight
ButtonGroup.group: notificationSetting
rightPadding: 0
checked: appSettings.notificationSetting === 2
checked: appSettings.notificationSetting === Constants.notifyNone
onCheckedChanged: {
appSettings.notificationSetting = 2
if (checked) {
appSettings.notificationSetting = Constants.notifyNone
}
}
}
}
@ -149,7 +155,7 @@ ScrollView {
Layout.alignment: Qt.AlignRight
checked: appSettings.notificationSoundsEnabled
onCheckedChanged: {
appSettings.notificationSoundsEnabled = this.checked
appSettings.notificationSoundsEnabled = checked
}
}
}
@ -221,7 +227,9 @@ ScrollView {
ButtonGroup.group: messageSetting
checked: appSettings.notificationMessagePreviewSetting === Constants.notificationPreviewAnonymous
onCheckedChanged: {
appSettings.notificationMessagePreviewSetting = Constants.notificationPreviewAnonymous
if (checked) {
appSettings.notificationMessagePreviewSetting = Constants.notificationPreviewAnonymous
}
}
anchors.top: parent.top
anchors.topMargin: Style.current.halfPadding
@ -253,7 +261,9 @@ ScrollView {
ButtonGroup.group: messageSetting
checked: appSettings.notificationMessagePreviewSetting === Constants.notificationPreviewNameOnly
onCheckedChanged: {
appSettings.notificationMessagePreviewSetting = Constants.notificationPreviewNameOnly
if (checked) {
appSettings.notificationMessagePreviewSetting = Constants.notificationPreviewNameOnly
}
}
anchors.top: parent.top
anchors.topMargin: Style.current.halfPadding
@ -415,10 +425,11 @@ ScrollView {
font.pixelSize: 15
color: Style.current.red
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onPressed: mouse.accepted = false
onClicked: {
appSettings.notificationSetting = defaultAppSettings.notificationSetting
appSettings.notificationSoundsEnabled = defaultAppSettings.notificationSoundsEnabled
appSettings.notificationMessagePreviewSetting = defaultAppSettings.notificationMessagePreviewSetting
appSettings.allowNotificationsFromNonContacts = defaultAppSettings.allowNotificationsFromNonContacts
}
}

View File

@ -68,12 +68,9 @@ ApplicationWindow {
}
signal settingsLoaded()
Settings {
id: appSettings
fileName: profileModel.profileSettingsFile
property var chatSplitView
property var walletSplitView
property var profileSplitView
id: defaultAppSettings
property bool walletEnabled: false
property bool browserEnabled: false
property bool displayChatImages: false
@ -81,7 +78,7 @@ ApplicationWindow {
property string locale: "en"
property var recentEmojis: []
property real volume: 0.2
property int notificationSetting: 0
property int notificationSetting: Constants.notifyAllMessages
property bool notificationSoundsEnabled: true
property int notificationMessagePreviewSetting: Constants.notificationPreviewNameAndMessage
property bool allowNotificationsFromNonContacts: false
@ -101,6 +98,39 @@ ApplicationWindow {
property bool compatibilityMode: true
}
Settings {
id: appSettings
fileName: profileModel.profileSettingsFile
property var chatSplitView
property var walletSplitView
property var profileSplitView
property bool walletEnabled: defaultAppSettings.walletEnabled
property bool browserEnabled: defaultAppSettings.browserEnabled
property bool displayChatImages: defaultAppSettings.displayChatImages
property bool compactMode: defaultAppSettings.compactMode
property string locale: defaultAppSettings.locale
property var recentEmojis: defaultAppSettings.recentEmojis
property real volume: defaultAppSettings.volume
property int notificationSetting: defaultAppSettings.notificationSetting
property bool notificationSoundsEnabled: defaultAppSettings.notificationSoundsEnabled
property int notificationMessagePreviewSetting: defaultAppSettings.notificationMessagePreviewSetting
property bool allowNotificationsFromNonContacts: defaultAppSettings.allowNotificationsFromNonContacts
property var whitelistedUnfurlingSites: defaultAppSettings.whitelistedUnfurlingSites
property bool neverAskAboutUnfurlingAgain: defaultAppSettings.neverAskAboutUnfurlingAgain
// Browser settings
property bool autoLoadImages: defaultAppSettings.autoLoadImages
property bool javaScriptEnabled: defaultAppSettings.javaScriptEnabled
property bool errorPageEnabled: defaultAppSettings.errorPageEnabled
property bool pluginsEnabled: defaultAppSettings.pluginsEnabled
property bool autoLoadIconsForPage: defaultAppSettings.autoLoadIconsForPage
property bool touchIconsEnabled: defaultAppSettings.touchIconsEnabled
property bool webRTCPublicInterfacesOnly: defaultAppSettings.webRTCPublicInterfacesOnly
property bool devToolsEnabled: defaultAppSettings.devToolsEnabled
property bool pdfViewerEnabled: defaultAppSettings.pdfViewerEnabled
property bool compatibilityMode: defaultAppSettings.compatibilityMode
}
signal whitelistChanged()
function changeUnfurlingWhitelist(site, enabled) {