lux-shell/modules/bar/components/tray/TrayItem.qml
2025-07-30 21:49:38 -04:00

49 lines
1 KiB
QML

pragma ComponentBehavior: Bound
import qs.widgets
import QtQuick
import Quickshell
import Quickshell.Services.SystemTray
import Quickshell.Widgets
import "menu/"
StyledButton {
id: root
property SystemTrayItem trayItem
property bool menuOpened: false
onClicked: toggleMenu()
function toggleMenu() {
menuOpened = !menuOpened;
}
content: IconImage {
id: icon
asynchronous: true
implicitSize: 18
source: {
let icon = root.trayItem.icon;
if (icon.includes("?path=")) {
const [name, path] = icon.split("?path=");
icon = `file://${path}/${name.slice(name.lastIndexOf("/") + 1)}`;
}
return icon;
}
}
Menu {
id: menu
opened: root.menuOpened
anchor.item: root
anchor.rect.x: root.width / 2 - width / 2
anchor.rect.y: root.height + 8
menuOpener: QsMenuOpener {
menu: root.trayItem.menu
}
}
}