Krolyxon
Commit 6d5cbb7

Branches

Refs →

aurora.configquickshellauroraControlPanel.qml

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