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 2.5
0008 import QtQuick.Controls 2.5 as QQC2
0009 
0010 import org.kde.kirigami 2.14 as Kirigami
0011 
0012 Kirigami.BasicListItem
0013 {
0014     id: item
0015     property QtObject action: null
0016     checked: action.checked
0017     icon: action.iconName
0018     separatorVisible: false
0019     visible: action.enabled
0020 
0021     onClicked: trigger()
0022     Keys.onEnterPressed: trigger()
0023     Keys.onReturnPressed: trigger()
0024 
0025     function trigger() {
0026         drawer.resetMenu()
0027         action.trigger()
0028     }
0029 
0030     Kirigami.MnemonicData.enabled: item.enabled && item.visible
0031     Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.MenuItem
0032     Kirigami.MnemonicData.label: action.text
0033     label: Kirigami.MnemonicData.richTextLabel
0034 
0035     QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
0036     QQC2.ToolTip.visible: hovered && p0.nativeText.length > 0
0037     QQC2.ToolTip.text: p0.nativeText
0038 
0039     readonly property var p0: Shortcut {
0040         sequence: item.Kirigami.MnemonicData.sequence
0041         onActivated: item.clicked()
0042     }
0043 
0044     // Using the generic onPressed so individual instances can override
0045     // behaviour using Keys.on{Up,Down}Pressed
0046     Keys.onPressed: {
0047         if (event.accepted) {
0048             return
0049         }
0050 
0051         // Using forceActiveFocus here since the item may be in a focus scope
0052         // and just setting focus won't focus the scope.
0053         if (event.key === Qt.Key_Up) {
0054             nextItemInFocusChain(false).forceActiveFocus()
0055             event.accepted = true
0056         } else if (event.key === Qt.Key_Down) {
0057             nextItemInFocusChain(true).forceActiveFocus()
0058             event.accepted = true
0059         }
0060     }
0061 }