quickshell: fix menu delegate, use inline repeater
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e02e1f41c1
commit
5f1618e49c
1 changed files with 51 additions and 64 deletions
|
|
@ -750,32 +750,26 @@ in
|
|||
Repeater {
|
||||
model: menuOpener.children
|
||||
|
||||
Loader {
|
||||
Rectangle {
|
||||
required property var modelData
|
||||
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
|
||||
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
|
||||
|
||||
// Menu item content
|
||||
RowLayout {
|
||||
visible: !modelData.isSeparator
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 10
|
||||
anchors.rightMargin: 10
|
||||
|
|
@ -803,29 +797,22 @@ in
|
|||
id: itemMouse
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
enabled: modelData.enabled
|
||||
enabled: !modelData.isSeparator && modelData.enabled
|
||||
onClicked: {
|
||||
modelData.triggered();
|
||||
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 {} }
|
||||
Component { id: separatorComp; SeparatorDelegate {} }
|
||||
onVisibleChanged: {
|
||||
if (!visible) {
|
||||
menuOpener.menu = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue