summaryrefslogtreecommitdiff
path: root/modules/bar/Pills.qml
blob: 7af9d6d645b1de033bf07d4a50da73792ef9e6ce (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
127
128
129
130
131
132
133
134
135
import "root:/widgets"
import "root:/services"
import "root:/config"
import "components"
import "components/workspaces"
import Quickshell
import QtQuick
import QtQuick.Layouts

BoxLayout {
    id: root

    required property ShellScreen screen

    function get(horiz, vert) {
        return BarConfig.vertical ? vert : horiz;
    }

    vertical: BarConfig.vertical
    spacing: Appearance.padding.large

    anchors.fill: parent
    anchors.margins: BarConfig.sizes.floatingGap
    anchors.rightMargin: get(BarConfig.sizes.floatingGap, 0)
    anchors.bottomMargin: get(0, BarConfig.sizes.floatingGap)

    Pill {
        OsIcon {
            id: osIcon

            anchors.horizontalCenter: root.get(undefined, parent.horizontalCenter)
            anchors.verticalCenter: root.get(parent.verticalCenter, undefined)
        }

        Workspaces {
            vertical: BarConfig.vertical

            anchors.left: root.get(osIcon.right, undefined)
            anchors.leftMargin: root.get(Appearance.padding.large, 0)
            anchors.top: root.get(undefined, osIcon.bottom)
            anchors.topMargin: root.get(0, Appearance.padding.large)

            anchors.horizontalCenter: root.get(undefined, parent.horizontalCenter)
            anchors.verticalCenter: root.get(parent.verticalCenter, undefined)
        }
    }

    MouseArea {
        Layout.fillWidth: true
        Layout.fillHeight: true

        onWheel: event => {
            if (event.angleDelta.y > 0)
                Audio.setVolume(Audio.volume + 0.1);
            else if (event.angleDelta.y < 0)
                Audio.setVolume(Audio.volume - 0.1);
        }
    }

    Pill {
        ActiveWindow {
            vertical: BarConfig.vertical

            anchors.horizontalCenter: root.get(undefined, parent.horizontalCenter)
            anchors.verticalCenter: root.get(parent.verticalCenter, undefined)
        }
    }

    MouseArea {
        Layout.fillWidth: true
        Layout.fillHeight: true

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

    Pill {
        Tray {
            vertical: BarConfig.vertical

            anchors.horizontalCenter: root.get(undefined, parent.horizontalCenter)
            anchors.verticalCenter: root.get(parent.verticalCenter, undefined)
        }
    }

    Pill {
        Clock {
            id: clock

            vertical: BarConfig.vertical

            anchors.horizontalCenter: root.get(undefined, parent.horizontalCenter)
            anchors.verticalCenter: root.get(parent.verticalCenter, undefined)
        }

        StatusIcons {
            anchors.left: root.get(clock.right, undefined)
            anchors.leftMargin: root.get(Appearance.padding.large, 0)
            anchors.top: root.get(undefined, clock.bottom)
            anchors.topMargin: root.get(0, Appearance.padding.large)

            anchors.horizontalCenter: root.get(undefined, parent.horizontalCenter)
            anchors.verticalCenter: root.get(parent.verticalCenter, undefined)
        }
    }

    Pill {
        // Make circle
        Layout.maximumWidth: BarConfig.sizes.height
        Layout.maximumHeight: BarConfig.sizes.height

        Power {
            // Center in pill
            x: (BarConfig.sizes.height - width) / 2
            y: (BarConfig.sizes.height - height) / 2

            anchors.horizontalCenter: root.get(undefined, parent.horizontalCenter)
            anchors.verticalCenter: root.get(parent.verticalCenter, undefined)
        }
    }

    component Pill: PaddedRect {
        color: Colours.alpha(Colours.palette.m3surface, false)
        radius: Appearance.rounding.full
        padding: BarConfig.vertical ? [Appearance.padding.large, 0] : [0, Appearance.padding.large]

        Layout.minimumWidth: BarConfig.sizes.height
        Layout.minimumHeight: BarConfig.sizes.height
    }
}