Warning, /plasma/plasma-desktop/applets/kimpanel/package/contents/ui/ContextMenu.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-2015 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     function open(item, actionItem) {
0022         visualParent = item;
0023         refreshMenu(actionItem);
0024         menu.openRelative();
0025     }
0026 
0027     function refreshMenu(actionItem) {
0028         if (menu) {
0029             menu.destroy();
0030         }
0031 
0032         menu = contextMenuComponent.createObject(root, {"actionItem": actionItem});
0033 
0034         if (actionList && actionList.length > 0) {
0035             menu.separator.visible = true;
0036             actionList.forEach(function(actionItem) {
0037                 var item = contextMenuItemComponent.createObject(menu.showMenu, {
0038                     "actionItem": actionItem,
0039                 });
0040             });
0041         }
0042     }
0043 
0044     Component {
0045         id: contextMenuItemComponent
0046 
0047         PlasmaExtras.MenuItem {
0048             property variant actionItem
0049 
0050             text: actionItem.label
0051             icon: actionItem.icon
0052 
0053             onClicked: {
0054                 kimpanel.showAction(actionItem.key);
0055             }
0056         }
0057     }
0058 
0059     Component {
0060         id: contextMenuComponent
0061 
0062         PlasmaExtras.Menu {
0063             visualParent: root.visualParent
0064             property variant actionItem
0065             property Item separator: separatorItem
0066             property QtObject showMenu: subShowMenu
0067 
0068             placement: {
0069                 if (Plasmoid.location === PlasmaCore.Types.LeftEdge) {
0070                     return PlasmaExtras.Menu.RightPosedTopAlignedPopup;
0071                 } else if (Plasmoid.location === PlasmaCore.Types.TopEdge) {
0072                     return PlasmaExtras.Menu.BottomPosedLeftAlignedPopup;
0073                 } else if (Plasmoid.location === PlasmaCore.Types.RightEdge) {
0074                     return PlasmaExtras.Menu.LeftPosedTopAlignedPopup;
0075                 } else {
0076                     return PlasmaExtras.Menu.TopPosedLeftAlignedPopup;
0077                 }
0078             }
0079 
0080             PlasmaExtras.MenuItem {
0081                 id: showItem
0082                 visible: separatorItem.visible
0083                 text: i18n("Show")
0084 
0085                 property PlasmaExtras.Menu _subShowMenu: PlasmaExtras.Menu {
0086                     id: subShowMenu
0087                     visualParent: showItem.action
0088                 }
0089             }
0090 
0091             PlasmaExtras.MenuItem {
0092                 id: separatorItem
0093                 separator: true
0094                 visible: false
0095             }
0096 
0097             PlasmaExtras.MenuItem {
0098                 text: i18n("Hide %1", actionItem.label);
0099                 onClicked: {
0100                     kimpanel.hideAction(actionItem.key);
0101                 }
0102                 enabled: actionItem.key !== 'kimpanel-placeholder'
0103                 visible: enabled
0104             }
0105 
0106             PlasmaExtras.MenuItem {
0107                 text: i18n("Configure Input Method")
0108                 icon: "configure"
0109                 onClicked: {
0110                     helper.configure();
0111                 }
0112             }
0113 
0114             PlasmaExtras.MenuItem {
0115                 text: i18n("Reload Config")
0116                 icon: "view-refresh"
0117                 onClicked: {
0118                     helper.reloadConfig();
0119                 }
0120             }
0121 
0122             PlasmaExtras.MenuItem {
0123                 text: i18n("Exit Input Method")
0124                 icon: "application-exit"
0125                 onClicked: {
0126                     helper.exit();
0127                 }
0128             }
0129 
0130             PlasmaExtras.MenuItem {
0131                 property QtObject configureAction: null
0132 
0133                 enabled: configureAction && configureAction.enabled
0134 
0135                 text: configureAction ? configureAction.text : ""
0136                 icon: configureAction ? configureAction.icon : ""
0137 
0138                 onClicked: configureAction.trigger()
0139 
0140                 Component.onCompleted: configureAction = Plasmoid.internalAction("configure")
0141             }
0142         }
0143     }
0144 }