diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-17 13:15:15 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-17 13:15:15 +0200 |
| commit | 441d8e30e9fdf8cb1215a5b1c45770955758ea26 (patch) | |
| tree | 3c9b2a703fddf3772fec63343a729da614d73d7e /desktop/island | |
| parent | 141439750a2974a39f8dc6edf8af2c8100a36005 (diff) | |
| download | quickshell-441d8e30e9fdf8cb1215a5b1c45770955758ea26.tar.gz quickshell-441d8e30e9fdf8cb1215a5b1c45770955758ea26.zip | |
settings: OBS scenes icon page
Diffstat (limited to 'desktop/island')
| -rw-r--r-- | desktop/island/SceneIcons.qml | 46 |
1 files changed, 44 insertions, 2 deletions
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 { |
