4pragma ComponentBehavior: Bound
7import QtQuick.Controls as QQC2
8import QtQuick.Templates as T
9import org.kde.kirigami as Kirigami
14 property alias actions: actionsInstantiator.model
16 required property Component submenuComponent
17 property Component itemDelegate: ActionMenuItem {}
18 property Component separatorDelegate: QQC2.MenuSeparator {
19 property T.Action action
20 visible: !(action instanceof Kirigami.Action) || action.visible
22 property Component loaderDelegate: Loader {
23 property T.Action action
25 property T.Action parentAction
26 property T.MenuItem parentItem
28 visible: !(parentAction instanceof Kirigami.Action) || parentAction.visible
31 id: actionsInstantiator
37 required property T.Action modelData
38 readonly property T.Action action: modelData
40 property QtObject item: null
41 property bool isSubMenu: false
43 Component.onCompleted: {
44 const isKirigamiAction = delegate.action instanceof Kirigami.Action;
45 if (!isKirigamiAction || delegate.action.children.length === 0) {
46 if (isKirigamiAction && delegate.action.separator) {
47 item = root.separatorDelegate.createObject(null, { action: delegate.action });
48 }
else if (action.displayComponent) {
49 item = root.loaderDelegate.createObject(null, {
50 actions: delegate.action,
51 sourceComponent: action.displayComponent,
54 item = root.itemDelegate.createObject(null, { action: delegate.action });
57 }
else if (root.submenuComponent) {
58 item = root.submenuComponent.createObject(null, {
59 parentAction: delegate.action,
60 title: delegate.action.text,
61 actions: delegate.action.children,
62 submenuComponent: root.submenuComponent,
66 root.insertMenu(root.count, item);
67 item.parentItem = root.contentData[root.contentData.length - 1];
68 item.parentItem.icon = delegate.action.icon;
74 Component.onDestruction: {
76 root.removeMenu(item);
78 root.removeItem(item);