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