summaryrefslogtreecommitdiff
path: root/modules/osd/Interactions.qml
blob: fa75aa0f77632c59c353bafb7f6c606f5cd6557c (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
import "root:/services"
import "root:/config"
import Quickshell
import QtQuick

Scope {
    id: root

    required property ShellScreen screen
    required property PersistentProperties visibilities
    required property bool hovered
    readonly property Brightness.Monitor monitor: Brightness.getMonitorForScreen(screen)

    function show(): void {
        root.visibilities.osd = true;
        timer.restart();
    }

    Connections {
        target: Audio

        function onMutedChanged(): void {
            root.show();
        }

        function onVolumeChanged(): void {
            root.show();
        }
    }

    Connections {
        target: root.monitor

        function onBrightnessChanged(): void {
            root.show();
        }
    }

    Timer {
        id: timer

        interval: Config.osd.hideDelay
        onTriggered: {
            if (!root.hovered)
                root.visibilities.osd = false;
        }
    }
}