Merge pull request #504 from Amadoabad/notification-freeze

Notifications freeze when hovered
This commit is contained in:
Lysec
2025-10-17 13:03:30 +02:00
committed by GitHub
3 changed files with 52 additions and 2 deletions
+28
View File
@@ -248,10 +248,35 @@ Variants {
// Staggered animation delay based on index
readonly property int animationDelay: index * 100
property int hoverCount: 0
onHoverCountChanged: {
if (hoverCount > 0) {
resumeTimer.stop()
NotificationService.pauseTimeout(notificationId)
} else {
resumeTimer.start()
}
}
Timer {
id: resumeTimer
interval: 50
repeat: false
onTriggered: {
if (hoverCount === 0) {
NotificationService.resumeTimeout(notificationId)
}
}
}
// Right-click to dismiss
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
hoverEnabled: true
onEntered: parent.hoverCount++
onExited: parent.hoverCount--
onClicked: {
if (mouse.button === Qt.RightButton) {
animateOut()
@@ -484,6 +509,9 @@ Variants {
delegate: NButton {
property var actionData: modelData
onEntered: card.hoverCount++
onExited: card.hoverCount--
text: {
var actionText = actionData.text || "Open"
// If text contains comma, take the part after the comma (the display text)
+20 -2
View File
@@ -111,7 +111,9 @@ Singleton {
notificationMetadata[data.id] = {
"timestamp": data.timestamp.getTime(),
"duration": expire,
"urgency": data.urgency
"urgency": data.urgency,
"paused": false,
"pauseTime": 0
}
activeList.insert(0, data)
@@ -219,7 +221,7 @@ Singleton {
const notif = activeList.get(i)
const meta = notificationMetadata[notif.id]
if (!meta || meta.duration === -1)
if (!meta || meta.duration === -1 || meta.paused)
continue
// Skip infinite notifications
@@ -408,6 +410,22 @@ Singleton {
return ""
}
function pauseTimeout(id) {
const meta = notificationMetadata[id]
if (meta && !meta.paused) {
meta.paused = true
meta.pauseTime = Date.now()
}
}
function resumeTimeout(id) {
const meta = notificationMetadata[id]
if (meta && meta.paused) {
meta.timestamp += Date.now() - meta.pauseTime
meta.paused = false
}
}
// Public API
function dismissActiveNotification(id) {
activeMap[id]?.dismiss()
+4
View File
@@ -25,6 +25,8 @@ Rectangle {
signal clicked
signal rightClicked
signal middleClicked
signal entered
signal exited
// Internal properties
property bool hovered: false
@@ -140,12 +142,14 @@ Rectangle {
onEntered: {
root.hovered = true
root.entered()
if (tooltipText) {
TooltipService.show(Screen, root, root.tooltipText)
}
}
onExited: {
root.hovered = false
root.exited()
if (tooltipText) {
TooltipService.hide()
}