This commit is contained in:
2026-03-02 19:31:26 +02:00
parent aa8c07b136
commit 505d28adca
2 changed files with 25 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ Item {
property bool closing: false property bool closing: false
property bool contextOpen: false property bool contextOpen: false
property real collapseFactor: 1 property real collapseFactor: 1
property bool hovered: hoverHandler.hovered
readonly property string notifTitle: notifObject ? String(notifObject.summary || "") : "" readonly property string notifTitle: notifObject ? String(notifObject.summary || "") : ""
readonly property string notifBody: notifObject ? String(notifObject.body || "") : "" readonly property string notifBody: notifObject ? String(notifObject.body || "") : ""
@@ -78,9 +79,11 @@ Item {
if (!notifObject) if (!notifObject)
return theme.fallbackNormalTimeoutMs; return theme.fallbackNormalTimeoutMs;
const rawSeconds = Number(notifObject.expireTimeout); const rawTimeout = Number(notifObject.expireTimeout);
if (Number.isFinite(rawSeconds) && rawSeconds > 0) if (Number.isFinite(rawTimeout) && rawTimeout > 0) {
return Math.max(1000, Math.round(rawSeconds * 1000)); const normalizedTimeout = rawTimeout > 100 ? Math.round(rawTimeout) : Math.round(rawTimeout * 1000);
return Math.max(theme ? theme.minimumTimeoutMs : 4500, normalizedTimeout);
}
const urgency = notifObject.urgency; const urgency = notifObject.urgency;
if (urgency === NotificationUrgency.Critical) if (urgency === NotificationUrgency.Critical)
@@ -124,7 +127,7 @@ Item {
} }
function restartTimeout() { function restartTimeout() {
if (closing || isExpanded || peekMode) if (closing || isExpanded || peekMode || hovered)
return; return;
timeoutTimer.interval = urgencyTimeoutMs(); timeoutTimer.interval = urgencyTimeoutMs();
timeoutTimer.restart(); timeoutTimer.restart();
@@ -160,7 +163,7 @@ Item {
id: timeoutTimer id: timeoutTimer
interval: root.urgencyTimeoutMs() interval: root.urgencyTimeoutMs()
repeat: false repeat: false
running: !root.peekMode running: false
onTriggered: root.beginClose("timeout") onTriggered: root.beginClose("timeout")
} }
@@ -384,6 +387,10 @@ Item {
onTapped: root.beginClose("dismiss") onTapped: root.beginClose("dismiss")
} }
HoverHandler {
id: hoverHandler
}
onNotifObjectChanged: restartTimeout() onNotifObjectChanged: restartTimeout()
onNotifVersionChanged: restartTimeout() onNotifVersionChanged: restartTimeout()
onContextOpenChanged: { onContextOpenChanged: {
@@ -392,5 +399,17 @@ Item {
else else
timeoutTimer.stop(); timeoutTimer.stop();
} }
onHoveredChanged: {
if (hovered)
timeoutTimer.stop();
else
restartTimeout();
}
onForceExpandedChanged: {
if (forceExpanded)
timeoutTimer.stop();
else
restartTimeout();
}
Component.onCompleted: restartTimeout() Component.onCompleted: restartTimeout()
} }

View File

@@ -38,6 +38,7 @@ QtObject {
readonly property int fallbackLowTimeoutMs: 4500 readonly property int fallbackLowTimeoutMs: 4500
readonly property int fallbackNormalTimeoutMs: 5000 readonly property int fallbackNormalTimeoutMs: 5000
readonly property int fallbackCriticalTimeoutMs: 8000 readonly property int fallbackCriticalTimeoutMs: 8000
readonly property int minimumTimeoutMs: 4500
readonly property int enterMs: 170 readonly property int enterMs: 170
readonly property int exitMs: 140 readonly property int exitMs: 140