aboutsummaryrefslogtreecommitdiffstats
path: root/home/quickshell/bar/blocks/SystemTray.qml
diff options
context:
space:
mode:
authorPetri Hienonen <petri.hienonen@gmail.com>2024-05-23 13:56:00 +0300
committerPetri Hienonen <petri.hienonen@gmail.com>2025-11-30 12:29:57 +0200
commit08297376a85a1719518507e54fca9de954d2376a (patch)
tree3b9c58304b40248533bbb2bb5b7bad2da9da1ff0 /home/quickshell/bar/blocks/SystemTray.qml
parent75c2af4aedd2ac5c2cfc74b346625fa4b265541d (diff)
downloadnixos-08297376a85a1719518507e54fca9de954d2376a.tar.zst
Agenix configuration
Diffstat (limited to 'home/quickshell/bar/blocks/SystemTray.qml')
-rw-r--r--home/quickshell/bar/blocks/SystemTray.qml80
1 files changed, 80 insertions, 0 deletions
diff --git a/home/quickshell/bar/blocks/SystemTray.qml b/home/quickshell/bar/blocks/SystemTray.qml
new file mode 100644
index 0000000..15c4691
--- /dev/null
+++ b/home/quickshell/bar/blocks/SystemTray.qml
@@ -0,0 +1,80 @@
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import Quickshell
+import Quickshell.Widgets
+import Quickshell.Services.SystemTray
+import "root:/bar"
+
+RowLayout {
+ spacing: 5
+
+ Repeater {
+ model: ScriptModel {
+ values: {[...SystemTray.items.values]
+ .filter((item) => {
+ return (item.id != "spotify-client"
+ && item.id != "chrome_status_icon_1")
+ })
+ }
+ }
+
+ MouseArea {
+ id: delegate
+ required property SystemTrayItem modelData
+ property alias item: delegate.modelData
+
+ Layout.fillHeight: true
+ implicitWidth: icon.implicitWidth + 5
+
+ acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
+ hoverEnabled: true
+
+ onClicked: event => {
+ if (event.button == Qt.LeftButton) {
+ item.activate();
+ } else if (event.button == Qt.MiddleButton) {
+ item.secondaryActivate();
+ } else if (event.button == Qt.RightButton) {
+ menuAnchor.open();
+ }
+ }
+
+ onWheel: event => {
+ event.accepted = true;
+ const points = event.angleDelta.y / 120
+ item.scroll(points, false);
+ }
+
+ IconImage {
+ id: icon
+ anchors.centerIn: parent
+ source: item.icon
+ implicitSize: 16
+ }
+
+ QsMenuAnchor {
+ id: menuAnchor
+ menu: item.menu
+
+ anchor.window: delegate.QsWindow.window
+ anchor.adjustment: PopupAdjustment.Flip
+
+ anchor.onAnchoring: {
+ const window = delegate.QsWindow.window;
+ const widgetRect = window.contentItem.mapFromItem(delegate, 0, delegate.height, delegate.width, delegate.height);
+
+ menuAnchor.anchor.rect = widgetRect;
+ }
+ }
+
+ Tooltip {
+ relativeItem: delegate.containsMouse ? delegate : null
+
+ Label {
+ text: delegate.item.tooltipTitle || delegate.item.id
+ }
+ }
+ }
+ }
+}