8import QtQuick.Controls as QQC2
9import QtQuick.Templates as T
10import org.kde.kirigami as Kirigami
15 property alias actions: actionsInstantiator.model
17 property Component submenuComponent
18 property Component itemDelegate: ActionMenuItem {}
19 property Component separatorDelegate: QQC2.MenuSeparator {
20 property T.Action action
22 property Component loaderDelegate: Loader {
23 property T.Action action
25 property T.Action parentAction
26 property T.MenuItem parentItem
29 id: actionsInstantiator
33 readonly property T.Action action: modelData
35 property QtObject item: null
36 property bool isSubMenu: false
38 Component.onCompleted: {
39 const isKirigamiAction = action instanceof Kirigami.Action;
40 if (!isKirigamiAction || action.children.length === 0) {
41 if (isKirigamiAction && action.separator) {
42 item = root.separatorDelegate.createObject(null, { action });
43 }
else if (action.displayComponent) {
44 item = root.loaderDelegate.createObject(null, {
46 sourceComponent: action.displayComponent,
49 item = root.itemDelegate.createObject(null, { action });
52 }
else if (root.submenuComponent) {
53 item = root.submenuComponent.createObject(null, {
56 actions: action.children,
59 root.insertMenu(root.count, item);
60 item.parentItem = root.contentData[root.contentData.length - 1];
61 item.parentItem.icon = action.icon;
66 Component.onDestruction: {
68 root.removeMenu(item);
70 root.removeItem(item);