7pragma ComponentBehavior: Bound
10import QtQuick.Controls as QQC2
11import QtQuick.Controls.impl as QQC2Impl
13import QtQuick.Templates as T
14import org.kde.kirigami as Kirigami
19 required property T.Action tAction
21 readonly property Kirigami.Action kAction: tAction instanceof Kirigami.Action ? tAction : null
23 readonly property bool actionVisible: kAction?.visible ?? true
24 readonly property bool isSeparator: kAction?.separator ?? false
25 readonly property bool isExpandable: kAction?.expandible ?? false
26 readonly property bool hasChildren: kAction ? kAction.children.length > 0 : false
27 readonly property bool hasVisibleMenu: actionsMenu?.visible ?? false
28 readonly property bool hasToolTip: kAction ? kAction.tooltip !== "" : false
30 checked: checkedBinding()
32 activeFocusOnTab: true
36 contentItem: RowLayout {
37 spacing: Kirigami.Units.largeSpacing
41 color: listItem.tAction.icon.color
42 source: listItem.tAction.icon.name || listItem.tAction.icon.source
44 readonly property int size: Kirigami.Units.iconSizes.smallMedium
45 Layout.minimumHeight: size
46 Layout.maximumHeight: size
47 Layout.minimumWidth: size
48 Layout.maximumWidth: size
50 selected: (listItem.highlighted || listItem.checked || listItem.down)
51 visible: source !== undefined && !listItem.isSeparator
54 QQC2Impl.MnemonicLabel {
56 visible: !listItem.isSeparator
57 text: width > height * 2 ? listItem.Kirigami.MnemonicData.mnemonicLabel :
""
62 horizontalAlignment: Text.AlignLeft
64 Layout.fillWidth:
true
65 mnemonicVisible: listItem.Kirigami.MnemonicData.active
66 color: (listItem.highlighted || listItem.checked || listItem.down) ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
67 elide: Text.ElideRight
72 }
else if (!listItem.enabled) {
80 duration: Kirigami.Units.longDuration/2
81 easing.type: Easing.InOutQuad
89 visible: listItem.isSeparator
90 Layout.fillWidth:
true
95 Layout.alignment:
Qt.AlignVCenter
96 Layout.leftMargin: !root.collapsed ? 0 : -width
97 Layout.preferredHeight: !root.collapsed ? Kirigami.Units.iconSizes.small : Kirigami.Units.iconSizes.small/2
99 selected: listItem.checked || listItem.down
100 Layout.preferredWidth: Layout.preferredHeight
101 source: listItem.mirrored ?
"go-next-symbolic-rtl" :
"go-next-symbolic"
102 visible: (!listItem.isExpandable || root.collapsed) && !listItem.isSeparator && listItem.hasChildren
106 Accessible.name: listItem.tAction?.text ??
""
107 Kirigami.MnemonicData.enabled: enabled && visible
108 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.MenuItem
109 Kirigami.MnemonicData.label: tAction?.text ??
""
112 sequence: listItem.Kirigami.MnemonicData.sequence
113 onActivated: listItem.clicked()
116 property ActionsMenu actionsMenu: ActionsMenu {
117 x:
Qt.application.layoutDirection ===
Qt.RightToLeft ? -width : listItem.width
118 actions: listItem.kAction?.children ?? []
119 submenuComponent: ActionsMenu {}
123 stackView.openSubMenu = listItem.actionsMenu;
124 }
else if (stackView.openSubMenu === listItem.actionsMenu) {
125 stackView.openSubMenu = null;
131 visible: actionVisible && opacity > 0
132 opacity: !root.collapsed || iconItem.source.toString().length > 0
134 Behavior on opacity {
136 duration: Kirigami.Units.longDuration / 2
137 easing.type: Easing.InOutQuad
141 enabled: tAction?.enabled ??
false
143 hoverEnabled: (!isExpandable || root.collapsed) && !Kirigami.Settings.tabletMode && !isSeparator
144 font.pointSize: isExpandable ? Kirigami.Theme.defaultFont.pointSize * 1.30 : Kirigami.Theme.defaultFont.pointSize
145 height: implicitHeight * opacity
148 visible: !listItem.isSeparator
149 && (listItem.hasToolTip || root.collapsed)
150 && !listItem.hasVisibleMenu
154 text: (listItem.kAction?.tooltip || listItem.tAction?.text) ??
""
155 delay: Kirigami.
Units.toolTipDelay
156 y: (listItem.height - height) / 2
157 x:
Qt.application.layoutDirection ===
Qt.
RightToLeft ? -width : listItem.width
164 if (stackView.openSubMenu) {
165 stackView.openSubMenu.visible = false;
167 if (actionsMenu.count > 0) {
168 actionsMenu.popup(this, width, 0);
174 Accessible.onPressAction: trigger()
175 Keys.onEnterPressed: event => trigger()
176 Keys.onReturnPressed: event => trigger()
182 if (root.collapsed) {
183 if (actionsMenu.count > 0 && !actionsMenu.visible) {
184 stackView.openSubMenu = actionsMenu;
185 actionsMenu.popup(
this, width, 0);
188 stackView.push(menuComponent, {
189 model: kAction?.children ?? [],
194 }
else if (root.resetMenuOnTriggered) {
197 checked =
Qt.binding(() => checkedBinding());
200 function checkedBinding(): bool {
201 return (tAction?.checked || actionsMenu?.visible) ?? false;
204 Keys.onDownPressed:
event => nextItemInFocusChain().focus =
true
205 Keys.onUpPressed:
event => nextItemInFocusChain(
false).focus =
true
QStringView level(QStringView ifopt)