1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
import Quickshell
import QtQuick
// The settings window: a normal toplevel, not a layer surface, so Hyprland
// tiles or floats it like any app. The drawer is the quick area; things set
// once and left alone live here. It hosts the pages of the modules that
// declare `settings: true`, from the same module list as the drawer, with a
// list of them down the left.
Scope {
id: root
property list<QtObject> modules
property bool open: false
property string page: ""
readonly property var pages: {
const out = [];
for (let i = 0; i < root.modules.length; i++)
if (root.modules[i].settings) out.push(root.modules[i]);
return out;
}
// Null is the landing page.
readonly property QtObject current: root.pages.find(m => m.name === root.page) ?? null
// An unknown or empty name opens the landing page.
function show(name) { root.page = name; root.open = true; }
// One step out: a page to the landing page, the landing page closes.
function back() {
if (root.current) root.page = "";
else root.close();
}
function close() { root.open = false; root.page = ""; }
LazyLoader {
active: root.open
FloatingWindow {
title: "Settings"
implicitWidth: 900
implicitHeight: 640
color: Theme.base
onClosed: root.close()
Item {
anchors.fill: parent
focus: true
Keys.onEscapePressed: root.back()
ListView {
id: side
anchors { top: parent.top; left: parent.left; bottom: parent.bottom; margins: 12 }
width: 200
spacing: 4
model: root.pages
delegate: Rectangle {
id: entry
required property QtObject modelData
readonly property bool selected: root.current === modelData
width: side.width
height: 36
radius: 8
color: selected ? Qt.alpha(Theme.accent, 0.22)
: area.containsMouse ? Qt.alpha(Theme.text, 0.06) : "transparent"
Row {
anchors { left: parent.left; leftMargin: 10; verticalCenter: parent.verticalCenter }
spacing: 10
Text {
text: entry.modelData.icon
font { family: Theme.iconFamily; pixelSize: Theme.fontSize }
color: Theme.text
}
Text {
text: entry.modelData.label
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
color: Theme.text
}
}
MouseArea {
id: area
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.page = entry.modelData.name
}
}
}
Rectangle {
id: rule
anchors { top: parent.top; bottom: parent.bottom; left: side.right; leftMargin: 12 }
width: 1
color: Qt.alpha(Theme.text, 0.12)
}
// The landing page: every settings page as a tile, as the
// drawer's grid shows its modules. Where back returns to.
Item {
anchors { top: parent.top; right: parent.right; bottom: parent.bottom; left: rule.right; margins: 16 }
visible: root.current === null
Text {
id: landingTitle
height: 44
verticalAlignment: Text.AlignVCenter
text: "Settings"
font { family: Theme.fontFamily; pixelSize: Theme.fontSize + 2; bold: true }
color: Theme.text
}
Flow {
id: landing
anchors { top: landingTitle.bottom; topMargin: 12; left: parent.left; right: parent.right }
spacing: 10
Repeater {
model: root.pages
Tile {
required property QtObject modelData
width: (landing.width - 2 * landing.spacing) / 3
icon: modelData.icon
label: modelData.label
onClicked: root.page = modelData.name
}
}
}
}
Loader {
id: pageLoader
anchors { top: parent.top; right: parent.right; bottom: parent.bottom; left: rule.right; margins: 16 }
sourceComponent: root.current?.page ?? null
// The Page's back arrow steps out to the landing page,
// dismiss closes the window, and go() moves to another
// settings page by name.
onLoaded: {
if (item && item.back) item.back.connect(root.back);
if (item && item.dismiss) item.dismiss.connect(root.close);
if (item && item.go) item.go.connect(name => root.page = name);
}
Binding {
target: pageLoader.item
property: "icon"
value: root.current ? root.current.icon : ""
when: pageLoader.item !== null
}
}
}
}
}
}
|