aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/obs/ObsScenesModule.qml
blob: a91149edb447cd8ec32a3b57448560e6cbd20162 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

import QtQuick
import "../.."
import "../../island"

// Which glyph each OBS scene shows in the island pill, from the same watched
// map the pill reads. Set once per scene: paste an icon from the Nerd Fonts
// cheat sheet. OBS is not required to edit the configured rows.
Module {
    id: mod
    name: "obs"
    label: "OBS scenes"
    // nf-md-record_circle, present in Inconsolata Nerd Font.
    icon: "\udb83\udec2"
    settings: true
    group: "Desktop"
    dirty: SceneIcons.dirty
    keywords: ["obs", "scene", "icon", "glyph", "recording", "webcam", "stream"]

    // The saved keys plus whatever OBS currently reports, so a scene created
    // in OBS appears without a restart and a configured scene survives OBS
    // being closed.
    function names() {
        const out = [];
        for (const n in SceneIcons.map.scenes) out.push(n);
        for (const n of Obs.scenes) if (out.indexOf(n) < 0) out.push(n);
        return out;
    }

    function refresh() {
        if (!SceneIcons.dirty) SceneIcons.begin();
        mod.searchItems = mod.names().map(n => ({ text: n, key: n }));
    }

    page: Component {
        Page {
            title: "OBS scenes"
            actions: Component {
                SaveBar {
                    dirty: SceneIcons.dirty
                    valid: SceneIcons.valid
                    onSave: SceneIcons.save(SceneIcons.draft)
                    onDiscard: SceneIcons.discard()
                }
            }
            ObsScenesPage { width: parent.width }
        }
    }
}