Do Not Disturb: factorized logic and toast in its proper service.
This commit is contained in:
parent
8ec1ad7255
commit
05bfb6fc37
4 changed files with 13 additions and 22 deletions
|
|
@ -23,11 +23,5 @@ NIconButton {
|
||||||
|
|
||||||
onClicked: PanelService.getPanel("notificationHistoryPanel")?.toggle(screen, this)
|
onClicked: PanelService.getPanel("notificationHistoryPanel")?.toggle(screen, this)
|
||||||
|
|
||||||
onRightClicked: {
|
onRightClicked: Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,6 @@ Item {
|
||||||
}
|
}
|
||||||
function toggleDND() {
|
function toggleDND() {
|
||||||
Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
|
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,13 +48,7 @@ NPanel {
|
||||||
icon: Settings.data.notifications.doNotDisturb ? "notifications_off" : "notifications_active"
|
icon: Settings.data.notifications.doNotDisturb ? "notifications_off" : "notifications_active"
|
||||||
tooltipText: Settings.data.notifications.doNotDisturb ? "Do Not Disturb (ON)" : "Do Not Disturb (OFF)"
|
tooltipText: Settings.data.notifications.doNotDisturb ? "Do Not Disturb (ON)" : "Do Not Disturb (OFF)"
|
||||||
sizeRatio: 0.8
|
sizeRatio: 0.8
|
||||||
onClicked: {
|
onClicked: Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
|
||||||
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 {
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,11 @@ Singleton {
|
||||||
|
|
||||||
// Signal when notification is received
|
// Signal when notification is received
|
||||||
onNotification: function (notification) {
|
onNotification: function (notification) {
|
||||||
|
// Always add notification to history
|
||||||
|
root.addToHistory(notification)
|
||||||
|
|
||||||
// Check if do-not-disturb is enabled
|
// Check if do-not-disturb is enabled
|
||||||
if (Settings.data.notifications && Settings.data.notifications.doNotDisturb) {
|
if (Settings.data.notifications && Settings.data.notifications.doNotDisturb) {
|
||||||
// Still add to history but don't show notification
|
|
||||||
root.addToHistory(notification)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,8 +46,6 @@ Singleton {
|
||||||
|
|
||||||
// Add to our model
|
// Add to our model
|
||||||
root.addNotification(notification)
|
root.addNotification(notification)
|
||||||
// Also add to history
|
|
||||||
root.addToHistory(notification)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,6 +107,15 @@ Singleton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Settings.data.notifications
|
||||||
|
function onDoNotDisturbChanged() {
|
||||||
|
const label = Settings.data.notifications.doNotDisturb ? "'Do Not Disturb' enabled" : "'Do Not Disturb' disabled"
|
||||||
|
const description = Settings.data.notifications.doNotDisturb ? "You'll find these notifications in your history." : "Showing all notifications."
|
||||||
|
ToastService.showNotice(label, description, "notice", false, 2000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Function to add notification to model
|
// Function to add notification to model
|
||||||
function addNotification(notification) {
|
function addNotification(notification) {
|
||||||
notificationModel.insert(0, {
|
notificationModel.insert(0, {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue