From 441d8e30e9fdf8cb1215a5b1c45770955758ea26 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 17 Oct 2026 13:15:15 +0200 Subject: settings: OBS scenes icon page --- desktop/island/SceneIcons.qml | 46 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'desktop/island') diff --git a/desktop/island/SceneIcons.qml b/desktop/island/SceneIcons.qml index 44bcf9c..b8fe6b8 100644 --- a/desktop/island/SceneIcons.qml +++ b/desktop/island/SceneIcons.qml @@ -27,11 +27,53 @@ Singleton { property var map: Icons.defaults + // The settings page's draft, null when not editing. Every edit reassigns + // draft so the page's bindings fire; Save normalizes and writes. + property var draft: null + property bool dirty: false + readonly property bool valid: draft !== null && Icons.validMap(draft) + // Emitted when the draft is dropped, so the page rebuilds its fields: + // TextInput breaks its text binding on user edit, so a Discard would + // otherwise leave the old glyph on screen. + signal reset + function iconFor(name) { return Icons.iconFor(root.map, name); } + function validGlyph(s) { return Icons.validGlyph(s); } + + function begin() { + if (!root.dirty) + root.draft = Icons.parse(Icons.serialize(root.map)); + } + + function editScene(name, text) { + if (!root.draft) root.begin(); + const scenes = Object.assign({}, root.draft.scenes); + if (text === "") delete scenes[name]; + else scenes[name] = text; + root.draft = Object.assign({}, root.draft, { scenes: scenes }); + root.dirty = true; + } + + function editGeneric(text) { + if (!root.draft) root.begin(); + root.draft = Object.assign({}, root.draft, { generic: text }); + root.dirty = true; + } + + function discard() { + root.draft = null; + root.dirty = false; + root.reset(); + } function save(map) { - root.map = map; - fv.setText(Icons.serialize(map)); + if (!map) return; + const out = Icons.normalize(map); + root.map = out; + fv.setText(Icons.serialize(out)); + root.draft = null; + root.dirty = false; + root.reset(); } FileView { -- cgit v1.2.3