diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-13 11:22:40 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-13 11:22:40 +0200 |
| commit | 215458d3fcc0bc57e5c2c7245f09bd108a7b461a (patch) | |
| tree | 3ac1773f217568c3fa0f38e36e10c2de6c35e36c /desktop | |
| parent | d4e3dd6d7003271a210e836e227e931d459db5cc (diff) | |
| download | quickshell-215458d3fcc0bc57e5c2c7245f09bd108a7b461a.tar.gz quickshell-215458d3fcc0bc57e5c2c7245f09bd108a7b461a.zip | |
feat(desktop): Prefs holds a pinned public IP
perf.pinnedIp in desktop.json, set from the performance panel's pin
button and written only on change. The address lives in the user's
state file, never in the repo. setControls and setPinnedIp share one
write so both keep keys this version does not know.
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop')
| -rw-r--r-- | desktop/Prefs.qml | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/desktop/Prefs.qml b/desktop/Prefs.qml index d56b34c..c342aba 100644 --- a/desktop/Prefs.qml +++ b/desktop/Prefs.qml @@ -32,13 +32,26 @@ Singleton { // Visible control tiles, in display order. property var controls: Controls.defaults() + // The public IP the user pinned from the performance panel; "" for none. + property string pinnedIp: "" + // The whole parsed object, so a write keeps keys this version does not // know about. property var doc: ({}) function setControls(list) { root.controls = Controls.normalize(list); - const out = Object.assign({}, root.doc, { controls: root.controls }); + root.write(Object.assign({}, root.doc, { controls: root.controls })); + } + + function setPinnedIp(ip) { + if (ip === root.pinnedIp) return; + root.pinnedIp = ip; + const perf = Object.assign({}, root.doc.perf, { pinnedIp: ip }); + root.write(Object.assign({}, root.doc, { perf: perf })); + } + + function write(out) { root.doc = out; file.setText(JSON.stringify(out, null, 2) + "\n"); } @@ -53,6 +66,8 @@ Singleton { const next = "controls" in parsed ? Controls.normalize(parsed.controls) : Controls.defaults(); // The watch also fires on our own write; compare so it is a no-op. if (JSON.stringify(next) !== JSON.stringify(root.controls)) root.controls = next; + const pin = parsed.perf && typeof parsed.perf.pinnedIp === "string" ? parsed.perf.pinnedIp : ""; + if (pin !== root.pinnedIp) root.pinnedIp = pin; } FileView { @@ -67,6 +82,6 @@ Singleton { onFileChanged: reload() onLoaded: root.reparse() // Missing file: the defaults, and nothing written. - onLoadFailed: { root.doc = {}; root.controls = Controls.defaults(); } + onLoadFailed: { root.doc = {}; root.controls = Controls.defaults(); root.pinnedIp = ""; } } } |
