timeout popup after mouse exits

This commit is contained in:
Benjamin Palko 2025-08-02 21:03:41 -04:00
parent 49ec4d8502
commit 87e9941e0a

View file

@ -32,51 +32,71 @@ PopupWindow {
} }
} }
WrapperRectangle { Timer {
id: background id: timer
interval: 750
opacity: 0 onTriggered: {
Behavior on opacity { if (!root.visible) {
NumberAnimation { return;
duration: root.animationDuration
} }
root.toggle();
} }
}
states: State { WrapperMouseArea {
name: "opened" hoverEnabled: true
when: root.opened onExited: {
PropertyChanges { timer.start();
background { }
opacity: 1 onEntered: {
timer.stop();
}
WrapperRectangle {
id: background
opacity: 0
Behavior on opacity {
NumberAnimation {
duration: root.animationDuration
} }
} }
}
transitions: [ states: State {
Transition { name: "opened"
from: "" when: root.opened
to: "opened" PropertyChanges {
ScriptAction { background {
script: root.visible = true opacity: 1
}
},
Transition {
from: "opened"
to: ""
SequentialAnimation {
PauseAnimation {
duration: root.animationDuration
} }
}
}
transitions: [
Transition {
from: ""
to: "opened"
ScriptAction { ScriptAction {
script: root.visible = false script: root.visible = true
}
},
Transition {
from: "opened"
to: ""
SequentialAnimation {
PauseAnimation {
duration: root.animationDuration
}
ScriptAction {
script: root.visible = false
}
} }
} }
} ]
]
Loader { Loader {
active: root.visible active: root.visible
sourceComponent: root.content sourceComponent: root.content
}
} }
} }
} }