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) {
|
if (dd.visible && !dd.closing) {
|
||||||
dd.animateClose();
|
dd.animateClose();
|
||||||
activeDropdown = null;
|
activeDropdown = null;
|
||||||
} else if (!dd.visible) {
|
} else {
|
||||||
if (activeDropdown && activeDropdown !== dd && activeDropdown.visible) {
|
if (activeDropdown && activeDropdown !== dd && activeDropdown.visible) {
|
||||||
activeDropdown.animateClose();
|
activeDropdown.animateClose();
|
||||||
}
|
}
|
||||||
if (setupFn) setupFn();
|
if (setupFn) setupFn();
|
||||||
|
if (dd.closing) {
|
||||||
|
// Cancel close animation, reopen
|
||||||
|
dd.closing = false;
|
||||||
|
dd.open = true;
|
||||||
|
} else {
|
||||||
dd.visible = true;
|
dd.visible = true;
|
||||||
|
}
|
||||||
activeDropdown = dd;
|
activeDropdown = dd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -539,9 +545,9 @@ in
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
hoverEnabled: true
|
||||||
bar.toggleDropdown(calPopup);
|
onClicked: bar.toggleDropdown(calPopup)
|
||||||
}
|
onEntered: { if (bar.activeDropdown && bar.activeDropdown !== calPopup) bar.toggleDropdown(calPopup); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -659,9 +665,7 @@ in
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MouseArea {
|
function openNetDropdown() {
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {
|
|
||||||
bar.toggleDropdown(netDropdown, function() {
|
bar.toggleDropdown(netDropdown, function() {
|
||||||
netWidget.wifiNetworks = [];
|
netWidget.wifiNetworks = [];
|
||||||
wifiScanProc.running = true;
|
wifiScanProc.running = true;
|
||||||
|
|
@ -669,6 +673,12 @@ in
|
||||||
netDropdown.dropdownX = pos.x;
|
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 {
|
function openBatteryDropdown() {
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {
|
|
||||||
bar.toggleDropdown(batteryDropdown, function() {
|
bar.toggleDropdown(batteryDropdown, function() {
|
||||||
batteryProc.running = true;
|
batteryProc.running = true;
|
||||||
profileProc.running = true;
|
profileProc.running = true;
|
||||||
|
|
@ -797,6 +805,12 @@ in
|
||||||
batteryDropdown.dropdownX = pos.x;
|
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 {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
hoverEnabled: true
|
||||||
onClicked: (event) => {
|
onClicked: (event) => {
|
||||||
if (event.button === Qt.RightButton && modelData.hasMenu) {
|
if (event.button === Qt.RightButton && modelData.hasMenu) {
|
||||||
bar.toggleDropdown(contextMenu, function() {
|
bar.toggleDropdown(contextMenu, function() {
|
||||||
|
|
@ -847,6 +862,16 @@ in
|
||||||
modelData.activate();
|
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