72 lines
2.3 KiB
QML
72 lines
2.3 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import Quickshell
|
|
import Quickshell.Services.SystemTray
|
|
import "." as M
|
|
|
|
RowLayout {
|
|
id: root
|
|
spacing: M.Theme.moduleSpacing + 2
|
|
|
|
required property var bar
|
|
|
|
Repeater {
|
|
model: SystemTray.items
|
|
|
|
delegate: Item {
|
|
id: iconItem
|
|
required property SystemTrayItem modelData
|
|
|
|
implicitWidth: 18
|
|
implicitHeight: 18
|
|
|
|
M.ThemedIcon {
|
|
anchors.fill: parent
|
|
source: iconItem.modelData.icon
|
|
tint: M.Theme.base05
|
|
}
|
|
|
|
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
|
|
onClicked: mouse => {
|
|
if (mouse.button === Qt.LeftButton) {
|
|
iconItem.modelData.activate();
|
|
} else if (mouse.button === Qt.RightButton) {
|
|
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
|
|
onMenuClosed: menuLoader.active = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|