pragma ComponentBehavior: Bound import QtQuick import Quickshell import Quickshell.Io import Quickshell.Wayland import "../components" import "../core" import "../services" import "../theme" // Caelestia-style dashboard: tabbed glass panel below the bar. The layer is // sized to the panel (HyprGlass shapes glass from the layer box) and morphs as // tabs of different sizes slide in. // qmllint disable uncreatable-type PanelWindow { // qmllint enable uncreatable-type id: root screen: ScreenService.current(ShellState.dashboardScreen) readonly property var options: ConfigService.ready ? ConfigService.data.dashboard : null readonly property string position: options ? options.position : "top-center" readonly property var tabs: options ? options.tabs.filter(t => t.enabled && !!DashboardRegistry.entry(t.id)).map(t => t.id) : [] readonly property int index: Math.max(0, tabs.indexOf(ShellState.dashboardTab)) readonly property string currentId: tabs[index] || "" readonly property int padding: 16 readonly property real screenWidth: screen ? screen.width : 1920 readonly property real screenHeight: screen ? screen.height : 1080 function select(i) { if (tabs.length) ShellState.dashboardTab = tabs[(i + tabs.length) % tabs.length]; } // Top placements hang from the bar as a drawer; "center" floats. readonly property bool attached: position !== "center" anchors { top: root.attached left: root.position === "top-left" right: root.position === "top-right" } // 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 { left: BarDrawers.margin + BarDrawers.radius right: BarDrawers.margin + BarDrawers.radius } // qmllint enable unqualified unresolved-type implicitWidth: Math.max(120, Math.round(panel.width)) implicitHeight: Math.max(60, Math.round((attached ? BarDrawers.bottom : 0) + panel.contentHeight)) visible: ShellState.dashboardOpen || panel.shown color: Theme.transparent exclusionMode: ExclusionMode.Ignore WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.namespace: "glassMxrph-dashboard" WlrLayershell.keyboardFocus: ShellState.dashboardOpen ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None Component.onCompleted: ShellState.dashboardWindow = root Component.onDestruction: ShellState.dashboardWindow = null Connections { target: ShellState function onDashboardOpenChanged() { if (!ShellState.dashboardOpen) { PowerService.cancel(); if (root.options && !root.options.rememberTab) ShellState.dashboardTab = ""; } } } onOptionsChanged: if (options && !options.enabled) ShellState.dashboardOpen = false OutsideClick { window: root active: ShellState.dashboardOpen onOutside: ShellState.dashboardOpen = false } // Fallback outside-click catcher (see ControlCenter). MouseArea { objectName: "dashboardOutside" x: -20000 y: -20000 width: 40000 height: 40000 onPressed: ShellState.dashboardOpen = false } BarDrawer { id: panel objectName: "dashboardSurface" y: root.attached ? BarDrawers.bottom : 0 open: ShellState.dashboardOpen attached: root.attached drawerId: "dashboard" screenName: root.screen ? root.screen.name : "" screenX: root.position === "top-left" ? BarDrawers.margin + BarDrawers.radius : root.position === "top-right" ? root.screenWidth - BarDrawers.margin - BarDrawers.radius - width : (root.screenWidth - width) / 2 readonly property Loader page: { pages.count; return pages.itemAt(root.index) as Loader; } readonly property Item pageItem: page ? page.item as Item : null readonly property real pageWidth: pageItem ? pageItem.implicitWidth : 600 readonly property real pageHeight: pageItem ? pageItem.implicitHeight : 300 readonly property bool morph: progress > 0.05 && Theme.duration > 0 readonly property real sideSpace: 2 * (BarDrawers.margin + BarDrawers.radius + ear) contentWidth: Math.min(root.screenWidth - sideSpace, pageWidth + 2 * root.padding) contentHeight: Math.min(root.screenHeight - BarDrawers.bottom - 20, tabBar.height + pageHeight + 3 * root.padding) Behavior on contentWidth { enabled: panel.morph NumberAnimation { duration: Theme.duration * 1.4 easing.type: Easing.BezierSpline easing.bezierCurve: [0.2, 0, 0, 1, 1, 1] } } Behavior on contentHeight { enabled: panel.morph NumberAnimation { duration: Theme.duration * 1.4 easing.type: Easing.BezierSpline easing.bezierCurve: [0.2, 0, 0, 1, 1, 1] } } focus: ShellState.dashboardOpen Keys.onEscapePressed: ShellState.dashboardOpen = false Keys.onLeftPressed: root.select(root.index - 1) Keys.onRightPressed: root.select(root.index + 1) Keys.onTabPressed: root.select(root.index + 1) Keys.onBacktabPressed: root.select(root.index - 1) Keys.onPressed: event => { const n = event.key - Qt.Key_1; if (n >= 0 && n < root.tabs.length) { root.select(n); event.accepted = true; } } Item { id: tabBar objectName: "dashboardTabs" x: root.padding y: root.padding width: panel.contentWidth - 2 * root.padding height: 46 readonly property real tabWidth: root.tabs.length ? width / root.tabs.length : width Row { anchors.fill: parent Repeater { model: root.tabs Item { id: tab required property string modelData required property int index readonly property var entry: DashboardRegistry.entry(modelData) readonly property bool current: root.index === index objectName: "dashTab-" + modelData width: tabBar.tabWidth height: tabBar.height - 4 Rectangle { anchors.fill: parent anchors.margins: 2 radius: height / 2 color: tabArea.containsMouse && !tab.current ? Theme.hover : Theme.transparent Behavior on color { ColorAnimation { duration: Theme.duration / 2 } } } Row { anchors.centerIn: parent spacing: 8 Text { anchors.verticalCenter: parent.verticalCenter text: Icons.available ? tab.entry.glyph : tab.entry.fallback font.family: Icons.available ? Icons.family : "" font.pixelSize: 16 color: tab.current ? Theme.accentVivid : Theme.textSecondary Behavior on color { ColorAnimation { duration: Theme.duration } } } Text { anchors.verticalCenter: parent.verticalCenter text: tab.entry.title font.pixelSize: 13 font.weight: tab.current ? Font.DemiBold : Font.Normal color: tab.current ? Theme.text : Theme.textSecondary } } MouseArea { id: tabArea anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: root.select(tab.index) onWheel: event => root.select(root.index + (event.angleDelta.y < 0 ? 1 : -1)) } Accessible.role: Accessible.PageTab Accessible.name: entry.title } } } Rectangle { id: indicator anchors.bottom: parent.bottom height: 3 radius: 1.5 width: Math.min(tabBar.tabWidth * 0.5, 72) x: tabBar.tabWidth * root.index + (tabBar.tabWidth - width) / 2 color: Theme.accentVivid Behavior on x { enabled: panel.morph NumberAnimation { duration: Theme.duration * 1.3 easing.type: Easing.OutCubic } } } Rectangle { anchors.top: parent.bottom anchors.topMargin: 0 width: parent.width height: 1 color: Theme.hairline } } // Pages sit side by side; the strip slides to the current one. Item { id: viewport objectName: "dashboardViewport" x: root.padding y: tabBar.y + tabBar.height + root.padding width: panel.contentWidth - 2 * root.padding height: panel.contentHeight - y - root.padding clip: true Row { id: strip spacing: root.padding * 2 x: panel.page ? -panel.page.x : 0 Behavior on x { enabled: panel.morph NumberAnimation { duration: Theme.duration * 1.3 easing.type: Easing.OutCubic } } Repeater { id: pages model: root.tabs Loader { id: pageLoader required property string modelData required property int index objectName: "dashPage-" + modelData active: ShellState.dashboardOpen || panel.visible source: DashboardRegistry.entry(modelData).source // Off-screen tabs fade so the slide reads as a swap. opacity: root.index === index ? 1 : 0.25 Behavior on opacity { NumberAnimation { duration: Theme.duration } } onLoaded: { item.current = Qt.binding(() => ShellState.dashboardOpen && root.index === pageLoader.index); if ("showEqualizer" in item) item.showEqualizer = Qt.binding(() => !!root.options && root.options.easyEffects); } } } } } } IpcHandler { target: "dashboard" function toggle(tab: string): void { ShellState.toggleDashboard(tab); } function open(tab: string): void { ShellState.openDashboard(tab); } function close(): void { ShellState.dashboardOpen = false; } function status(): string { return JSON.stringify({ open: ShellState.dashboardOpen, visible: root.visible, tab: root.currentId, tabs: root.tabs, position: root.position, screen: root.screen ? root.screen.name : "", width: root.implicitWidth, height: root.implicitHeight }); } } }