quickshell: fix menu delegate, use inline repeater

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
rope 2026-05-26 10:39:19 +01:00
parent e02e1f41c1
commit 5f1618e49c

View file

@ -750,32 +750,26 @@ in
Repeater { Repeater {
model: menuOpener.children model: menuOpener.children
Loader { Rectangle {
required property var modelData required property var modelData
width: 200 width: 200
sourceComponent: modelData.isSeparator ? separatorComp : menuItemComp height: modelData.isSeparator ? 9 : 28
} color: !modelData.isSeparator && itemMouse.containsMouse && modelData.enabled
} ? "#${c.base02}" : "transparent"
} radius: modelData.isSeparator ? 0 : 4
// Separator line
Rectangle {
visible: modelData.isSeparator
anchors.centerIn: parent
width: parent.width - 20
height: 1
color: "#${c.base03}"
} }
// Close when clicking outside // Menu item content
onVisibleChanged: {
if (!visible) {
menuOpener.menu = null;
}
}
}
// Menu item delegate
component MenuItemDelegate: Rectangle {
required property var modelData
width: 200
height: modelData.isSeparator ? 1 : 28
color: itemMouse.containsMouse && modelData.enabled ? "#${c.base02}" : "transparent"
radius: 4
RowLayout { RowLayout {
visible: !modelData.isSeparator
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: 10 anchors.leftMargin: 10
anchors.rightMargin: 10 anchors.rightMargin: 10
@ -803,29 +797,22 @@ in
id: itemMouse id: itemMouse
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
enabled: modelData.enabled enabled: !modelData.isSeparator && modelData.enabled
onClicked: { onClicked: {
modelData.triggered(); modelData.triggered();
contextMenu.visible = false; contextMenu.visible = false;
} }
} }
} }
}
// Separator delegate
component SeparatorDelegate: Rectangle {
width: 200
height: 9
color: "transparent"
Rectangle {
anchors.centerIn: parent
width: parent.width - 20
height: 1
color: "#${c.base03}"
} }
} }
Component { id: menuItemComp; MenuItemDelegate {} } onVisibleChanged: {
Component { id: separatorComp; SeparatorDelegate {} } if (!visible) {
menuOpener.menu = null;
}
}
} }
} }
} }