Warning, /frameworks/kirigami/src/controls/private/ActionsMenu.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <aleixpol@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Controls as QQC2 0009 import QtQuick.Templates as T 0010 import org.kde.kirigami as Kirigami 0011 0012 QQC2.Menu { 0013 id: root 0014 0015 property alias actions: actionsInstantiator.model 0016 0017 property Component submenuComponent 0018 property Component itemDelegate: ActionMenuItem {} 0019 property Component separatorDelegate: QQC2.MenuSeparator { 0020 property T.Action action 0021 } 0022 property Component loaderDelegate: Loader { 0023 property T.Action action 0024 } 0025 property T.Action parentAction 0026 property T.MenuItem parentItem 0027 0028 Instantiator { 0029 id: actionsInstantiator 0030 0031 active: root.visible 0032 delegate: QtObject { 0033 readonly property T.Action action: modelData 0034 0035 property QtObject item: null 0036 property bool isSubMenu: false 0037 0038 Component.onCompleted: { 0039 const isKirigamiAction = action instanceof Kirigami.Action; 0040 if (!isKirigamiAction || action.children.length === 0) { 0041 if (isKirigamiAction && action.separator) { 0042 item = root.separatorDelegate.createObject(null, { action }); 0043 } else if (action.displayComponent) { 0044 item = root.loaderDelegate.createObject(null, { 0045 action, 0046 sourceComponent: action.displayComponent, 0047 }); 0048 } else { 0049 item = root.itemDelegate.createObject(null, { action }); 0050 } 0051 root.addItem(item) 0052 } else if (root.submenuComponent) { 0053 item = root.submenuComponent.createObject(null, { 0054 parentAction: action, 0055 title: action.text, 0056 actions: action.children, 0057 }); 0058 0059 root.insertMenu(root.count, item); 0060 item.parentItem = root.contentData[root.contentData.length - 1]; 0061 item.parentItem.icon = action.icon; 0062 isSubMenu = true; 0063 } 0064 } 0065 0066 Component.onDestruction: { 0067 if (isSubMenu) { 0068 root.removeMenu(item); 0069 } else { 0070 root.removeItem(item); 0071 } 0072 item.destroy(); 0073 } 0074 } 0075 } 0076 }