diff --git a/Modules/Notification/Notification.qml b/Modules/Notification/Notification.qml index dcc820f58..9fbd1ad9d 100644 --- a/Modules/Notification/Notification.qml +++ b/Modules/Notification/Notification.qml @@ -198,7 +198,7 @@ Variants { property string notificationId: model.id property var notificationData: model - property int hoverCount: 0 + property bool isHovered: false property bool isRemoving: false readonly property int animationDelay: index * 100 @@ -249,34 +249,13 @@ Variants { return deltaY; } - // Hover handling - 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); - } - } - } - // Animation setup function triggerEntryAnimation() { animInDelayTimer.stop(); removalTimer.stop(); resumeTimer.stop(); isRemoving = false; - hoverCount = 0; + isHovered = false; isSwiping = false; swipeOffset = 0; swipeOffsetY = 0; @@ -428,14 +407,35 @@ Variants { anchors.fill: parent anchors.margins: notifWindow.shadowPadding + HoverHandler { + onHoveredChanged: { + isHovered = hovered; + if (isHovered) { + resumeTimer.stop(); + NotificationService.pauseTimeout(notificationId); + } else { + resumeTimer.start(); + } + } + } + + Timer { + id: resumeTimer + interval: 50 + repeat: false + onTriggered: { + if (!isHovered) { + NotificationService.resumeTimeout(notificationId); + } + } + } + // Right-click to dismiss MouseArea { id: cardDragArea anchors.fill: cardBackground acceptedButtons: Qt.LeftButton | Qt.RightButton hoverEnabled: true - onEntered: card.hoverCount++ - onExited: card.hoverCount-- onPressed: mouse => { if (mouse.button === Qt.LeftButton) { const globalPoint = cardDragArea.mapToGlobal(mouse.x, mouse.y); @@ -586,10 +586,6 @@ Variants { anchors.margins: Style.marginM spacing: Style.marginM - HoverHandler { - onHoveredChanged: hovered ? card.hoverCount++ : card.hoverCount-- - } - RowLayout { Layout.fillWidth: true spacing: Style.marginL @@ -698,9 +694,6 @@ Variants { delegate: NButton { property var actionData: modelData - onEntered: card.hoverCount++ - onExited: card.hoverCount-- - text: { var actionText = actionData.text || "Open"; if (actionText.includes(",")) { @@ -735,10 +728,6 @@ Variants { anchors.right: cardBackground.right anchors.rightMargin: Style.marginXL - HoverHandler { - onHoveredChanged: hovered ? card.hoverCount++ : card.hoverCount-- - } - onClicked: { card.runAction("", true); } @@ -752,10 +741,6 @@ Variants { anchors.margins: Style.marginM spacing: Style.marginS - HoverHandler { - onHoveredChanged: hovered ? card.hoverCount++ : card.hoverCount-- - } - NImageRounded { Layout.preferredWidth: Math.round(24 * Style.uiScaleRatio) Layout.preferredHeight: Math.round(24 * Style.uiScaleRatio) diff --git a/Modules/Toast/Toast.qml b/Modules/Toast/Toast.qml index 92795f05f..05a8b1b5f 100644 --- a/Modules/Toast/Toast.qml +++ b/Modules/Toast/Toast.qml @@ -29,7 +29,7 @@ Item { scale: initialScale property real progress: 1.0 - property int hoverCount: 0 + property bool isHovered: false property real swipeOffset: 0 property real swipeOffsetY: 0 property real pressGlobalX: 0 @@ -64,14 +64,17 @@ Item { return deltaY; } - onHoverCountChanged: { - if (hoverCount > 0) { - resumeTimer.stop(); - if (progressAnimation.running && !progressAnimation.paused) { - progressAnimation.pause(); + HoverHandler { + onHoveredChanged: { + isHovered = hovered; + if (isHovered) { + resumeTimer.stop(); + if (progressAnimation.running && !progressAnimation.paused) { + progressAnimation.pause(); + } + } else { + resumeTimer.start(); } - } else { - resumeTimer.start(); } } @@ -80,7 +83,7 @@ Item { interval: 50 repeat: false onTriggered: { - if (hoverCount === 0 && progressAnimation.paused) { + if (!isHovered && progressAnimation.paused) { progressAnimation.resume(); } } @@ -218,12 +221,6 @@ Item { anchors.fill: background acceptedButtons: Qt.LeftButton hoverEnabled: true - onEntered: { - root.hoverCount++; - } - onExited: { - root.hoverCount--; - } onPressed: mouse => { const globalPoint = toastDragArea.mapToGlobal(mouse.x, mouse.y); root.pressGlobalX = globalPoint.x; @@ -353,9 +350,6 @@ Item { outlined: false implicitHeight: 24 - onEntered: root.hoverCount++ - onExited: root.hoverCount-- - onClicked: { if (root.actionCallback) { root.actionCallback(); @@ -383,7 +377,7 @@ Item { opacity = 1.0; scale = 1.0; progress = 1.0; - hoverCount = 0; + isHovered = false; isSwiping = false; swipeOffset = 0; swipeOffsetY = 0;