From 46f14d5d36d39d815366168dc526613f7f75bcd8 Mon Sep 17 00:00:00 2001 From: Damocles Date: Thu, 16 Apr 2026 18:37:53 +0200 Subject: [PATCH] centralize panel content-change grace period into HoverPanel.keepOpen() --- modules/Cpu.qml | 1 + modules/HoverPanel.qml | 20 +++++++++++++++++++- modules/Memory.qml | 1 + modules/Mpris.qml | 11 ++--------- modules/Network.qml | 2 +- modules/NetworkMenu.qml | 20 ++++++++++++-------- 6 files changed, 36 insertions(+), 19 deletions(-) diff --git a/modules/Cpu.qml b/modules/Cpu.qml index 58d41e7..8159533 100644 --- a/modules/Cpu.qml +++ b/modules/Cpu.qml @@ -47,6 +47,7 @@ M.BarSection { property M.ProcessList _procs: M.ProcessList { sortBy: "cpu" active: root._showPanel + onProcessesChanged: hoverPanel.keepOpen(300) } on_AnyHoverChanged: { diff --git a/modules/HoverPanel.qml b/modules/HoverPanel.qml index fb84511..47f6dc3 100644 --- a/modules/HoverPanel.qml +++ b/modules/HoverPanel.qml @@ -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() } diff --git a/modules/Memory.qml b/modules/Memory.qml index 5d8b7a0..c9df8bc 100644 --- a/modules/Memory.qml +++ b/modules/Memory.qml @@ -24,6 +24,7 @@ M.BarSection { property M.ProcessList _procs: M.ProcessList { sortBy: "mem" active: root._showPanel + onProcessesChanged: hoverPanel.keepOpen(300) } on_AnyHoverChanged: { diff --git a/modules/Mpris.qml b/modules/Mpris.qml index 9d92b91..4fd58ef 100644 --- a/modules/Mpris.qml +++ b/modules/Mpris.qml @@ -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); } } } diff --git a/modules/Network.qml b/modules/Network.qml index ad84331..033c0ab 100644 --- a/modules/Network.qml +++ b/modules/Network.qml @@ -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 diff --git a/modules/NetworkMenu.qml b/modules/NetworkMenu.qml index ad493a2..529458e 100644 --- a/modules/NetworkMenu.qml +++ b/modules/NetworkMenu.qml @@ -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