Warning, /plasma/plasma-desktop/applets/kimpanel/package/contents/ui/ActionMenu.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2013 Aurélien Gâteau <agateau@kde.org> 0003 SPDX-FileCopyrightText: 2014 Eike Hein <hein@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 import QtQuick 2.0 0009 0010 import org.kde.plasma.core as PlasmaCore 0011 import org.kde.plasma.extras 2.0 as PlasmaExtras 0012 import org.kde.plasma.plasmoid 2.0 0013 0014 Item { 0015 id: root 0016 0017 property QtObject menu 0018 property Item visualParent 0019 property variant actionList 0020 0021 signal actionClicked(string actionId) 0022 0023 onActionListChanged: refreshMenu(); 0024 0025 function open() { 0026 menu.openRelative(); 0027 } 0028 0029 function refreshMenu() { 0030 if (menu) { 0031 menu.destroy(); 0032 } 0033 0034 menu = contextMenuComponent.createObject(root); 0035 0036 if (!actionList || actionList.length === 0) { 0037 var item = emptyMenuItemComponent.createObject(menu); 0038 0039 menu.addMenuItem(item); 0040 0041 return; 0042 } 0043 0044 actionList.forEach(function(actionItem) { 0045 var item = contextMenuItemComponent.createObject(menu, { 0046 "actionItem": actionItem, 0047 }); 0048 0049 menu.addMenuItem(item); 0050 }); 0051 } 0052 0053 Component { 0054 id: contextMenuComponent 0055 0056 PlasmaExtras.Menu { 0057 visualParent: root.visualParent 0058 0059 placement: { 0060 if (Plasmoid.location === PlasmaCore.Types.LeftEdge) { 0061 return PlasmaExtras.Menu.RightPosedTopAlignedPopup; 0062 } else if (Plasmoid.location === PlasmaCore.Types.TopEdge) { 0063 return PlasmaExtras.Menu.BottomPosedLeftAlignedPopup; 0064 } else if (Plasmoid.location === PlasmaCore.Types.RightEdge) { 0065 return PlasmaExtras.Menu.LeftPosedTopAlignedPopup; 0066 } else { 0067 return PlasmaExtras.Menu.TopPosedLeftAlignedPopup; 0068 } 0069 } 0070 } 0071 } 0072 0073 Component { 0074 id: contextMenuItemComponent 0075 0076 PlasmaExtras.MenuItem { 0077 property variant actionItem 0078 0079 text: actionItem.text ? actionItem.text : "" 0080 icon: actionItem.icon ? actionItem.icon : null 0081 checkable: actionItem.hint === "checked" 0082 checked: actionItem.hint === "checked" 0083 0084 onClicked: { 0085 actionClicked(actionItem.actionId); 0086 } 0087 } 0088 } 0089 0090 Component { 0091 id: emptyMenuItemComponent 0092 PlasmaExtras.MenuItem { 0093 text: i18n("(Empty)") 0094 enabled: false 0095 } 0096 } 0097 }