mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Notification: make doNotDisturb non persistent (fixes #665)
This commit is contained in:
@@ -206,7 +206,6 @@
|
||||
},
|
||||
"notifications": {
|
||||
"enabled": true,
|
||||
"doNotDisturb": false,
|
||||
"monitors": [],
|
||||
"location": "top_right",
|
||||
"overlayLayer": true,
|
||||
|
||||
@@ -342,7 +342,6 @@ Singleton {
|
||||
// notifications
|
||||
property JsonObject notifications: JsonObject {
|
||||
property bool enabled: true
|
||||
property bool doNotDisturb: false
|
||||
property list<string> monitors: []
|
||||
property string location: "top_right"
|
||||
property bool overlayLayer: true
|
||||
|
||||
@@ -48,8 +48,8 @@ NIconButton {
|
||||
baseSize: Style.capsuleHeight
|
||||
applyUiScale: false
|
||||
density: Settings.data.bar.density
|
||||
icon: Settings.data.notifications.doNotDisturb ? "bell-off" : "bell"
|
||||
tooltipText: Settings.data.notifications.doNotDisturb ? I18n.tr("tooltips.open-notification-history-disable-dnd") : I18n.tr("tooltips.open-notification-history-enable-dnd")
|
||||
icon: NotificationService.doNotDisturb ? "bell-off" : "bell"
|
||||
tooltipText: NotificationService.doNotDisturb ? I18n.tr("tooltips.open-notification-history-disable-dnd") : I18n.tr("tooltips.open-notification-history-enable-dnd")
|
||||
tooltipDirection: BarService.getTooltipDirection()
|
||||
colorBg: (Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent)
|
||||
colorFg: Color.mOnSurface
|
||||
@@ -61,7 +61,7 @@ NIconButton {
|
||||
panel?.toggle(this)
|
||||
}
|
||||
|
||||
onRightClicked: Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
|
||||
onRightClicked: NotificationService.doNotDisturb = !NotificationService.doNotDisturb
|
||||
|
||||
Loader {
|
||||
anchors.right: parent.right
|
||||
|
||||
@@ -8,9 +8,9 @@ import qs.Widgets
|
||||
NIconButtonHot {
|
||||
property ShellScreen screen
|
||||
|
||||
icon: Settings.data.notifications.doNotDisturb ? "bell-off" : "bell"
|
||||
hot: Settings.data.notifications.doNotDisturb
|
||||
icon: NotificationService.doNotDisturb ? "bell-off" : "bell"
|
||||
hot: NotificationService.doNotDisturb
|
||||
tooltipText: I18n.tr("quickSettings.notifications.tooltip.action")
|
||||
onClicked: PanelService.getPanel("notificationHistoryPanel", screen)?.toggle(this)
|
||||
onRightClicked: Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
|
||||
onRightClicked: NotificationService.doNotDisturb = !NotificationService.doNotDisturb
|
||||
}
|
||||
|
||||
@@ -56,10 +56,10 @@ SmartPanel {
|
||||
}
|
||||
|
||||
NIconButton {
|
||||
icon: Settings.data.notifications.doNotDisturb ? "bell-off" : "bell"
|
||||
tooltipText: Settings.data.notifications.doNotDisturb ? I18n.tr("tooltips.do-not-disturb-enabled") : I18n.tr("tooltips.do-not-disturb-disabled")
|
||||
icon: NotificationService.doNotDisturb ? "bell-off" : "bell"
|
||||
tooltipText: NotificationService.doNotDisturb ? I18n.tr("tooltips.do-not-disturb-enabled") : I18n.tr("tooltips.do-not-disturb-disabled")
|
||||
baseSize: Style.baseWidgetSize * 0.8
|
||||
onClicked: Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
|
||||
onClicked: NotificationService.doNotDisturb = !NotificationService.doNotDisturb
|
||||
}
|
||||
|
||||
NIconButton {
|
||||
|
||||
@@ -42,8 +42,8 @@ ColumnLayout {
|
||||
NToggle {
|
||||
label: I18n.tr("settings.notifications.settings.do-not-disturb.label")
|
||||
description: I18n.tr("settings.notifications.settings.do-not-disturb.description")
|
||||
checked: Settings.data.notifications.doNotDisturb
|
||||
onToggled: checked => Settings.data.notifications.doNotDisturb = checked
|
||||
checked: NotificationService.doNotDisturb
|
||||
onToggled: checked => NotificationService.doNotDisturb = checked
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
|
||||
@@ -62,13 +62,13 @@ Item {
|
||||
})
|
||||
}
|
||||
function toggleDND() {
|
||||
Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
|
||||
NotificationService.doNotDisturb = !NotificationService.doNotDisturb
|
||||
}
|
||||
function enableDND() {
|
||||
Settings.data.notifications.doNotDisturb = true
|
||||
NotificationService.doNotDisturb = true
|
||||
}
|
||||
function disableDND() {
|
||||
Settings.data.notifications.doNotDisturb = false
|
||||
NotificationService.doNotDisturb = false
|
||||
}
|
||||
function clear() {
|
||||
NotificationService.clearHistory()
|
||||
|
||||
@@ -21,6 +21,8 @@ Singleton {
|
||||
|
||||
// State
|
||||
property real lastSeenTs: 0
|
||||
// Volatile property that doesn't persist to settings (similar to noctaliaPerformanceMode)
|
||||
property bool doNotDisturb: false
|
||||
|
||||
// Models
|
||||
property ListModel activeList: ListModel {}
|
||||
@@ -161,7 +163,7 @@ Singleton {
|
||||
const data = createData(notification)
|
||||
addToHistory(data)
|
||||
|
||||
if (Settings.data.notifications?.doNotDisturb || PowerProfileService.noctaliaPerformanceMode)
|
||||
if (root.doNotDisturb || PowerProfileService.noctaliaPerformanceMode)
|
||||
return
|
||||
|
||||
// Check if this is a replacement notification
|
||||
@@ -728,11 +730,7 @@ Singleton {
|
||||
// Signals
|
||||
signal animateAndRemove(string notificationId)
|
||||
|
||||
Connections {
|
||||
target: Settings.data.notifications
|
||||
function onDoNotDisturbChanged() {
|
||||
const enabled = Settings.data.notifications.doNotDisturb
|
||||
ToastService.showNotice(enabled ? I18n.tr("toast.do-not-disturb.enabled") : I18n.tr("toast.do-not-disturb.disabled"), enabled ? I18n.tr("toast.do-not-disturb.enabled-desc") : I18n.tr("toast.do-not-disturb.disabled-desc"), enabled ? "bell-off" : "bell")
|
||||
}
|
||||
onDoNotDisturbChanged: {
|
||||
ToastService.showNotice(doNotDisturb ? I18n.tr("toast.do-not-disturb.enabled") : I18n.tr("toast.do-not-disturb.disabled"), doNotDisturb ? I18n.tr("toast.do-not-disturb.enabled-desc") : I18n.tr("toast.do-not-disturb.disabled-desc"), doNotDisturb ? "bell-off" : "bell")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user