more flyout stuff, tray menus
This commit is contained in:
parent
3a548930e2
commit
59458cade3
4 changed files with 401 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ import QtQuick
|
|||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Services.SystemTray
|
||||
import "." as M
|
||||
|
||||
RowLayout {
|
||||
id: root
|
||||
|
|
@ -25,6 +26,20 @@ RowLayout {
|
|||
fillMode: Image.PreserveAspectFit
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
onHoveredChanged: {
|
||||
const tip = [iconItem.modelData.tooltipTitle, iconItem.modelData.tooltipDescription]
|
||||
.filter(s => s).join("\n") || iconItem.modelData.title;
|
||||
if (hovered && tip) {
|
||||
M.FlyoutState.text = tip;
|
||||
M.FlyoutState.itemX = iconItem.mapToGlobal(iconItem.width / 2, 0).x;
|
||||
M.FlyoutState.visible = true;
|
||||
} else if (!hovered) {
|
||||
M.FlyoutState.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
|
|
@ -32,10 +47,26 @@ RowLayout {
|
|||
if (mouse.button === Qt.LeftButton) {
|
||||
iconItem.modelData.activate();
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
iconItem.modelData.display(root.bar, mouse.x, mouse.y);
|
||||
if (iconItem.modelData.menu) {
|
||||
menuLoader.active = true;
|
||||
} else {
|
||||
iconItem.modelData.secondaryActivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Per-icon context menu window, created on demand
|
||||
Loader {
|
||||
id: menuLoader
|
||||
active: false
|
||||
sourceComponent: M.TrayMenu {
|
||||
handle: iconItem.modelData.menu
|
||||
screen: root.bar.screen
|
||||
anchorX: iconItem.mapToGlobal(iconItem.width / 2, 0).x
|
||||
onClosed: menuLoader.active = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue