import QtQuick import Quickshell import Quickshell.Widgets import Quickshell.Services.SystemTray Item { anchors.verticalCenter: parent.verticalCenter width: systemTrayRow.childrenRect.width height: parent.height clip: true Row { id: systemTrayRow anchors.centerIn: parent width: childrenRect.width height: parent.height spacing: 0 Repeater { model: { var trayItems = Array.from(SystemTray.items.values).filter(item => item.status !== Status.Passive); trayItems.sort((a, b) => a.category !== b.category ? b.category - a.category : a.id.localeCompare(b.id)) return trayItems; } delegate: Item { property var trayItem: modelData property string iconSource: { let icon = trayItem && trayItem.icon if (typeof icon === 'string' || icon instanceof String) { if (icon.includes("?path=")) { const split = icon.split("?path=") if (split.length !== 2) return icon const name = split[0] const path = split[1] const fileName = name.substring( name.lastIndexOf("/") + 1) return `file://${path}/${fileName}` } return icon } return "" } width: 16 height: parent.height anchors.verticalCenter: parent.verticalCenter IconImage { anchors.centerIn: parent width: parent.width height: parent.width source: parent.iconSource asynchronous: true smooth: true mipmap: true } MouseArea { id: trayItemArea anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton hoverEnabled: true cursorShape: trayItem.onlyMenu ? Qt.ArrowCursor : Qt.PointingHandCursor onClicked: mouse => { if (!trayItem) return if (mouse.button === Qt.LeftButton && !trayItem.onlyMenu) { trayItem.activate() return } if (trayItem.hasMenu) { var globalPos = mapToGlobal(0, 0) var currentScreen = screen || Screen var screenX = currentScreen.x || 0 var relativeX = globalPos.x - screenX menuAnchor.menu = trayItem.menu menuAnchor.anchor.window = bar menuAnchor.anchor.rect = Qt.rect( relativeX, 21, parent.width, 1) menuAnchor.open() } } } PopupWindow { anchor { item: trayItemArea edges: Edges.Bottom } visible: (trayItem.tooltipTitle || trayItem.tooltipDescription) && trayItemArea.containsMouse && !menuAnchor.visible color: "black" implicitWidth: Math.max(tooltipTitle.contentWidth, tooltipDescription.contentWidth) + 16 implicitHeight: tooltipTitle.contentHeight + tooltipDescription.contentHeight + 16 WrapperItem { margin: 8 Column { Text { id: tooltipTitle font.pointSize: 10 font.family: "Fira Sans" font.bold: true color: "white" text: trayItem.tooltipTitle } Text { id: tooltipDescription font.pointSize: 10 font.family: "Fira Sans" color: "white" text: trayItem.tooltipDescription } } } } } } } QsMenuAnchor { id: menuAnchor } }