forked from Shinonome/dots-hyprland
custom system tray
This commit is contained in:
@@ -9,12 +9,13 @@ import Qt5Compat.GraphicalEffects
|
||||
|
||||
MouseArea {
|
||||
id: root
|
||||
|
||||
property var bar: root.QsWindow.window
|
||||
required property SystemTrayItem item
|
||||
property bool targetMenuOpen: false
|
||||
hoverEnabled: true
|
||||
|
||||
signal menuOpened(qsWindow: var)
|
||||
signal menuClosed()
|
||||
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
implicitWidth: 20
|
||||
implicitHeight: 20
|
||||
@@ -36,16 +37,30 @@ MouseArea {
|
||||
if (Config.options.bar.tray.showItemId) tooltip.content += "\n[" + item.id + "]";
|
||||
}
|
||||
|
||||
QsMenuAnchor {
|
||||
Loader {
|
||||
id: menu
|
||||
|
||||
menu: root.item.menu
|
||||
anchor.window: bar
|
||||
anchor.rect.x: root.x + (Config.options.bar.vertical ? 0 : bar?.width)
|
||||
anchor.rect.y: root.y + (Config.options.bar.vertical ? bar?.height : 0)
|
||||
anchor.rect.height: root.height
|
||||
anchor.rect.width: root.width
|
||||
anchor.edges: Config.options.bar.bottom ? (Edges.Top | Edges.Left) : (Edges.Bottom | Edges.Right)
|
||||
function open() {
|
||||
menu.active = true;
|
||||
}
|
||||
active: false
|
||||
sourceComponent: SysTrayMenu {
|
||||
Component.onCompleted: this.open();
|
||||
trayItemMenuHandle: root.item.menu
|
||||
anchor {
|
||||
window: root.QsWindow.window
|
||||
rect.x: root.x + (Config.options.bar.vertical ? 0 : QsWindow.window?.width)
|
||||
rect.y: root.y + (Config.options.bar.vertical ? QsWindow.window?.height : 0)
|
||||
rect.height: root.height
|
||||
rect.width: root.width
|
||||
edges: Config.options.bar.bottom ? (Edges.Top | Edges.Left) : (Edges.Bottom | Edges.Right)
|
||||
gravity: Config.options.bar.bottom ? (Edges.Top | Edges.Left) : (Edges.Bottom | Edges.Right)
|
||||
}
|
||||
onMenuOpened: (window) => root.menuOpened(window);
|
||||
onMenuClosed: {
|
||||
root.menuClosed();
|
||||
menu.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IconImage {
|
||||
|
||||
Reference in New Issue
Block a user