aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/Prefs.qml
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/Prefs.qml')
-rw-r--r--desktop/Prefs.qml19
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 = ""; }
}
}