Notification: add enable/disable toggle

This commit is contained in:
Ly-sec
2025-11-06 17:30:16 +01:00
parent 7211868c27
commit ceb2dea2a9
12 changed files with 81 additions and 6 deletions
+40 -6
View File
@@ -76,12 +76,46 @@ Singleton {
}
}
// Notification server
NotificationServer {
keepOnReload: false
imageSupported: true
actionsSupported: true
onNotification: notification => handleNotification(notification)
// Notification server - only created when notifications are enabled
property var notificationServerLoader: null
Component {
id: notificationServerComponent
NotificationServer {
keepOnReload: false
imageSupported: true
actionsSupported: true
onNotification: notification => handleNotification(notification)
}
}
function updateNotificationServer() {
// Destroy existing server if it exists
if (notificationServerLoader) {
notificationServerLoader.destroy()
notificationServerLoader = null
}
// Create server only if enabled
if (Settings.isLoaded && Settings.data.notifications.enabled !== false) {
notificationServerLoader = notificationServerComponent.createObject(root)
}
}
Component.onCompleted: {
if (Settings.isLoaded) {
updateNotificationServer()
}
}
Connections {
target: Settings
function onSettingsLoaded() {
updateNotificationServer()
}
function onSettingsSaved() {
updateNotificationServer()
}
}
// Main handler