Warning, /plasma/plasma-workspace/applets/clipboard/contents/ui/Menu.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQml 2.15 0009 import org.kde.plasma.extras 2.0 as PlasmaExtras 0010 import org.kde.plasma.components 3.0 as PlasmaComponents3 0011 import org.kde.kirigami 2.20 as Kirigami 0012 0013 PlasmaComponents3.ScrollView { 0014 id: menu 0015 0016 property alias view: menuListView 0017 property alias model: menuListView.model 0018 property bool supportsBarcodes 0019 readonly property int pageUpPageDownSkipCount: menuListView.visibleArea.heightRatio * menuListView.count 0020 0021 background: null 0022 0023 signal itemSelected(string uuid) 0024 signal remove(string uuid) 0025 signal edit(string uuid) 0026 signal barcode(string text) 0027 signal triggerAction(string uuid) 0028 0029 contentWidth: availableWidth - contentItem.leftMargin - contentItem.rightMargin 0030 0031 Keys.onPressed: event => { 0032 if (menuListView.count !== 0) { 0033 switch (event.key) { 0034 case Qt.Key_Home: { 0035 menuListView.currentIndex = 0; 0036 event.accepted = true; 0037 break; 0038 } 0039 case Qt.Key_End: { 0040 menuListView.currentIndex = menuListView.count - 1; 0041 event.accepted = true; 0042 break; 0043 } 0044 case Qt.Key_PageUp: { 0045 menuListView.currentIndex = Math.max(menuListView.currentIndex - pageUpPageDownSkipCount, 0); 0046 event.accepted = true; 0047 break; 0048 } 0049 case Qt.Key_PageDown: { 0050 menuListView.currentIndex = Math.min(menuListView.currentIndex + pageUpPageDownSkipCount, menuListView.count - 1); 0051 event.accepted = true; 0052 break; 0053 } 0054 default: { 0055 event.accepted = false; 0056 break; 0057 } 0058 } 0059 } 0060 } 0061 0062 contentItem: ListView { 0063 id: menuListView 0064 0065 highlight: PlasmaExtras.Highlight { } 0066 highlightMoveDuration: 0 0067 highlightResizeDuration: 0 0068 currentIndex: -1 0069 0070 Connections { 0071 target: main 0072 function onExpandedChanged() { 0073 if (main.expanded) { 0074 menuListView.currentIndex = -1 0075 menuListView.positionViewAtBeginning() 0076 } 0077 } 0078 } 0079 0080 topMargin: Kirigami.Units.largeSpacing 0081 bottomMargin: Kirigami.Units.largeSpacing 0082 leftMargin: Kirigami.Units.largeSpacing 0083 rightMargin: Kirigami.Units.largeSpacing 0084 spacing: Kirigami.Units.smallSpacing 0085 0086 reuseItems: true 0087 0088 delegate: ClipboardItemDelegate { 0089 // FIXME: removing this causes a binding loop 0090 width: menuListView.width - menuListView.leftMargin - menuListView.rightMargin 0091 0092 supportsBarcodes: menu.supportsBarcodes 0093 0094 onItemSelected: uuid => menu.itemSelected(uuid) 0095 onRemove: uuid => menu.remove(uuid) 0096 onEdit: uuid => menu.edit(uuid) 0097 onBarcode: text => menu.barcode(text) 0098 onTriggerAction: uuid => menu.triggerAction(uuid) 0099 0100 Binding { 0101 target: menuListView 0102 // don't change currentIndex if it would make listview scroll 0103 // see https://bugs.kde.org/show_bug.cgi?id=387797 0104 // this is a workaround till https://bugreports.qt.io/browse/QTBUG-114574 gets fixed 0105 // which would allow a proper solution 0106 when: hovered && (y - menuListView.contentY + height + 1 /* border */ < menuListView.height) && (y - menuListView.contentY >= 0) 0107 property: "currentIndex"; value: index 0108 restoreMode: Binding.RestoreBinding 0109 } 0110 } 0111 0112 Keys.onUpPressed: event => { 0113 if (view.currentIndex === 0) { 0114 view.currentIndex = -1; 0115 filter.selectAll(); 0116 } 0117 event.accepted = false; // Forward to KeyNavigation.up 0118 } 0119 0120 Loader { 0121 id: emptyHint 0122 0123 anchors.centerIn: parent 0124 width: parent.width - (Kirigami.Units.gridUnit * 4) 0125 0126 active: menuListView.count === 0 0127 visible: active 0128 asynchronous: true 0129 0130 sourceComponent: PlasmaExtras.PlaceholderMessage { 0131 width: parent.width 0132 readonly property bool hasText: model.filterRegularExpression.length > 0 0133 iconName: hasText ? "edit-none" : "edit-paste" 0134 text: hasText ? i18n("No matches") : i18n("Clipboard is empty") 0135 } 0136 } 0137 } 0138 }