diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-17 10:10:42 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-17 10:10:42 +0200 |
| commit | e5399f3e8d8572f1db7c4391a7c571d4845500f1 (patch) | |
| tree | fd826694491f7f7973cd077513461ba4dd7f9827 /desktop/Prefs.qml | |
| parent | c832b66159e52503ca3da4b8f9fa7d32dbd28353 (diff) | |
| download | quickshell-e5399f3e8d8572f1db7c4391a7c571d4845500f1.tar.gz quickshell-e5399f3e8d8572f1db7c4391a7c571d4845500f1.zip | |
desktop: centred About, and a resizable settings sidebar
The About text sat in the top-left corner of an otherwise empty page; it
is now centred both ways in the space beside the sidebar.
The sidebar's edge, the rule between it and the page, drags to resize it
between 160 and 420px, lit in the accent while hovered. The width lives
in Prefs, written once on release rather than on every pixel of the
drag, so it survives a restart without a file to edit by hand.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/Prefs.qml')
| -rw-r--r-- | desktop/Prefs.qml | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/desktop/Prefs.qml b/desktop/Prefs.qml index def720c..1cc83cd 100644 --- a/desktop/Prefs.qml +++ b/desktop/Prefs.qml @@ -35,6 +35,11 @@ Singleton { // (assistant/Presets.js, which also validates what is read here). property var presets: null + // The settings window's sidebar width, dragged by its edge. + readonly property int sidebarMin: 160 + readonly property int sidebarMax: 420 + property int settingsSidebar: 200 + // The whole parsed object, so a write keeps keys this version does not // know about. property var doc: ({}) @@ -59,6 +64,14 @@ Singleton { root.write(Object.assign({}, root.doc, { assistant: a })); } + function setSettingsSidebar(w) { + w = Math.round(Math.max(root.sidebarMin, Math.min(root.sidebarMax, w))); + if (w === root.settingsSidebar) return; + root.settingsSidebar = w; + const s = Object.assign({}, root.doc.settings, { sidebar: w }); + root.write(Object.assign({}, root.doc, { settings: s })); + } + function write(out) { root.doc = out; file.setText(JSON.stringify(out, null, 2) + "\n"); @@ -75,6 +88,9 @@ Singleton { if (pin !== root.pinnedIp) root.pinnedIp = pin; root.presets = parsed.assistant && parsed.assistant.presets !== undefined ? parsed.assistant.presets : null; + const w = parsed.settings ? parsed.settings.sidebar : undefined; + root.settingsSidebar = typeof w === "number" && w >= root.sidebarMin && w <= root.sidebarMax + ? Math.round(w) : 200; } FileView { @@ -89,6 +105,6 @@ Singleton { onFileChanged: reload() onLoaded: root.reparse() // Missing file: the defaults, and nothing written. - onLoadFailed: { root.doc = {}; root.pinnedIp = ""; root.presets = null; } + onLoadFailed: { root.doc = {}; root.pinnedIp = ""; root.presets = null; root.settingsSidebar = 200; } } } |
