barmodule: own hoverpanel internally, modules supply content as component

This commit is contained in:
Damocles 2026-04-25 14:07:26 +02:00
parent 26476dc930
commit 6fd36c812f
17 changed files with 367 additions and 453 deletions

View file

@ -9,10 +9,9 @@ import "../services" as S
// On tap: toggles _panelOpen and emits tapped(). Modules that want custom tap
// behavior connect onTapped to their action (the toggle still happens).
//
// Modules with a HoverPanel bind:
// M.HoverPanel { showPanel: root._showPanel; onDismissed: root.dismissPanel() }
//
// Modules without a panel need nothing - the toggle is a harmless no-op.
// Panel modules set panelComponent + panel config properties. BarModule owns the
// HoverPanel internally - modules never interact with it directly.
// For content resize grace, call keepPanelOpen(ms).
Row {
id: root
property string tooltip: ""
@ -25,6 +24,13 @@ Row {
property bool _osdActive: false
readonly property bool _showPanel: _panelOpen || _osdActive
// Panel configuration - set by modules that have applets
property Component panelComponent: null
property string panelTitle: ""
property string panelNamespace: "nova-panel"
property real panelContentWidth: 220
property Component titleActionsComponent: null
signal tapped
function flashPanel() {
@ -38,6 +44,11 @@ Row {
_osdTimer.stop();
}
function keepPanelOpen(ms) {
if (_panelLoader.item)
_panelLoader.item.keepOpen(ms);
}
Timer {
id: _osdTimer
interval: 1500
@ -81,4 +92,27 @@ Row {
duration: 150
}
}
// HoverPanel - only created when module provides panelComponent
LazyLoader {
id: _panelLoader
active: root.panelComponent !== null
M.HoverPanel {
showPanel: root._showPanel
screen: QsWindow.window?.screen ?? null
anchorItem: root
accentColor: root.accentColor
panelNamespace: root.panelNamespace
panelTitle: root.panelTitle
contentWidth: root.panelContentWidth
titleActionsComponent: root.titleActionsComponent
onDismissed: root.dismissPanel()
Loader {
width: root.panelContentWidth
sourceComponent: root.panelComponent
}
}
}
}