/*SPDX-FileCopyrightText: 2013 AurΓ©lien GΓ’teau <agateau@kde.org>SPDX-FileCopyrightText: 2014 Eike Hein <hein@kde.org>SPDX-License-Identifier: GPL-2.0-or-later*/pragma ComponentBehavior: Boundimport QtQuickimport org.kde.plasma.core as PlasmaCoreimport org.kde.plasma.extras as PlasmaExtrasimport org.kde.plasma.plasmoidItem {id: rootproperty PlasmaExtras.Menu menuproperty Item visualParentproperty var actionListsignal actionClicked(string actionId)onActionListChanged: refreshMenu();function open() {menu.openRelative();}function refreshMenu() {if (menu) {menu.destroy();}menu = contextMenuComponent.createObject(root);if (!actionList || actionList.length === 0) {const item = emptyMenuItemComponent.createObject(menu);menu.addMenuItem(item);return;}actionList.forEach(actionItem => {const item = contextMenuItemComponent.createObject(menu, { actionItem });menu.addMenuItem(item);});}Component {id: contextMenuComponentPlasmaExtras.Menu {visualParent: root.visualParentplacement: {if (Plasmoid.location === PlasmaCore.Types.LeftEdge) {return PlasmaExtras.Menu.RightPosedTopAlignedPopup;} else if (Plasmoid.location === PlasmaCore.Types.TopEdge) {return PlasmaExtras.Menu.BottomPosedLeftAlignedPopup;} else if (Plasmoid.location === PlasmaCore.Types.RightEdge) {return PlasmaExtras.Menu.LeftPosedTopAlignedPopup;} else {return PlasmaExtras.Menu.TopPosedLeftAlignedPopup;}}}}Component {id: contextMenuItemComponentPlasmaExtras.MenuItem {property var actionItemtext: actionItem.text ? actionItem.text : ""icon: actionItem.icon ? actionItem.icon : nullcheckable: actionItem.hint === "checked"checked: actionItem.hint === "checked"onClicked: {root.actionClicked(actionItem.actionId);}}}Component {id: emptyMenuItemComponentPlasmaExtras.MenuItem {text: i18nc("@label placeholder for empty menu", "(Empty)")enabled: false}}}