diff options
Diffstat (limited to 'desktop')
| -rw-r--r-- | desktop/Prefs.qml | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/desktop/Prefs.qml b/desktop/Prefs.qml index 0ed6ee9..9a9b0b7 100644 --- a/desktop/Prefs.qml +++ b/desktop/Prefs.qml @@ -50,6 +50,18 @@ Singleton { readonly property int sidebarMax: 420 property int settingsSidebar: 200 + // The wallpaper engine (modules/appearance/WallEngine.qml): on or off, + // the interval, a list of paths per screen, and each screen's home, the + // wallpaper switching off returns to. In here rather than in list files: + // the lists can be empty, and an empty FileView write writes nothing. + readonly property var wallEngineDefaults: ({ on: false, minutes: 30, h: [], v: [], homeH: "", homeV: "" }) + property var wallEngine: wallEngineDefaults + function setWallEngine(changes) { + const w = Object.assign({}, root.wallEngine, changes); + root.wallEngine = w; + root.write(Object.assign({}, root.doc, { wallEngine: w })); + } + // The whole parsed object, so a write keeps keys this version does not // know about. property var doc: ({}) @@ -103,6 +115,15 @@ Singleton { const w = parsed.settings ? parsed.settings.sidebar : undefined; root.settingsSidebar = typeof w === "number" && w >= root.sidebarMin && w <= root.sidebarMax ? Math.round(w) : 200; + const we = parsed.wallEngine && typeof parsed.wallEngine === "object" ? parsed.wallEngine : {}; + const paths = a => Array.isArray(a) ? a.filter(s => typeof s === "string" && s !== "") : []; + const str = s => typeof s === "string" ? s : ""; + root.wallEngine = { + on: we.on === true, + minutes: Number.isInteger(we.minutes) && we.minutes >= 1 ? we.minutes : 30, + h: paths(we.h), v: paths(we.v), + homeH: str(we.homeH), homeV: str(we.homeV), + }; } FileView { @@ -117,6 +138,6 @@ Singleton { onFileChanged: reload() onLoaded: root.reparse() // Missing file: the defaults, and nothing written. - onLoadFailed: { root.doc = {}; root.pinnedIp = ""; root.presets = null; root.settingsSidebar = 200; root.assistantModel = ""; } + onLoadFailed: { root.doc = {}; root.pinnedIp = ""; root.presets = null; root.settingsSidebar = 200; root.assistantModel = ""; root.wallEngine = root.wallEngineDefaults; } } } |
