Krolyxon
Commit d48166e

Branches

Refs →

aurora.configquickshellauroraControlPanel.qml

124 lines · 4.5 KB · QML

1import QtQuick
2import QtQuick.Layouts
3import Quickshell
4import Quickshell.Wayland
5import Quickshell.Hyprland
6
7PanelWindow {
8 id: win
9 property bool opened: false
10 property int tab: 0
11 signal tabRequested(int index)
12 signal closeRequested()
13 signal overlayRequested(string name)
14 signal settingsRequested()
15
16 visible: opened
17 anchors { top: true; right: true }
18 margins { top: 6; right: 8 } // sits just under the bar (bar's exclusive zone is respected)
19 implicitWidth: 440
20 implicitHeight: 720
21 exclusiveZone: 0
22 color: "transparent"
23 WlrLayershell.layer: WlrLayer.Overlay
24 WlrLayershell.namespace: "aurora-panel"
25 WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
26
27 // click anywhere outside to close
28 HyprlandFocusGrab {
29 windows: [win]
30 active: win.opened
31 onCleared: win.closeRequested()
32 }
33
34 readonly property var tabs: [
35 { icon: Theme.iHome, name: "home" },
36 { icon: Theme.iVolHigh, name: "audio" },
37 { icon: Theme.iWifi, name: "net" },
38 { icon: Theme.iBt, name: "bt" },
39 { icon: Theme.iChip, name: "system" },
40 { icon: Theme.iBell, name: "notifs" }
41 ]
42
43 Rectangle {
44 anchors.fill: parent
45 color: Theme.bgA
46 border.width: 2
47 border.color: Theme.accent
48 focus: true
49 Keys.onEscapePressed: win.closeRequested()
50 // Tab / Shift+Tab cycle through the tabs (wraps around)
51 Keys.onTabPressed: win.tabRequested((win.tab + 1) % win.tabs.length)
52 Keys.onBacktabPressed: win.tabRequested((win.tab + win.tabs.length - 1) % win.tabs.length)
53
54 ColumnLayout {
55 anchors.fill: parent
56 anchors.margins: 12
57 spacing: 10
58
59 RowLayout {
60 Layout.fillWidth: true
61 spacing: 2
62
63 Repeater {
64 model: win.tabs
65 delegate: Rectangle {
66 id: tabBtn
67 required property var modelData
68 required property int index
69 readonly property bool current: win.tab === index
70 implicitWidth: lbl.implicitWidth + 22
71 implicitHeight: 28
72 color: current ? Theme.accent : (tm.containsMouse ? Theme.surfaceHi : "transparent")
73
74 Text {
75 id: lbl
76 anchors.centerIn: parent
77 text: tabBtn.current ? tabBtn.modelData.icon + " " + tabBtn.modelData.name : tabBtn.modelData.icon
78 color: tabBtn.current ? Theme.bg : Theme.fg
79 font.family: Theme.font
80 font.pixelSize: Theme.fontSize
81 font.bold: true
82 }
83 Rectangle { // unread badge on the notifs tab
84 visible: tabBtn.modelData.name === "notifs" && Notifs.count > 0 && !tabBtn.current
85 width: 6; height: 6
86 anchors.top: parent.top
87 anchors.right: parent.right
88 anchors.margins: 3
89 color: Theme.accent
90 }
91 MouseArea {
92 id: tm
93 anchors.fill: parent
94 hoverEnabled: true
95 cursorShape: Qt.PointingHandCursor
96 onClicked: win.tabRequested(tabBtn.index)
97 }
98 }
99 }
100 Item { Layout.fillWidth: true }
101 IconBtn { icon: Theme.iCog; implicitHeight: 28; onClicked: win.settingsRequested() }
102 IconBtn { icon: Theme.iClose; implicitHeight: 28; onClicked: win.closeRequested() }
103 }
104
105 Rectangle { Layout.fillWidth: true; Layout.preferredHeight: 1; color: Theme.line }
106
107 StackLayout {
108 Layout.fillWidth: true
109 Layout.fillHeight: true
110 currentIndex: win.tab
111
112 HomePage {
113 onCloseRequested: win.closeRequested()
114 onOverlayRequested: name => win.overlayRequested(name)
115 }
116 AudioPage {}
117 NetPage { active: win.opened && win.tab === 2 }
118 BtPage { active: win.opened && win.tab === 3 }
119 SysPage {}
120 NotifPage {}
121 }
122 }
123 }
124}