diff --git a/Shell/Notifications/NotificationCard.qml b/Shell/Notifications/NotificationCard.qml index 1f6faca..392e436 100644 --- a/Shell/Notifications/NotificationCard.qml +++ b/Shell/Notifications/NotificationCard.qml @@ -21,6 +21,7 @@ Item { property bool closing: false property bool contextOpen: false property real collapseFactor: 1 + property bool hovered: hoverHandler.hovered readonly property string notifTitle: notifObject ? String(notifObject.summary || "") : "" readonly property string notifBody: notifObject ? String(notifObject.body || "") : "" @@ -78,9 +79,11 @@ Item { if (!notifObject) return theme.fallbackNormalTimeoutMs; - const rawSeconds = Number(notifObject.expireTimeout); - if (Number.isFinite(rawSeconds) && rawSeconds > 0) - return Math.max(1000, Math.round(rawSeconds * 1000)); + const rawTimeout = Number(notifObject.expireTimeout); + if (Number.isFinite(rawTimeout) && rawTimeout > 0) { + const normalizedTimeout = rawTimeout > 100 ? Math.round(rawTimeout) : Math.round(rawTimeout * 1000); + return Math.max(theme ? theme.minimumTimeoutMs : 4500, normalizedTimeout); + } const urgency = notifObject.urgency; if (urgency === NotificationUrgency.Critical) @@ -124,7 +127,7 @@ Item { } function restartTimeout() { - if (closing || isExpanded || peekMode) + if (closing || isExpanded || peekMode || hovered) return; timeoutTimer.interval = urgencyTimeoutMs(); timeoutTimer.restart(); @@ -160,7 +163,7 @@ Item { id: timeoutTimer interval: root.urgencyTimeoutMs() repeat: false - running: !root.peekMode + running: false onTriggered: root.beginClose("timeout") } @@ -384,6 +387,10 @@ Item { onTapped: root.beginClose("dismiss") } + HoverHandler { + id: hoverHandler + } + onNotifObjectChanged: restartTimeout() onNotifVersionChanged: restartTimeout() onContextOpenChanged: { @@ -392,5 +399,17 @@ Item { else timeoutTimer.stop(); } + onHoveredChanged: { + if (hovered) + timeoutTimer.stop(); + else + restartTimeout(); + } + onForceExpandedChanged: { + if (forceExpanded) + timeoutTimer.stop(); + else + restartTimeout(); + } Component.onCompleted: restartTimeout() } diff --git a/Shell/Notifications/NotificationTheme.qml b/Shell/Notifications/NotificationTheme.qml index be4e3ea..93c9f75 100644 --- a/Shell/Notifications/NotificationTheme.qml +++ b/Shell/Notifications/NotificationTheme.qml @@ -38,6 +38,7 @@ QtObject { readonly property int fallbackLowTimeoutMs: 4500 readonly property int fallbackNormalTimeoutMs: 5000 readonly property int fallbackCriticalTimeoutMs: 8000 + readonly property int minimumTimeoutMs: 4500 readonly property int enterMs: 170 readonly property int exitMs: 140