aboutsummaryrefslogtreecommitdiff
path: root/modules/system/quickshell/ControlCenter.qml
blob: af136389b935bb3082b620bd5a51ff81eae29170 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Networking
import Quickshell.Bluetooth
import Quickshell.Services.Pipewire
import Quickshell.Services.Mpris

Item {
    id: root
    width: childrenRect.width
    height: parent.height

    BrightnessService {
        id: brightnessService
    }

    MouseArea {
        anchors.fill: parent
        onClicked: GlobalState.toggle("ControlCenter")
    }

    Row {
        anchors.verticalCenter: parent.verticalCenter
        spacing: 4
        Image {
            width: 20
            height: 20
            source: Quickshell.iconPath("emblem-system-symbolic")
            sourceSize: Qt.size(width, height)
            smooth: true
            mipmap: true
        }
    }

    AnchoredPopup {
        popupName: "ControlCenter"
        anchorWindow: barWindow
        anchorItem: root

        PopupCard {
            id: card
            width: 320
            margins: 16

            RowLayout {
                Layout.fillWidth: true
                spacing: 12

                ConnectivityBox {
                    Layout.fillWidth: true
                }

                ColumnLayout {
                    spacing: 12
                    ControlTile {
                        label: "Do Not Disturb"
                        icon: "notifications"
                    }
                    ControlTile {
                        icon: "network-wireless"
                    }
                }
            }

            SliderBox {
                label: "Display"
                icon: "display-brightness"
                value: brightnessService.brightness
                onMoved: val => brightnessService.setBrightness(val)
            }

            SliderBox {
                label: "Sound"
                icon: "audio-volume-high"
                value: Pipewire.defaultAudioSink?.audio?.volume ?? 0
                clickable: true
                onClicked: Qt.callLater(() => GlobalState.open("Volume"))
                onMoved: val => {
                    const sink = Pipewire.defaultAudioSink;
                    if (sink?.audio) {
                        sink.audio.muted = false;
                        sink.audio.volume = val;
                    }
                }
            }

            Squircle {
                Layout.fillWidth: true
                height: 64
                cornerRadius: 16
                fillColor: hoverArea.containsMouse ? Theme.surfaceHover : Theme.surface
                visible: (Mpris.players?.values?.length ?? 0) > 0

                MouseArea {
                    id: hoverArea
                    anchors.fill: parent
                    hoverEnabled: true
                    acceptedButtons: Qt.NoButton
                }

                MediaCard {
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.right: parent.right
                    anchors.leftMargin: 12
                    anchors.rightMargin: 12

                    isExpanded: false

                    readonly property var activePlayer: {
                        const ps = Mpris.players?.values || [];
                        for (const p of ps)
                            if (p.playbackState === MprisPlaybackState.Playing)
                                return p;
                        return ps[0] ?? null;
                    }

                    player: activePlayer

                    onClicked: Qt.callLater(() => GlobalState.open("Media"))
                }
            }
        }
    }
}