[applets/clipboard] Delete items with delete key

Pressing the delete key will now delete the highlighted list item under
any of the following circumstances:

1. A list item is selected and has focus
2. A list item is selected and the search field has focus but it is
   empty or the insertion point is at the end of the string (in either
   case, pressing the delete key would otherwise do nothing)

This allows quickly and easily deleting clipboard items using only the
keyboard, including after using the search field to filter it down.

BUG: 439174
FIXED-IN: 5.78
wilder-5.24
Nate Graham 5 years ago
parent f40bbbff06
commit 8416e3de66
  1. 3
      applets/clipboard/contents/ui/ClipboardItemDelegate.qml
  2. 13
      applets/clipboard/contents/ui/ClipboardPage.qml

@ -60,6 +60,9 @@ PlasmaExtras.ListItem {
menuListView.currentIndex = -1
}
}
Keys.onDeletePressed: {
remove(UuidRole);
}
ListView.onIsCurrentItemChanged: {
if (ListView.isCurrentItem) {

@ -90,6 +90,19 @@ ColumnLayout {
clearButtonShown: true
Layout.fillWidth: true
// Only override delete key behavior to delete list items if
// it would do nothing
Keys.enabled: filter.text.length == 0 || filter.cursorPosition == filter.length
Keys.onDeletePressed: {
let clipboardItemIndex = clipboardMenu.view.currentIndex
if (clipboardItemIndex != -1) {
let uuid = clipboardMenu.model.get(clipboardItemIndex).UuidRole
if (uuid) {
clipboardMenu.view.currentItem.remove(uuid);
}
}
}
Connections {
target: main
function onClearSearchField() {

Loading…
Cancel
Save