52 lines
1.0 KiB
QML
52 lines
1.0 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import Quickshell
|
|
import Quickshell.Widgets
|
|
import Quickshell.Services.SystemTray
|
|
import qs.common
|
|
|
|
MouseArea {
|
|
id: root
|
|
|
|
required property SystemTrayItem item
|
|
property bool targetMenuOpen: false
|
|
property int trayItemWidth: Appearance.font.pixelSize.larger
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
Layout.fillHeight: true
|
|
implicitWidth: trayItemWidth
|
|
onClicked: (event) => {
|
|
switch (event.button) {
|
|
case Qt.LeftButton:
|
|
item.activate();
|
|
break;
|
|
case Qt.RightButton:
|
|
if (item.hasMenu) {
|
|
menu.open();
|
|
}
|
|
break;
|
|
}
|
|
event.accepted = true;
|
|
}
|
|
|
|
QsMenuAnchor {
|
|
id: menu
|
|
menu: root.item.menu
|
|
anchor {
|
|
item: root // Works instead of using window
|
|
edges: Edges.Bottom | Edges.Right
|
|
gravity: Edges.Bottom | Edges.Left
|
|
margins {
|
|
top: 30
|
|
}
|
|
}
|
|
}
|
|
|
|
IconImage {
|
|
id: trayIcon
|
|
source: root.item.icon
|
|
anchors.centerIn: parent
|
|
width: parent.width
|
|
height: parent.height
|
|
}
|
|
} |