Krolyxon
Commit 6a3e480

Branches

Refs →

aurora.configquickshellauroraTray.qml

61 lines · 2.3 KB · QML

1import QtQuick
2import QtQuick.Effects
3import Quickshell
4import Quickshell.Services.SystemTray
5
6// Tray icons in the bar (a row, or a column in the vertical bar); monochrome unless Settings.appIcons is "colour"
7// (dots are too coarse at this size).
8Item {
9 id: tray
10 property bool show: true
11 property bool vertical: Theme.barVertical
12 visible: show && SystemTray.items.values.length > 0
13 implicitWidth: vertical ? Theme.barSize : row.implicitWidth + 22
14 implicitHeight: vertical ? row.implicitHeight + 22 : Theme.barSize
15
16 Grid {
17 id: row
18 anchors.centerIn: parent
19 columns: tray.vertical ? 1 : Math.max(1, rep.count) // only columns flips, see BarPill
20 spacing: 12
21 Repeater {
22 id: rep
23 model: SystemTray.items
24 delegate: Item {
25 id: it
26 required property var modelData
27 width: 16
28 height: 16
29
30 // under the icon, or beside it in the vertical bar
31 function openMenu() {
32 var p = tray.vertical ? it.mapToItem(null, it.width + 14, 0) : it.mapToItem(null, 0, it.height + 10)
33 modelData.display(QsWindow.window, p.x, p.y)
34 }
35 Image {
36 anchors.fill: parent
37 source: it.modelData.icon
38 sourceSize: Qt.size(32, 32)
39 smooth: true
40 layer.enabled: Settings.appIcons !== "colour"
41 layer.effect: MultiEffect { saturation: -1; brightness: 0.1 }
42 }
43 MouseArea {
44 anchors.fill: parent
45 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
46 cursorShape: Qt.PointingHandCursor
47 onClicked: mouse => {
48 if (mouse.button === Qt.LeftButton) {
49 if (it.modelData.onlyMenu) it.openMenu()
50 else it.modelData.activate()
51 } else if (mouse.button === Qt.MiddleButton) {
52 it.modelData.secondaryActivate()
53 } else {
54 it.openMenu()
55 }
56 }
57 }
58 }
59 }
60 }
61}