import QtQuick import Quickshell import "../theme" Item { id: root property string text: "" property string iconSource: "" property bool separator: false property bool actionEnabled: true property bool selected: false property bool submenu: false property int buttonType: QsMenuButtonType.None property int checkState: Qt.Unchecked signal invoked() signal entered() implicitWidth: 264 implicitHeight: separator ? 9 : 34 Accessible.role: separator ? Accessible.Separator : Accessible.MenuItem Accessible.name: text Accessible.checkable: buttonType !== QsMenuButtonType.None Accessible.checked: checkState === Qt.Checked Accessible.onPressAction: if (actionEnabled && !separator) invoked() Rectangle { anchors.verticalCenter: parent.verticalCenter; width: parent.width; height: 1; color: Theme.border; visible: root.separator } Rectangle { anchors.fill: parent; radius: 9; visible: !root.separator color: root.selected && root.actionEnabled ? Qt.alpha(Theme.accent, 0.22) : Theme.transparent Behavior on color { ColorAnimation { duration: Theme.duration / 2 } } } Row { anchors.verticalCenter: parent.verticalCenter; x: 8; spacing: 8; visible: !root.separator opacity: root.actionEnabled ? 1 : 0.4 Item { width: 18; height: 18 Rectangle { anchors.centerIn: parent; width: 14; height: 14 radius: root.buttonType === QsMenuButtonType.RadioButton ? 7 : 3 visible: root.buttonType !== QsMenuButtonType.None color: Theme.transparent; border.width: 1 border.color: root.checkState === Qt.Unchecked ? Theme.textSecondary : Theme.accent Rectangle { anchors.centerIn: parent; width: 6; height: 6; radius: 3; color: Theme.accent; visible: root.buttonType === QsMenuButtonType.RadioButton && root.checkState === Qt.Checked } Text { anchors.centerIn: parent; text: root.checkState === Qt.PartiallyChecked ? "−" : "✓"; font.pixelSize: 12; color: Theme.accent; visible: root.buttonType !== QsMenuButtonType.RadioButton && root.checkState !== Qt.Unchecked } } Image { anchors.fill: parent; source: root.iconSource; sourceSize.width: 18; sourceSize.height: 18; visible: root.buttonType === QsMenuButtonType.None; fillMode: Image.PreserveAspectFit } } Text { width: root.width - 70; text: root.text; textFormat: Text.PlainText; elide: Text.ElideRight; color: Theme.text; font.pixelSize: 13; height: 18; verticalAlignment: Text.AlignVCenter } Text { text: root.submenu ? "›" : ""; color: Theme.textSecondary; font.pixelSize: 16 } } MouseArea { anchors.fill: parent; hoverEnabled: true; enabled: !root.separator onEntered: root.entered() onClicked: if (root.actionEnabled) root.invoked() } }