aboutsummaryrefslogtreecommitdiff
path: root/modules/system/quickshell/Bar.qml
blob: 77cfd1e63790ebff6198fb54c3fd88331253421c (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
import Quickshell
import Quickshell.Wayland
import Quickshell.Services.SystemTray
import QtQuick

PanelWindow {
    id: barWindow

    WlrLayershell.layer: WlrLayer.Top

    anchors {
        top: true
        left: true
        right: true
    }

    implicitHeight: Theme.barHeight
    color: Theme.barBg

    Item {
        anchors.fill: parent
        anchors.leftMargin: 12
        anchors.rightMargin: 12

        Workspaces {
            anchors {
                left: parent.left
                verticalCenter: parent.verticalCenter
            }
        }

        Row {
            anchors {
                right: parent.right
                verticalCenter: parent.verticalCenter
            }
            spacing: 14

            Repeater {
                model: SystemTray.items

                delegate: Image {
                    id: trayIcon
                    required property SystemTrayItem modelData

                    width: 16
                    height: 16
                    anchors.verticalCenter: parent.verticalCenter
                    source: modelData.icon
                    sourceSize: Qt.size(width, height)
                    smooth: true
                    mipmap: true

                    MouseArea {
                        anchors.fill: parent
                        acceptedButtons: Qt.LeftButton | Qt.RightButton
                        onClicked: mouse => {
                            if (mouse.button === Qt.RightButton) {
                                if (modelData.hasMenu && modelData.menu) {
                                    trayMenu.menuItem = modelData.menu;
                                    trayMenu.open(trayIcon);
                                }
                            } else {
                                modelData.activate()
                            }
                        }
                    }
                }
            }

            TrayMenu {
                id: trayMenu
                parentWindow: barWindow
            }

            Bluetooth { anchors.verticalCenter: parent.verticalCenter }
            
            Wifi { anchors.verticalCenter: parent.verticalCenter }
            
            Volume { anchors.verticalCenter: parent.verticalCenter }
            
            Media { anchors.verticalCenter: parent.verticalCenter }
            
            ControlCenter { anchors.verticalCenter: parent.verticalCenter }

            Text {
                id: clock
                anchors.verticalCenter: parent.verticalCenter
                color: Theme.text
                font {
                    family: Theme.mainFont
                    pixelSize: 13
                    weight: Font.Medium
                }

                Timer {
                    interval: 1000
                    running: true
                    repeat: true
                    onTriggered: parent.text = Qt.formatDateTime(new Date(), "ddd d MMM  HH:mm:ss")
                }

                Component.onCompleted: text = Qt.formatDateTime(new Date(), "ddd d MMM  HH:mm:ss")
            }
        }
    }
}