centralize panel content-change grace period into HoverPanel.keepOpen()

This commit is contained in:
Damocles 2026-04-16 18:37:53 +02:00
parent 084ef1da75
commit 46f14d5d36
6 changed files with 36 additions and 19 deletions

View file

@ -47,6 +47,7 @@ M.BarSection {
property M.ProcessList _procs: M.ProcessList {
sortBy: "cpu"
active: root._showPanel
onProcessesChanged: hoverPanel.keepOpen(300)
}
on_AnyHoverChanged: {

View file

@ -92,6 +92,24 @@ PanelWindow {
}
}
// Content-change grace: call keepOpen(ms) when panel content is about to
// resize/rebuild (session switch, device list change, etc.) to prevent the
// hover-drop-on-resize from closing the panel.
property bool _contentBusy: false
Timer {
id: _contentBusyTimer
onTriggered: {
root._contentBusy = false;
if (!root.showPanel && !root._grace && !root._pinned)
root._hideTimer.restart();
}
}
function keepOpen(ms) {
_contentBusy = true;
_contentBusyTimer.interval = ms ?? 400;
_contentBusyTimer.restart();
}
function _show() {
_updatePosition();
_winVisible = true;
@ -115,7 +133,7 @@ PanelWindow {
Timer {
id: _hideTimer
interval: 150
onTriggered: if (!root.showPanel && !root._grace && !root._pinned)
onTriggered: if (!root.showPanel && !root._grace && !root._pinned && !root._contentBusy)
root.dismiss()
}

View file

@ -24,6 +24,7 @@ M.BarSection {
property M.ProcessList _procs: M.ProcessList {
sortBy: "mem"
active: root._showPanel
onProcessesChanged: hoverPanel.keepOpen(300)
}
on_AnyHoverChanged: {

View file

@ -75,13 +75,7 @@ M.BarSection {
required property var bar
property bool _pinned: false
property bool _switching: false
Timer {
id: _sessionSwitchTimer
interval: 400
onTriggered: root._switching = false
}
readonly property bool _anyHover: root._hovered || hoverPanel.panelHovered || _switching
readonly property bool _anyHover: root._hovered || hoverPanel.panelHovered
readonly property bool _showPanel: _anyHover || _pinned
on_AnyHoverChanged: {
@ -414,8 +408,7 @@ M.BarSection {
TapHandler {
onTapped: {
root._playerIdx = index;
root._switching = true;
_sessionSwitchTimer.restart();
hoverPanel.keepOpen(400);
}
}
}

View file

@ -98,7 +98,7 @@ M.BarSection {
required property var bar
readonly property bool _anyHover: root._hovered || networkMenu.panelHovered || networkMenu._busy
readonly property bool _anyHover: root._hovered || networkMenu.panelHovered
M.NetworkMenu {
id: networkMenu

View file

@ -12,8 +12,6 @@ M.HoverPanel {
onVisibleChanged: if (visible)
scanner.running = true
readonly property bool _busy: connectProc.running || disconnectProc.running || radioProc.running
function triggerRefresh() {
if (visible)
scanner.running = true;
@ -85,24 +83,30 @@ M.HoverPanel {
id: radioProc
property string _state: ""
command: ["nmcli", "radio", "wifi", _state]
onRunningChanged: if (!running)
scanner.running = true
onRunningChanged: if (!running) {
scanner.running = true;
menuWindow.keepOpen(500);
}
}
property Process _connectProc: Process {
id: connectProc
property string uuid: ""
command: ["nmcli", "connection", "up", uuid]
onRunningChanged: if (!running)
scanner.running = true
onRunningChanged: if (!running) {
scanner.running = true;
menuWindow.keepOpen(500);
}
}
property Process _disconnectProc: Process {
id: disconnectProc
property string uuid: ""
command: ["nmcli", "connection", "down", uuid]
onRunningChanged: if (!running)
scanner.running = true
onRunningChanged: if (!running) {
scanner.running = true;
menuWindow.keepOpen(500);
}
}
// Wi-Fi radio toggle header