Extract panels out into their own top-level concern
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
|
||||
// Base item for shell panels. Panels are not bar widgets, but the bar may host
|
||||
// or toggle them and injects the same ambient context while doing so. The base
|
||||
// owns the shared IPC-backed open/close lifecycle; panel implementations own
|
||||
// their button behavior, keyboard navigation, and content.
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property QtObject bar: null
|
||||
property string moduleName: ""
|
||||
property var settings: ({})
|
||||
property string ipcTarget: ""
|
||||
property bool manageIpc: true
|
||||
property alias controller: panelController
|
||||
|
||||
readonly property bool opened: panelController.open
|
||||
|
||||
function open() { panelController.show() }
|
||||
function close() { panelController.hide() }
|
||||
function toggle() { opened ? close() : open() }
|
||||
|
||||
PanelController {
|
||||
id: panelController
|
||||
}
|
||||
|
||||
property IpcHandler _ipc: manageIpc ? ipcComponent.createObject(root) : null
|
||||
|
||||
property Component ipcComponent: Component {
|
||||
IpcHandler {
|
||||
target: root.ipcTarget
|
||||
function open(): void { root.open() }
|
||||
function close(): void { root.close() }
|
||||
function show(): void { root.open() }
|
||||
function hide(): void { root.close() }
|
||||
function toggle(): void { root.toggle() }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user