summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell/SystemTray.qml
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2025-08-31 12:12:23 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2025-08-31 12:12:23 +0200
commit9fc966ff7726d01267a6220483fb005c0efaa9c0 (patch)
tree9e66f32774a55a7f51314883648bd40751250091 /accounts/gkleen@sif/shell/quickshell/SystemTray.qml
parent97423da1a1e58a2820d12bed5b36f0896fd3cccc (diff)
downloadnixos-9fc966ff7726d01267a6220483fb005c0efaa9c0.tar
nixos-9fc966ff7726d01267a6220483fb005c0efaa9c0.tar.gz
nixos-9fc966ff7726d01267a6220483fb005c0efaa9c0.tar.bz2
nixos-9fc966ff7726d01267a6220483fb005c0efaa9c0.tar.xz
nixos-9fc966ff7726d01267a6220483fb005c0efaa9c0.zip
...
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/SystemTray.qml')
-rw-r--r--accounts/gkleen@sif/shell/quickshell/SystemTray.qml94
1 files changed, 94 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml
new file mode 100644
index 00000000..a02a81fd
--- /dev/null
+++ b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml
@@ -0,0 +1,94 @@
1import QtQuick
2import Quickshell
3import Quickshell.Widgets
4import Quickshell.Services.SystemTray
5
6Item {
7 anchors.verticalCenter: parent.verticalCenter
8 width: systemTrayRow.childrenRect.width
9 height: parent.height
10 clip: true
11
12 Row {
13 id: systemTrayRow
14 anchors.centerIn: parent
15 width: childrenRect.width
16 height: parent.height
17 spacing: 0
18
19 Repeater {
20 model: SystemTray.items.values
21
22 delegate: Item {
23 property var trayItem: modelData
24 property string iconSource: {
25 let icon = trayItem && trayItem.icon
26 if (typeof icon === 'string' || icon instanceof String) {
27 if (icon.includes("?path=")) {
28 const split = icon.split("?path=")
29 if (split.length !== 2)
30 return icon
31 const name = split[0]
32 const path = split[1]
33 const fileName = name.substring(
34 name.lastIndexOf("/") + 1)
35 return `file://${path}/${fileName}`
36 }
37 return icon
38 }
39 return ""
40 }
41
42 width: 16
43 height: parent.height
44 anchors.verticalCenter: parent.verticalCenter
45
46 IconImage {
47 anchors.centerIn: parent
48 width: parent.width
49 height: parent.width
50 source: parent.iconSource
51 asynchronous: true
52 smooth: true
53 mipmap: true
54 }
55
56 MouseArea {
57 id: trayItemArea
58
59 anchors.fill: parent
60 acceptedButtons: Qt.LeftButton | Qt.RightButton
61 hoverEnabled: true
62 cursorShape: Qt.PointingHandCursor
63 onClicked: mouse => {
64 if (!trayItem)
65 return
66
67 if (mouse.button === Qt.LeftButton
68 && !trayItem.onlyMenu) {
69 trayItem.activate()
70 return
71 }
72
73 if (trayItem.hasMenu) {
74 var globalPos = mapToGlobal(0, 0)
75 var currentScreen = screen || Screen
76 var screenX = currentScreen.x || 0
77 var relativeX = globalPos.x - screenX
78 menuAnchor.menu = trayItem.menu
79 menuAnchor.anchor.window = bar
80 menuAnchor.anchor.rect = Qt.rect(
81 relativeX,
82 21,
83 parent.width, 1)
84 menuAnchor.open()
85 }
86 }
87 }
88 }
89 }
90 }
91 QsMenuAnchor {
92 id: menuAnchor
93 }
94}