quickshell: auto-close dropdowns on mouse inactivity

3s timer starts when dropdown opens or mouse leaves. Hovering
the dropdown stops the timer. Leaves instantly on mouse exit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
rope 2026-05-26 17:17:25 +01:00
parent 98d1e6249c
commit a8a129a9cd

View file

@ -838,6 +838,7 @@ in
property real dropdownX: 0 property real dropdownX: 0
property real fullWidth: 200 property real fullWidth: 200
property real fullHeight: 200 property real fullHeight: 200
property int autoCloseMs: 3000
default property alias content: dropdownContent.data default property alias content: dropdownContent.data
anchor.window: bar anchor.window: bar
@ -854,11 +855,30 @@ in
onVisibleChanged: { onVisibleChanged: {
if (visible) { if (visible) {
open = true; open = true;
_autoClose.restart();
} else { } else {
open = false; open = false;
_autoClose.stop();
} }
} }
Timer {
id: _autoClose
interval: dropdown.autoCloseMs
onTriggered: bar.closeAllDropdowns()
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
propagateComposedEvents: true
onEntered: _autoClose.stop()
onExited: _autoClose.restart()
onClicked: (mouse) => mouse.accepted = false
onPressed: (mouse) => mouse.accepted = false
onReleased: (mouse) => mouse.accepted = false
}
Item { Item {
anchors.right: _dropdownRect.left anchors.right: _dropdownRect.left
anchors.top: parent.top anchors.top: parent.top