refactor(quickshell): split bar components

This commit is contained in:
2026-09-25 17:41:59 -04:00
parent 4fdb6d90d8
commit 04cf13ae99
6 changed files with 225 additions and 180 deletions
+66
View File
@@ -0,0 +1,66 @@
import QtQuick
import Quickshell.Services.SystemTray
import Quickshell.Widgets
Rectangle {
id: root
required property var barWindow
visible: trayRepeater.count > 0
implicitWidth: trayItems.implicitWidth + Theme.contentPadding * 2
implicitHeight: Theme.blockHeight
color: Theme.primary
Row {
id: trayItems
anchors.centerIn: parent
spacing: Theme.contentPadding
Repeater {
id: trayRepeater
model: SystemTray.items
Item {
id: trayItem
required property var modelData
width: 26
height: 30
IconImage {
anchors {
fill: parent
margins: 3
}
source: trayItem.modelData.icon
opacity: trayMouse.containsMouse ? 1 : 0.82
Behavior on opacity {
NumberAnimation { duration: 120 }
}
}
MouseArea {
id: trayMouse
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
onClicked: mouse => {
if (mouse.button === Qt.MiddleButton) {
trayItem.modelData.secondaryActivate();
} else if (mouse.button === Qt.RightButton || trayItem.modelData.onlyMenu) {
const point = mapToItem(root.barWindow.contentItem, 0, height);
trayItem.modelData.display(root.barWindow, point.x, point.y);
} else {
trayItem.modelData.activate();
}
}
onWheel: wheel => trayItem.modelData.scroll(
wheel.angleDelta.y, false)
}
}
}
}
}