pragma ComponentBehavior: Bound import QtQuick import QtQuick.Controls import Quickshell import Quickshell.Hyprland import "../components" import "../services" import "../theme" import "../core" PopupWindow { id: root readonly property var group: DockState.group property bool contentOpen: false property int selectedIndex: -1 readonly property var rows: { if (!group) return []; if (DockState.chooser) return chooser.rows; let rows = []; if (group.entry) rows.push({ id: "open", text: "Open", kind: "open", enabled: true }); rows = rows.concat(chooser.rows); if (group.entry && group.entry.actions.length) { rows.push({ id: "actions-separator", separator: true }); for (const action of group.entry.actions) rows.push({ id: "action:" + action.id, text: action.name, kind: "action", action: action, enabled: true }); } rows.push({ id: "pin-separator", separator: true }); if (group.pinned) rows.push({ id: "unpin", text: "Unpin", kind: "unpin", enabled: true }); else if (group.entry) rows.push({ id: "pin", text: "Pin to dock", kind: "pin", enabled: true }); if (group.windows.length) { rows.push({ id: "close-separator", separator: true }); for (const window of group.windows) rows.push({ id: "close:" + window.address, text: "Close ยท " + (window.title || group.name), kind: "close", address: window.address, enabled: true }); } return rows; } function invoke(index) { const row = rows[index]; if (!row || row.separator || !row.enabled || !group) return; const entry = group.entry; DockState.close(); if (row.kind === "focus") Qt.callLater(() => HyprlandService.focusWindow(row.address)); else if (row.kind === "close") HyprlandService.closeWindow(row.address); else if (row.kind === "open" || row.kind === "action") { if (!ApplicationsService.launch(entry, row.action || null)) ShellState.openSettings("dock"); } else if (row.kind === "pin") DockModel.pin(group.id); else if (row.kind === "unpin") DockModel.unpin(group.id); } function move(direction) { const start = selectedIndex < 0 ? (direction > 0 ? -1 : 0) : selectedIndex; for (let i = 1; i <= rows.length; i++) { const n = (start + direction * i + rows.length) % rows.length; if (!rows[n].separator) { selectedIndex = n; list.positionViewAtIndex(n, ListView.Contain); return; } } } anchor.item: DockState.anchorItem // Quickshell 0.3.1 exports the enums but omits flags types from metadata. // qmllint disable missing-type anchor.edges: DockModel.options.position === "bottom" ? Edges.Top : DockModel.options.position === "left" ? Edges.Right : Edges.Left anchor.gravity: DockModel.options.position === "bottom" ? Edges.Top : DockModel.options.position === "left" ? Edges.Right : Edges.Left anchor.adjustment: PopupAdjustment.Flip | PopupAdjustment.Slide // qmllint enable missing-type color: Theme.transparent implicitWidth: 320 implicitHeight: Math.min(screen ? screen.height - 100 : 600, Math.max(70, list.contentHeight + 28)) visible: DockState.opened || surface.visible Component.onCompleted: DockState.menuWindow = root Component.onDestruction: DockState.menuWindow = null Connections { target: DockState function onOpenedChanged() { root.contentOpen = DockState.opened; if (DockState.opened) { root.selectedIndex = -1; surface.forceActiveFocus(); } } } WindowChooser { id: chooser group: root.group } HyprlandFocusGrab { windows: [root] active: DockState.opened onCleared: DockState.close() } GlassMenu { id: surface anchors.fill: parent anchors.margins: 4 opened: root.contentOpen focus: true Keys.onEscapePressed: DockState.close() Keys.onDownPressed: root.move(1) Keys.onUpPressed: root.move(-1) Keys.onReturnPressed: root.invoke(root.selectedIndex) Keys.onEnterPressed: root.invoke(root.selectedIndex) ListView { id: list objectName: "dockMenuList" anchors.fill: parent clip: true model: root.rows boundsBehavior: Flickable.StopAtBounds ScrollBar.vertical: ScrollBar {} delegate: GlassMenuItem { required property var modelData required property int index width: list.width text: modelData.text || "" separator: !!modelData.separator actionEnabled: modelData.enabled === true selected: root.selectedIndex === index buttonType: modelData.checked ? QsMenuButtonType.RadioButton : QsMenuButtonType.None checkState: modelData.checked ? Qt.Checked : Qt.Unchecked onEntered: root.selectedIndex = index onInvoked: root.invoke(index) } } } }