pragma ComponentBehavior: Bound import QtQuick import "NotificationPolicy.js" as Policy QtObject { id: entry required property var notification property bool closed: false property bool firstUpdate: true // Coalesce replacement property signals: backend updates several fields in one turn. property Timer changed: Timer { interval: 0 onTriggered: if (!entry.closed) { const resumed = entry.firstUpdate && entry.notification.lastGeneration; entry.expiry.stop(); const duration = Policy.timeoutMs(entry.notification.expireTimeout, entry.notification.urgency); const deadlines = Object.assign({}, Notifications.deadlines); const id = entry.notification.id; const restored = resumed ? Notifications.restoredDeadline(entry.notification) : undefined; const deadline = restored !== undefined ? restored : duration > 0 ? Date.now() + duration : 0; Notifications.setDeadline(id, deadline); Notifications.received(entry.notification, resumed); entry.firstUpdate = false; if (deadline > 0) { entry.expiry.interval = Math.max(1, deadline - Date.now()); entry.expiry.start(); } } } property Timer expiry: Timer { onTriggered: if (!entry.closed) entry.notification.expire() } property Connections events: Connections { target: entry.notification function onSummaryChanged() { entry.changed.restart(); } function onBodyChanged() { entry.changed.restart(); } function onAppNameChanged() { entry.changed.restart(); } function onExpireTimeoutChanged() { entry.changed.restart(); } function onUrgencyChanged() { entry.changed.restart(); } function onActionsChanged() { entry.changed.restart(); } function onHintsChanged() { entry.changed.restart(); } function onTransientChanged() { entry.changed.restart(); } function onImageChanged() { entry.changed.restart(); } function onClosed(reason) { entry.closed = true; entry.changed.stop(); entry.expiry.stop(); Notifications.recordClose(entry.notification.id, reason); } } Component.onCompleted: changed.start() }