From 87e9941e0a50971c2b1294ed18c416f8dc1bf864 Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Sat, 2 Aug 2025 21:03:41 -0400 Subject: [PATCH] timeout popup after mouse exits --- widgets/StyledPopupWindow.qml | 88 +++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 34 deletions(-) diff --git a/widgets/StyledPopupWindow.qml b/widgets/StyledPopupWindow.qml index 4b7ed4f..4927cfb 100644 --- a/widgets/StyledPopupWindow.qml +++ b/widgets/StyledPopupWindow.qml @@ -32,51 +32,71 @@ PopupWindow { } } - WrapperRectangle { - id: background - - opacity: 0 - Behavior on opacity { - NumberAnimation { - duration: root.animationDuration + Timer { + id: timer + interval: 750 + onTriggered: { + if (!root.visible) { + return; } + root.toggle(); } + } - states: State { - name: "opened" - when: root.opened - PropertyChanges { - background { - opacity: 1 + WrapperMouseArea { + hoverEnabled: true + onExited: { + timer.start(); + } + onEntered: { + timer.stop(); + } + WrapperRectangle { + id: background + + opacity: 0 + Behavior on opacity { + NumberAnimation { + duration: root.animationDuration } } - } - transitions: [ - Transition { - from: "" - to: "opened" - ScriptAction { - script: root.visible = true - } - }, - Transition { - from: "opened" - to: "" - SequentialAnimation { - PauseAnimation { - duration: root.animationDuration + states: State { + name: "opened" + when: root.opened + PropertyChanges { + background { + opacity: 1 } + } + } + + transitions: [ + Transition { + from: "" + to: "opened" ScriptAction { - script: root.visible = false + script: root.visible = true + } + }, + Transition { + from: "opened" + to: "" + SequentialAnimation { + PauseAnimation { + duration: root.animationDuration + } + ScriptAction { + script: root.visible = false + } } } - } - ] + ] - Loader { - active: root.visible - sourceComponent: root.content + Loader { + active: root.visible + sourceComponent: root.content + } } } }