summaryrefslogtreecommitdiff
path: root/modules/osd/Content.qml
blob: 80fc71462bfed68def8b1c036dab243daae8e702 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
pragma ComponentBehavior: Bound

import qs.components.controls
import qs.services
import qs.config
import qs.utils
import QtQuick

Column {
    id: root

    required property Brightness.Monitor monitor

    padding: Appearance.padding.large

    anchors.verticalCenter: parent.verticalCenter
    anchors.left: parent.left

    spacing: Appearance.spacing.normal

    // Speaker volume
    CustomMouseArea {
        implicitWidth: Config.osd.sizes.sliderWidth
        implicitHeight: Config.osd.sizes.sliderHeight

        onWheel: event => {
            if (event.angleDelta.y > 0)
                Audio.incrementVolume();
            else if (event.angleDelta.y < 0)
                Audio.decrementVolume();
        }

        FilledSlider {
            anchors.fill: parent

            icon: Icons.getVolumeIcon(value, Audio.muted)
            value: Audio.volume
            onMoved: Audio.setVolume(value)
        }
    }

    // Brightness
    WrappedLoader {
        active: Config.osd.enableBrightness

        sourceComponent: CustomMouseArea {
            implicitWidth: Config.osd.sizes.sliderWidth
            implicitHeight: Config.osd.sizes.sliderHeight

            onWheel: event => {
                const monitor = root.monitor;
                if (!monitor)
                    return;
                if (event.angleDelta.y > 0)
                    monitor.setBrightness(monitor.brightness + 0.1);
                else if (event.angleDelta.y < 0)
                    monitor.setBrightness(monitor.brightness - 0.1);
            }

            FilledSlider {
                anchors.fill: parent

                icon: `brightness_${(Math.round(value * 6) + 1)}`
                value: root.monitor?.brightness ?? 0
                onMoved: root.monitor?.setBrightness(value)
            }
        }
    }
    component WrappedLoader: Loader {
        asynchronous: true
        visible: active
    }
}