Warning, /plasma/plasma-desktop/applets/kicker/package/contents/ui/ItemGridDelegate.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 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.plasma.components 3.0 as PlasmaComponents3
0010 import org.kde.plasma.core as PlasmaCore
0011 import org.kde.kirigami 2.20 as Kirigami
0012
0013 import "code/tools.js" as Tools
0014
0015 Item {
0016 id: item
0017
0018 width: GridView.view.cellWidth
0019 height: width
0020
0021 enabled: !model.disabled
0022
0023 property bool showLabel: true
0024
0025 property int itemIndex: model.index
0026 property string favoriteId: model.favoriteId !== undefined ? model.favoriteId : ""
0027 property url url: model.url !== undefined ? model.url : ""
0028 property variant icon: model.decoration !== undefined ? model.decoration : ""
0029 property var m: model
0030 property bool hasActionList: ((model.favoriteId !== null)
0031 || (("hasActionList" in model) && (model.hasActionList === true)))
0032
0033 Accessible.role: Accessible.MenuItem
0034 Accessible.name: model.display
0035
0036 function openActionMenu(x, y) {
0037 var actionList = hasActionList ? model.actionList : [];
0038 Tools.fillActionMenu(i18n, actionMenu, actionList, GridView.view.model.favoritesModel, model.favoriteId);
0039 actionMenu.visualParent = item;
0040 actionMenu.open(x, y);
0041 }
0042
0043 function actionTriggered(actionId, actionArgument) {
0044 var close = (Tools.triggerAction(GridView.view.model, model.index, actionId, actionArgument) === true);
0045
0046 if (close) {
0047 root.toggle();
0048 }
0049 }
0050
0051 Kirigami.Icon {
0052 id: icon
0053
0054 y: item.showLabel ? (2 * highlightItemSvg.margins.top) : undefined
0055
0056 anchors.horizontalCenter: parent.horizontalCenter
0057 anchors.verticalCenter: item.showLabel ? undefined : parent.verticalCenter
0058
0059 width: iconSize
0060 height: width
0061
0062 animated: false
0063
0064 source: model.decoration
0065 }
0066
0067 PlasmaComponents3.Label {
0068 id: label
0069
0070 visible: item.showLabel
0071
0072 anchors {
0073 top: icon.bottom
0074 topMargin: Kirigami.Units.smallSpacing
0075 left: parent.left
0076 leftMargin: highlightItemSvg.margins.left
0077 right: parent.right
0078 rightMargin: highlightItemSvg.margins.right
0079 }
0080
0081 horizontalAlignment: Text.AlignHCenter
0082
0083 maximumLineCount: 2
0084 elide: Text.ElideMiddle
0085 wrapMode: Text.Wrap
0086
0087 color: "white" // FIXME TODO: Respect theming?
0088
0089 text: ("name" in model ? model.name : model.display)
0090 textFormat: Text.PlainText
0091 }
0092
0093 PlasmaCore.ToolTipArea {
0094 id: toolTip
0095
0096 property string text: model.display
0097
0098 anchors.fill: parent
0099 active: root.visible && label.truncated
0100 mainItem: toolTipDelegate
0101
0102 onContainsMouseChanged: item.GridView.view.itemContainsMouseChanged(containsMouse)
0103 }
0104
0105 Keys.onPressed: event => {
0106 if (event.key === Qt.Key_Menu && hasActionList) {
0107 event.accepted = true;
0108 openActionMenu(item);
0109 } else if ((event.key === Qt.Key_Enter || event.key === Qt.Key_Return)) {
0110 event.accepted = true;
0111
0112 if ("trigger" in GridView.view.model) {
0113 GridView.view.model.trigger(index, "", null);
0114 root.toggle();
0115 }
0116
0117 itemGrid.itemActivated(index, "", null);
0118 }
0119 }
0120 }