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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
// 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 QtQuick
import "../.."
import "Hypr.js" as H
// One row per option: its name, its value (in the accent when it differs
// from Hyprland's default, colours as swatches), and what it does. Filters
// for everything, what the config sets, and what differs from the default.
// Clicking a row opens it: the whole description, the default and range,
// and an editor shaped by the type: true/false and an enum's names as
// choices, anything else as a Lua expression started from the value.
Column {
id: page
required property QtObject mod
property string filter: "all"
property string query: ""
property string editing: ""
property string draft: ""
property string error: ""
property bool busy: false
spacing: 10
readonly property var all: page.mod.descs.map(d => {
const o = page.mod.values[d.name];
return { d: d, o: o, set: !!(o && o.set), changed: H.changed(d, o), over: page.mod.overridden.includes(d.name) };
})
readonly property int setCount: page.all.filter(r => r.set).length
readonly property int changedCount: page.all.filter(r => r.changed).length
readonly property var shown: {
const q = page.query.trim().toLowerCase();
return page.all.filter(r => (page.filter === "all" || (page.filter === "set" ? r.set : r.changed))
&& (q === "" || r.d.name.toLowerCase().includes(q) || r.d.description.toLowerCase().includes(q)));
}
function toggle(r) {
page.error = "";
if (page.editing === r.d.name) { page.editing = ""; return; }
page.editing = r.d.name;
page.draft = r.o ? H.lua(r.o) : "";
}
function apply(name, expr) {
if (page.busy) return;
page.busy = true;
page.error = "";
page.mod.set(name, expr, err => {
page.busy = false;
page.error = err;
if (err === "") page.draft = expr;
});
}
component Small: Text {
color: Theme.subtext
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
elide: Text.ElideRight
}
component OptionRow: Column {
id: or
required property var row
readonly property bool open: page.editing === or.row.d.name
readonly property string kind: H.kind(or.row.o)
readonly property var choices: or.kind === "bool"
? [{ name: "true", v: true }, { name: "false", v: false }]
: or.kind === "int" ? H.choices(or.row.d) : []
objectName: "opt:" + or.row.d.name
width: page.width
spacing: 6
Item {
width: parent.width
height: 30
Rectangle {
anchors.fill: parent
radius: 6
color: rowArea.containsMouse || or.open ? Qt.alpha(Theme.accent, 0.12) : "transparent"
}
Text {
x: 8
width: parent.width * 0.36 - 16
anchors.verticalCenter: parent.verticalCenter
elide: Text.ElideRight
textFormat: Text.StyledText
// The section faded, the option itself bright.
readonly property int cut: or.row.d.name.lastIndexOf(":") + 1
text: "<font color='" + Theme.subtext + "'>" + or.row.d.name.slice(0, cut) + "</font>" + or.row.d.name.slice(cut)
color: Theme.text
font { family: Theme.iconFamily; pixelSize: Theme.fontSize - 3 }
}
Row {
x: parent.width * 0.36
width: parent.width * 0.26 - 12
anchors.verticalCenter: parent.verticalCenter
spacing: 4
clip: true
Repeater {
model: H.colors(or.row.o)
Rectangle {
required property string modelData
anchors.verticalCenter: parent.verticalCenter
width: 10; height: 10; radius: 2
color: modelData
}
}
Text {
text: H.show(or.row.d, or.row.o)
color: or.row.changed ? Theme.accent : Theme.subtext
font { family: Theme.iconFamily; pixelSize: Theme.fontSize - 3; bold: or.row.changed }
}
}
Small {
x: parent.width * 0.62
width: parent.width * 0.38 - 8
anchors.verticalCenter: parent.verticalCenter
text: (or.row.over ? "● " : "") + or.row.d.description
}
MouseArea {
id: rowArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: page.toggle(or.row)
}
}
Column {
visible: or.open
x: 8
width: parent.width - 16
spacing: 6
bottomPadding: 8
Text {
width: parent.width
wrapMode: Text.Wrap
text: or.row.d.description
color: Theme.text
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
}
Small {
width: parent.width
wrapMode: Text.Wrap
text: "Default " + H.show(or.row.d, { [or.kind || "str"]: or.row.d.default })
+ (or.row.d.min !== undefined && or.row.d.min !== null ? ", from " + or.row.d.min + " to " + or.row.d.max : "")
+ (or.row.over ? ". Set by keystone.lua."
: or.row.set ? ". Set in your config: a change here overrides it from keystone.lua." : ".")
}
// true/false, or an enum's names.
Flow {
visible: or.choices.length > 0
width: parent.width
spacing: 6
Repeater {
model: or.choices
Chip {
required property var modelData
text: modelData.name
selected: or.row.o && or.row.o[or.kind] === modelData.v
onClicked: if (!selected) page.apply(or.row.d.name, String(modelData.v))
}
}
}
Item {
visible: or.choices.length === 0 && or.kind !== ""
width: parent.width
height: 32
Field {
anchors { left: parent.left; right: applyBtn.left; rightMargin: 8 }
mono: true
text: page.draft
onEdited: t => page.draft = t
onAccepted: page.apply(or.row.d.name, page.draft)
}
Button {
id: applyBtn
anchors { right: parent.right; verticalCenter: parent.verticalCenter }
text: page.busy ? "Checking…" : "Apply"
enabled: !page.busy && page.draft.trim() !== ""
onClicked: page.apply(or.row.d.name, page.draft)
}
}
Small {
width: parent.width
visible: page.error !== ""
wrapMode: Text.Wrap
color: Theme.red
text: page.error
}
Button {
visible: or.row.over
text: "Reset, drop the keystone.lua line"
onClicked: page.mod.reset(or.row.d.name)
}
}
}
Small {
width: parent.width
wrapMode: Text.Wrap
text: page.all.length + " options, live from Hyprland. Your config sets " + page.setCount + ", and "
+ page.changedCount + " differ from the default. Click one to see more, or change it."
}
Item {
width: parent.width
height: 32
Field {
id: search
width: parent.width * 0.3
text: page.query
placeholder: "Search options"
onEdited: t => page.query = t
}
Row {
anchors { left: search.right; leftMargin: 12; verticalCenter: parent.verticalCenter }
spacing: 6
Chip { text: "Everything · " + page.all.length; selected: page.filter === "all"; onClicked: page.filter = "all" }
Chip { text: "Set in your config · " + page.setCount; selected: page.filter === "set"; onClicked: page.filter = "set" }
Chip { text: "Changed from default · " + page.changedCount; selected: page.filter === "changed"; onClicked: page.filter = "changed" }
}
}
Item {
width: parent.width
height: 20
Small { x: 8; text: "Option" }
Small { x: parent.width * 0.36; text: "Value" }
Small { x: parent.width * 0.62; text: "What it does" }
}
Repeater {
model: page.shown
OptionRow {
required property var modelData
row: modelData
}
}
Small {
width: parent.width
wrapMode: Text.Wrap
text: "Values in the accent differ from Hyprland's default; faded ones are the default. Colours show as swatches. "
+ "● marks an option set from this page, in sections/keystone.lua."
}
}
|