quickshell: hover-to-switch between active dropdowns
When a dropdown is open, hovering another bar icon (clock, network, battery, tray) instantly switches to that dropdown. Also handles cancelling a close animation to reopen. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1d45734a04
commit
53c9abb11a
1 changed files with 46 additions and 21 deletions
|
|
@ -469,12 +469,18 @@ in
|
|||
if (dd.visible && !dd.closing) {
|
||||
dd.animateClose();
|
||||
activeDropdown = null;
|
||||
} else if (!dd.visible) {
|
||||
} else {
|
||||
if (activeDropdown && activeDropdown !== dd && activeDropdown.visible) {
|
||||
activeDropdown.animateClose();
|
||||
}
|
||||
if (setupFn) setupFn();
|
||||
if (dd.closing) {
|
||||
// Cancel close animation, reopen
|
||||
dd.closing = false;
|
||||
dd.open = true;
|
||||
} else {
|
||||
dd.visible = true;
|
||||
}
|
||||
activeDropdown = dd;
|
||||
}
|
||||
}
|
||||
|
|
@ -539,9 +545,9 @@ in
|
|||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
bar.toggleDropdown(calPopup);
|
||||
}
|
||||
hoverEnabled: true
|
||||
onClicked: bar.toggleDropdown(calPopup)
|
||||
onEntered: { if (bar.activeDropdown && bar.activeDropdown !== calPopup) bar.toggleDropdown(calPopup); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -659,9 +665,7 @@ in
|
|||
}
|
||||
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
function openNetDropdown() {
|
||||
bar.toggleDropdown(netDropdown, function() {
|
||||
netWidget.wifiNetworks = [];
|
||||
wifiScanProc.running = true;
|
||||
|
|
@ -669,6 +673,12 @@ in
|
|||
netDropdown.dropdownX = pos.x;
|
||||
});
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: netWidget.openNetDropdown()
|
||||
onEntered: { if (bar.activeDropdown && bar.activeDropdown !== netDropdown) netWidget.openNetDropdown(); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -787,9 +797,7 @@ in
|
|||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
function openBatteryDropdown() {
|
||||
bar.toggleDropdown(batteryDropdown, function() {
|
||||
batteryProc.running = true;
|
||||
profileProc.running = true;
|
||||
|
|
@ -797,6 +805,12 @@ in
|
|||
batteryDropdown.dropdownX = pos.x;
|
||||
});
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: batteryWidget.openBatteryDropdown()
|
||||
onEntered: { if (bar.activeDropdown && bar.activeDropdown !== batteryDropdown) batteryWidget.openBatteryDropdown(); }
|
||||
}
|
||||
}
|
||||
''}
|
||||
|
|
@ -835,6 +849,7 @@ in
|
|||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
hoverEnabled: true
|
||||
onClicked: (event) => {
|
||||
if (event.button === Qt.RightButton && modelData.hasMenu) {
|
||||
bar.toggleDropdown(contextMenu, function() {
|
||||
|
|
@ -847,6 +862,16 @@ in
|
|||
modelData.activate();
|
||||
}
|
||||
}
|
||||
onEntered: {
|
||||
if (bar.activeDropdown && modelData.hasMenu) {
|
||||
bar.toggleDropdown(contextMenu, function() {
|
||||
let pos = parent.mapToItem(bar.contentItem, parent.width / 2, 0);
|
||||
contextMenu.dropdownX = pos.x;
|
||||
contextMenu.trayItem = modelData;
|
||||
menuOpener.menu = modelData.menu;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue