From 215458d3fcc0bc57e5c2c7245f09bd108a7b461a Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 13 Oct 2026 11:22:40 +0200 Subject: 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 --- desktop/Prefs.qml | 19 +++++++++++++++++-- 1 file 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 = ""; } } } -- cgit v1.2.3