import QtQuick import Quickshell import Quickshell.Wayland import "../../../components" as C import "../../../core" as Core import "../../../services" as GS // Hosts a Noctalia v4 plugin's Panel.qml as a glassMxrph bar drawer: it grows // out of the bar under the button that opened it, sized from the panel's // contentPreferredWidth/Height. Escape or an outside click closes it. PanelWindow { id: root required property var api property url source: "" readonly property bool open: !!api && !!api.panelOpenScreen // Lets test drivers find this panel. Component.onCompleted: GS.PluginService.panelWindows[api.pluginId] = root // Keep the last screen while the drawer animates closed. property var lastScreen: null onOpenChanged: { if (open) lastScreen = api.panelOpenScreen; else GS.PluginService.releasePopout(api); } screen: open ? api.panelOpenScreen : lastScreen readonly property Item anchorItem: api && api.panelAnchor ? api.panelAnchor : null readonly property var anchorWindow: anchorItem && anchorItem.QsWindow ? anchorItem.QsWindow.window : null readonly property bool fromBar: !!anchorWindow && GS.TrayService.barWindows.includes(anchorWindow) readonly property real screenW: screen ? screen.width : 1920 readonly property real screenH: screen ? screen.height : 1080 readonly property real anchorCenter: { root.open; if (!fromBar) return screenW / 2; const p = anchorItem.mapToItem(anchorWindow.contentItem, anchorItem.width / 2, 0); return p.x; } readonly property Item panel: loader.item readonly property var panelObject: loader.item readonly property real preferredWidth: panelObject && panelObject.contentPreferredWidth > 0 ? panelObject.contentPreferredWidth : 400 readonly property real preferredHeight: panelObject && panelObject.contentPreferredHeight > 0 ? panelObject.contentPreferredHeight : 320 readonly property real drawerX: Core.BarDrawers.clampX(anchorCenter, drawer.width, screenW) anchors { top: true left: true } // qmllint disable unqualified unresolved-type margins.left: root.drawerX // qmllint enable unqualified unresolved-type implicitWidth: Math.max(1, Math.round(drawer.width)) implicitHeight: Math.max(1, Math.round(Core.BarDrawers.bottom + drawer.contentHeight)) visible: open || drawer.shown color: "transparent" exclusionMode: ExclusionMode.Ignore WlrLayershell.namespace: "glassMxrph-plugin-panel" WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.keyboardFocus: open ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None C.OutsideClick { window: root active: root.open onOutside: root.api.closePanel(null) } MouseArea { x: -20000 y: -20000 width: 40000 height: 40000 enabled: root.open onPressed: root.api.closePanel(null) } C.BarDrawer { id: drawer objectName: "noctaliaPanelSurface" y: Core.BarDrawers.bottom open: root.open contentWidth: Math.min(root.preferredWidth, root.screenW - 2 * (Core.BarDrawers.margin + Core.BarDrawers.radius + ear)) contentHeight: Math.min(root.preferredHeight, root.screenH - Core.BarDrawers.bottom - 20) drawerId: "noctalia-panel-" + (root.api ? root.api.pluginId : "") screenName: root.screen ? root.screen.name : "" screenX: root.drawerX sourceScreenX: root.fromBar ? root.anchorCenter : -1 focus: root.open Keys.onEscapePressed: root.api.closePanel(null) MouseArea { anchors.fill: parent acceptedButtons: Qt.AllButtons } Loader { id: loader anchors.fill: parent active: root.open || drawer.shown onActiveChanged: if (active) setSource(root.source, { pluginApi: root.api }) onLoaded: { if ("screen" in item) item.screen = Qt.binding(() => root.screen); } } } }