Notification: add DND option to widget and notification panel as requested in #212
This commit is contained in:
parent
60950fb461
commit
c8a056f332
4 changed files with 28 additions and 5 deletions
|
|
@ -296,6 +296,7 @@ Singleton {
|
||||||
|
|
||||||
// notifications
|
// notifications
|
||||||
property JsonObject notifications: JsonObject {
|
property JsonObject notifications: JsonObject {
|
||||||
|
property bool doNotDisturb: false
|
||||||
property list<string> monitors: []
|
property list<string> monitors: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,20 @@ NIconButton {
|
||||||
property real scaling: 1.0
|
property real scaling: 1.0
|
||||||
|
|
||||||
sizeRatio: 0.8
|
sizeRatio: 0.8
|
||||||
icon: "notifications"
|
icon: Settings.data.notifications.doNotDisturb ? "notifications_off" : "notifications"
|
||||||
tooltipText: "Notification history"
|
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
|
colorBg: Color.mSurfaceVariant
|
||||||
colorFg: Color.mOnSurface
|
colorFg: Settings.data.notifications.doNotDisturb ? Color.mError : Color.mOnSurface
|
||||||
colorBorder: Color.transparent
|
colorBorder: Color.transparent
|
||||||
colorBorderHover: Color.transparent
|
colorBorderHover: Color.transparent
|
||||||
|
|
||||||
onClicked: PanelService.getPanel("notificationHistoryPanel")?.toggle(screen, this)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,19 @@ NPanel {
|
||||||
Layout.fillWidth: true
|
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 {
|
NIconButton {
|
||||||
icon: "delete"
|
icon: "delete"
|
||||||
tooltipText: "Clear history"
|
tooltipText: "Clear history"
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ Singleton {
|
||||||
// Signal when notification is received
|
// Signal when notification is received
|
||||||
onNotification: function (notification) {
|
onNotification: function (notification) {
|
||||||
|
|
||||||
// Check if notifications are suppressed
|
// Check if do-not-disturb is enabled
|
||||||
if (Settings.data.notifications && Settings.data.notifications.suppressed) {
|
if (Settings.data.notifications && Settings.data.notifications.doNotDisturb) {
|
||||||
// Still add to history but don't show notification
|
// Still add to history but don't show notification
|
||||||
root.addToHistory(notification)
|
root.addToHistory(notification)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue