Krolyxon
Commit fb9b856

Branches

Refs →

aurora.configquickshellauroraTray.qml

60 lines · 1.9 KB · QML

1import QtQuick
2import Quickshell
3import Quickshell.Services.SystemTray
4
5Item {
6 id: tray
7 property bool show: true
8 visible: show && SystemTray.items.values.length > 0
9 implicitWidth: row.implicitWidth + 24
10 implicitHeight: parent ? parent.height : Theme.barHeight
11
12 Rectangle {
13 anchors.left: parent.left
14 anchors.right: parent.right
15 anchors.bottom: parent.bottom
16 height: 1
17 color: Theme.dim
18 }
19 Row {
20 id: row
21 anchors.centerIn: parent
22 spacing: 10
23 Repeater {
24 model: SystemTray.items
25 delegate: Item {
26 id: it
27 required property var modelData
28 width: 14
29 height: 14
30 anchors.verticalCenter: parent.verticalCenter
31
32 function openMenu() {
33 var p = it.mapToItem(null, 0, it.height + 4)
34 modelData.display(QsWindow.window, p.x, p.y)
35 }
36 Image {
37 anchors.fill: parent
38 source: it.modelData.icon
39 sourceSize: Qt.size(28, 28)
40 smooth: true
41 }
42 MouseArea {
43 anchors.fill: parent
44 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
45 cursorShape: Qt.PointingHandCursor
46 onClicked: mouse => {
47 if (mouse.button === Qt.LeftButton) {
48 if (it.modelData.onlyMenu) it.openMenu()
49 else it.modelData.activate()
50 } else if (mouse.button === Qt.MiddleButton) {
51 it.modelData.secondaryActivate()
52 } else {
53 it.openMenu()
54 }
55 }
56 }
57 }
58 }
59 }
60}