Notification: add DND option to widget and notification panel as requested in #212

This commit is contained in:
Ly-sec 2025-09-05 22:42:40 +02:00
parent 60950fb461
commit c8a056f332
4 changed files with 28 additions and 5 deletions

View file

@ -296,6 +296,7 @@ Singleton {
// notifications
property JsonObject notifications: JsonObject {
property bool doNotDisturb: false
property list<string> monitors: []
}

View file

@ -14,11 +14,20 @@ NIconButton {
property real scaling: 1.0
sizeRatio: 0.8
icon: "notifications"
tooltipText: "Notification history"
icon: Settings.data.notifications.doNotDisturb ? "notifications_off" : "notifications"
tooltipText: Settings.data.notifications.doNotDisturb ? "Notification history (Do Not Disturb ON)\nRight-click to toggle Do Not Disturb" : "Notification history\nRight-click to toggle Do Not Disturb"
colorBg: Color.mSurfaceVariant
colorFg: Color.mOnSurface
colorFg: Settings.data.notifications.doNotDisturb ? Color.mError : Color.mOnSurface
colorBorder: Color.transparent
colorBorderHover: Color.transparent
onClicked: PanelService.getPanel("notificationHistoryPanel")?.toggle(screen, this)
onRightClicked: {
Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
ToastService.showNotice(
Settings.data.notifications.doNotDisturb ? "Do Not Disturb enabled" : "Do Not Disturb disabled",
Settings.data.notifications.doNotDisturb ? "Notifications will be hidden but saved to history" : "Notifications will be shown normally",
"notice", false, 2000)
}
}

View file

@ -43,6 +43,19 @@ NPanel {
Layout.fillWidth: true
}
NIconButton {
icon: Settings.data.notifications.doNotDisturb ? "notifications_off" : "notifications_active"
tooltipText: Settings.data.notifications.doNotDisturb ? "Do Not Disturb (ON)" : "Do Not Disturb (OFF)"
sizeRatio: 0.8
onClicked: {
Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
ToastService.showNotice(
Settings.data.notifications.doNotDisturb ? "Do Not Disturb enabled" : "Do Not Disturb disabled",
Settings.data.notifications.doNotDisturb ? "Notifications will be hidden but saved to history" : "Notifications will be shown normally",
"notice", false, 2000)
}
}
NIconButton {
icon: "delete"
tooltipText: "Clear history"

View file

@ -29,8 +29,8 @@ Singleton {
// Signal when notification is received
onNotification: function (notification) {
// Check if notifications are suppressed
if (Settings.data.notifications && Settings.data.notifications.suppressed) {
// Check if do-not-disturb is enabled
if (Settings.data.notifications && Settings.data.notifications.doNotDisturb) {
// Still add to history but don't show notification
root.addToHistory(notification)
return