Warning, /plasma/discover/discover/qml/ActionListItem.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@blue-systems.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Controls as QQC2 0009 import QtQuick.Layouts 0010 0011 import org.kde.kirigami as Kirigami 0012 import org.kde.kirigami.delegates as KD 0013 0014 QQC2.ItemDelegate { 0015 id: item 0016 0017 Layout.fillWidth: true 0018 0019 highlighted: checked 0020 visible: enabled 0021 0022 Keys.onEnterPressed: trigger() 0023 Keys.onReturnPressed: trigger() 0024 0025 function trigger() { 0026 if (enabled) { 0027 if (typeof drawer !== "undefined") { 0028 drawer.resetMenu() 0029 } 0030 action.trigger() 0031 } 0032 } 0033 0034 property string subtitle 0035 property string stateIconName 0036 0037 contentItem: RowLayout { 0038 spacing: Kirigami.Units.largeSpacing 0039 KD.IconTitleSubtitle { 0040 Layout.fillWidth: true 0041 icon: icon.fromControlsIcon(item.icon) 0042 title: item.text 0043 subtitle: item.subtitle 0044 selected: item.highlighted 0045 font: item.font 0046 } 0047 Kirigami.Icon { 0048 Layout.fillHeight: true 0049 visible: item.stateIconName.length > 0 0050 source: item.stateIconName 0051 implicitWidth: Kirigami.Units.iconSizes.sizeForLabels 0052 implicitHeight: Kirigami.Units.iconSizes.sizeForLabels 0053 } 0054 } 0055 0056 Kirigami.MnemonicData.enabled: item.enabled && item.visible 0057 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.MenuItem 0058 Kirigami.MnemonicData.label: action.text 0059 0060 // Note changing text here does not affect the action.text 0061 text: Kirigami.MnemonicData.richTextLabel 0062 0063 QQC2.ToolTip.text: shortcut.nativeText 0064 QQC2.ToolTip.visible: (Kirigami.Settings.tabletMode ? down : hovered) && QQC2.ToolTip.text.length > 0 0065 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0066 0067 Shortcut { 0068 id: shortcut 0069 sequence: item.Kirigami.MnemonicData.sequence 0070 onActivated: item.trigger() 0071 } 0072 0073 // Using the generic onPressed so individual instances can override 0074 // behaviour using Keys.on{Up,Down}Pressed 0075 Keys.onPressed: event => { 0076 if (event.accepted) { 0077 return 0078 } 0079 0080 // Using forceActiveFocus here since the item may be in a focus scope 0081 // and just setting focus won't focus the scope. 0082 if (event.key === Qt.Key_Up) { 0083 nextItemInFocusChain(false).forceActiveFocus() 0084 event.accepted = true 0085 } else if (event.key === Qt.Key_Down) { 0086 nextItemInFocusChain(true).forceActiveFocus() 0087 event.accepted = true 0088 } 0089 } 0090 }