diff options
Diffstat (limited to 'desktop/Prefs.qml')
| -rw-r--r-- | desktop/Prefs.qml | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/desktop/Prefs.qml b/desktop/Prefs.qml index fa0dde9..def720c 100644 --- a/desktop/Prefs.qml +++ b/desktop/Prefs.qml @@ -31,6 +31,10 @@ Singleton { // The public IP the user pinned from the performance panel; "" for none. property string pinnedIp: "" + // The assistant's Ask presets as saved, or null for the defaults + // (assistant/Presets.js, which also validates what is read here). + property var presets: null + // The whole parsed object, so a write keeps keys this version does not // know about. property var doc: ({}) @@ -42,6 +46,19 @@ Singleton { root.write(Object.assign({}, root.doc, { perf: perf })); } + // For the settings page that will edit the presets. + function setPresets(list) { + root.presets = list; + const a = Object.assign({}, root.doc.assistant, { presets: list }); + root.write(Object.assign({}, root.doc, { assistant: a })); + } + function resetPresets() { + root.presets = null; + const a = Object.assign({}, root.doc.assistant); + delete a.presets; + root.write(Object.assign({}, root.doc, { assistant: a })); + } + function write(out) { root.doc = out; file.setText(JSON.stringify(out, null, 2) + "\n"); @@ -56,6 +73,8 @@ Singleton { root.doc = parsed; const pin = parsed.perf && typeof parsed.perf.pinnedIp === "string" ? parsed.perf.pinnedIp : ""; if (pin !== root.pinnedIp) root.pinnedIp = pin; + root.presets = parsed.assistant && parsed.assistant.presets !== undefined + ? parsed.assistant.presets : null; } FileView { @@ -70,6 +89,6 @@ Singleton { onFileChanged: reload() onLoaded: root.reparse() // Missing file: the defaults, and nothing written. - onLoadFailed: { root.doc = {}; root.pinnedIp = ""; } + onLoadFailed: { root.doc = {}; root.pinnedIp = ""; root.presets = null; } } } |
