Warning, /plasma/plasma-desktop/applets/kicker/package/contents/ui/SideBarItem.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2013-2015 Eike Hein <hein@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.15
0008 
0009 import org.kde.kquickcontrolsaddons 2.0
0010 import org.kde.plasma.core as PlasmaCore
0011 import org.kde.kirigami 2.20 as Kirigami
0012 import org.kde.plasma.plasmoid 2.0
0013 
0014 import "code/tools.js" as Tools
0015 
0016 Item {
0017     id: item
0018 
0019     width: root.width
0020     height: root.width
0021 
0022     signal actionTriggered(string actionId, variant actionArgument)
0023     signal aboutToShowActionMenu(variant actionMenu)
0024 
0025     property bool hasActionList: ((model.favoriteId !== null)
0026         || (("hasActionList" in model) && (model.hasActionList !== null)))
0027     property int itemIndex: model.index
0028 
0029     onAboutToShowActionMenu: actionMenu => {
0030         const actionList = (model.hasActionList !== null) ? model.actionList : [];
0031         Tools.fillActionMenu(i18n, actionMenu, actionList, repeater.model, model.favoriteId);
0032     }
0033 
0034     onActionTriggered: (actionId, actionArgument) => {
0035         if (Tools.triggerAction(repeater.model, model.index, actionId, actionArgument) === true) {
0036             kicker.expanded = false;
0037         }
0038     }
0039 
0040     function openActionMenu(visualParent, x, y) {
0041         aboutToShowActionMenu(actionMenu);
0042         actionMenu.visualParent = visualParent;
0043         actionMenu.open(x, y);
0044     }
0045 
0046     ActionMenu {
0047         id: actionMenu
0048 
0049         onActionClicked: {
0050             actionTriggered(actionId, actionArgument);
0051         }
0052     }
0053 
0054     Kirigami.Icon {
0055         anchors.fill: parent
0056 
0057         active: toolTip.containsMouse
0058 
0059         source: model.decoration
0060     }
0061 
0062     MouseEventListener {
0063         id: listener
0064 
0065         anchors {
0066             fill: parent
0067             leftMargin: - sideBar.margins.left
0068             rightMargin: - sideBar.margins.right
0069         }
0070 
0071         enabled: (item.parent && !item.parent.animating)
0072 
0073         property bool pressed: false
0074         property int pressX: -1
0075         property int pressY: -1
0076 
0077         hoverEnabled: true
0078         acceptedButtons: Qt.LeftButton | Qt.RightButton
0079 
0080         onPressed: {
0081             if (mouse.buttons & Qt.RightButton) {
0082                 if (item.hasActionList) {
0083                     item.openActionMenu(item, mouse.x, mouse.y);
0084                 }
0085             } else {
0086                 pressed = true;
0087                 pressX = mouse.x;
0088                 pressY = mouse.y;
0089             }
0090         }
0091 
0092         onReleased: {
0093             if (pressed) {
0094                 repeater.model.trigger(index, "", null);
0095                 kicker.expanded = false;
0096             }
0097 
0098             pressed = false;
0099             pressX = -1;
0100             pressY = -1;
0101         }
0102 
0103         onContainsMouseChanged: {
0104             if (!containsMouse) {
0105                 pressed = false;
0106                 pressX = -1;
0107                 pressY = -1;
0108             }
0109         }
0110 
0111         onPositionChanged: {
0112             if (pressX !== -1 && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) {
0113                 kicker.dragSource = item;
0114                 dragHelper.startDrag(kicker, model.url, model.icon);
0115                 pressed = false;
0116                 pressX = -1;
0117                 pressY = -1;
0118 
0119                 return;
0120             }
0121         }
0122     }
0123 
0124     PlasmaCore.ToolTipArea {
0125         id: toolTip
0126 
0127         property string text: model.display
0128 
0129         anchors {
0130             fill: parent
0131             leftMargin: - sideBar.margins.left
0132             rightMargin: - sideBar.margins.right
0133         }
0134 
0135         interactive: false
0136         location: (((Plasmoid.location === PlasmaCore.Types.RightEdge)
0137             || (Qt.application.layoutDirection === Qt.RightToLeft))
0138             ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.LeftEdge)
0139 
0140         mainItem: toolTipDelegate
0141     }
0142 }