pragma ComponentBehavior: Bound import QtQuick import QtQuick.Controls import QtQuick.Layouts import Quickshell import Quickshell.Io import Quickshell.Wayland import "../components" import "../services" import "../core" import "../theme" // macOS-style Control Center. The layer surface is sized to the panel so // compositor glass (HyprGlass) shapes its edges to the panel, not the screen. // qmllint disable uncreatable-type PanelWindow { id: root screen: ScreenService.current(ShellState.controlCenterScreen) anchors { top: true right: true } readonly property int screenWidth: screen ? screen.width : 1920 readonly property int screenHeight: screen ? screen.height : 1080 // Drops out of the bar's right side; the right ear stays on its straight edge. readonly property real rightInset: BarDrawers.margin + BarDrawers.radius // Panel position on the output, for tests and diagnostics. readonly property real panelScreenX: screenWidth - rightInset - width + panel.ear readonly property real panelScreenY: BarDrawers.bottom // The layer starts at the screen top so the bar join is inside its box. // Margins is present at runtime but unresolved in 0.3.1 qmltypes. // qmllint disable unqualified unresolved-type margins { right: root.rightInset } // qmllint enable unqualified unresolved-type implicitWidth: Math.round(panel.width) implicitHeight: Math.round(BarDrawers.bottom + panel.contentHeight) visible: ShellState.controlCenterOpen || panel.shown color: Theme.transparent exclusionMode: ExclusionMode.Ignore WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.namespace: "glassMxrph-controlcenter" WlrLayershell.keyboardFocus: ShellState.controlCenterOpen ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None Component.onCompleted: ShellState.controlCenterWindow = root Component.onDestruction: ShellState.controlCenterWindow = null // Connectivity and the small tiles share one block (connectivity left, tiles // stacked right), placed where the first of them appears; other modules // span the full width in their configured order. readonly property var smallTiles: ["dnd", "nightLight", "profiles"] readonly property var blocks: { if (!ConfigService.ready) return []; const ids = ConfigService.data.controlCenter.modules.filter(m => m.enabled && !!ControlRegistry.entry(m.id)).map(m => m.id); const grouped = ids.filter(id => id === "connectivity" || smallTiles.includes(id)); const result = []; let placed = false; for (const id of ids) { if (!grouped.includes(id)) { result.push({ kind: "full", ids: [id] }); } else if (!placed) { placed = true; const tiles = grouped.filter(g => g !== "connectivity"); if (!grouped.includes("connectivity")) result.push({ kind: "grid", ids: tiles }); else if (tiles.length === 0) result.push({ kind: "full", ids: ["connectivity"] }); else result.push({ kind: "split", ids: tiles }); } } return result; } component ModuleSlot: Loader { property string moduleId Layout.fillWidth: true Layout.preferredWidth: 1 active: ShellState.controlCenterOpen source: moduleId ? ControlRegistry.entry(moduleId).source : "" } component HeaderButton: Rectangle { id: headerButton property string glyph property string fallback signal clicked implicitWidth: 28 implicitHeight: 28 radius: 14 color: headerArea.containsMouse ? Qt.alpha(Theme.text, 0.12) : Theme.transparent Accessible.role: Accessible.Button GlassIcon { anchors.centerIn: parent size: 28 glyphSize: 14 glyph: headerButton.glyph fallback: headerButton.fallback color: Theme.transparent border.width: 0 glyphColor: Theme.textSecondary } MouseArea { id: headerArea anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: headerButton.clicked() } } // Hyprland routes every pointer event to a layer with exclusive keyboard // focus, so clicks outside the panel arrive here with out-of-bounds // coordinates. Qt Quick still delivers them to items extending past the // window, so this catcher (behind the panel) dismisses on outside clicks. MouseArea { objectName: "controlCenterOutside" x: -20000 y: -20000 width: 40000 height: 40000 onPressed: ShellState.controlCenterOpen = false } BarDrawer { id: panel objectName: "controlCenterSurface" readonly property real targetWidth: Math.min(ConfigService.ready ? ConfigService.data.controlCenter.width : 400, root.screenWidth - 2 * root.rightInset - 2 * ear) readonly property real targetHeight: Math.min(content.implicitHeight + 28, root.screenHeight - BarDrawers.bottom - 20) y: BarDrawers.bottom open: ShellState.controlCenterOpen contentWidth: targetWidth contentHeight: targetHeight drawerId: "controlcenter" screenName: root.screen ? root.screen.name : "" screenX: root.screenWidth - root.rightInset - width focus: open onOpenChanged: if (open) forceActiveFocus() Keys.onEscapePressed: { if (PowerService.pending) PowerService.cancel(); else ShellState.controlCenterOpen = false; } Behavior on contentHeight { enabled: panel.settled NumberAnimation { duration: Theme.duration easing.type: Easing.OutCubic } } MouseArea { anchors.fill: parent } ScrollView { anchors.fill: parent anchors.margins: 14 clip: true contentWidth: panel.targetWidth - 28 ColumnLayout { id: content width: panel.targetWidth - 28 spacing: 10 RowLayout { Layout.fillWidth: true Layout.leftMargin: 4 spacing: 2 Text { text: "Control Center" color: Theme.text font.pixelSize: 14 font.weight: Font.DemiBold Layout.fillWidth: true } HeaderButton { glyph: "󰒓" fallback: "⚙" onClicked: ShellState.openSettings("controlcenter") Accessible.name: "Control Center settings" } HeaderButton { glyph: "󰅖" fallback: "×" onClicked: ShellState.controlCenterOpen = false Accessible.name: "Close Control Center" } } Repeater { model: root.blocks Item { id: block required property var modelData Layout.fillWidth: true implicitHeight: block.modelData.kind === "full" ? full.implicitHeight : block.modelData.kind === "split" ? split.implicitHeight : grid.implicitHeight ModuleSlot { id: full visible: block.modelData.kind === "full" width: parent.width moduleId: block.modelData.kind === "full" ? block.modelData.ids[0] : "" active: visible && ShellState.controlCenterOpen } RowLayout { id: split visible: block.modelData.kind === "split" width: parent.width spacing: 10 ModuleSlot { moduleId: "connectivity" active: split.visible && ShellState.controlCenterOpen Layout.fillHeight: true } ColumnLayout { Layout.fillWidth: true Layout.preferredWidth: 1 Layout.alignment: Qt.AlignTop spacing: 10 Repeater { model: block.modelData.kind === "split" ? block.modelData.ids : [] ModuleSlot { required property string modelData moduleId: modelData } } } } GridLayout { id: grid visible: block.modelData.kind === "grid" width: parent.width columns: 2 columnSpacing: 10 rowSpacing: 10 Repeater { model: block.modelData.kind === "grid" ? block.modelData.ids : [] ModuleSlot { required property string modelData moduleId: modelData } } } } } Text { visible: SystemService.acting text: "Updating system controls…" color: Theme.textSecondary font.pixelSize: 11 Layout.fillWidth: true Layout.leftMargin: 4 } Text { visible: !!SystemService.error text: SystemService.error color: Theme.urgent font.pixelSize: 11 wrapMode: Text.Wrap Layout.fillWidth: true Layout.leftMargin: 4 } GlassButton { visible: root.blocks.length === 0 text: "Add modules" onClicked: ShellState.openSettings("controlcenter") } } } } IpcHandler { target: "controlcenter" function toggle(): void { ShellState.toggleControlCenter(); } function open(): void { ShellState.openControlCenter(); } function close(): void { ShellState.controlCenterOpen = false; } function status(): string { return JSON.stringify({ opened: ShellState.controlCenterOpen, screen: root.screen ? root.screen.name : "", busy: SystemService.busy, error: SystemService.error, pendingPower: PowerService.pending }); } } }