KRunner: Handle escape key in history view more gracefully

Instead of adding an unprintable character to the UI the history view is
closed and the text field it focused.

To prevent unprintable characters like backspace a regex is used,
just like we already do in the ResultsView Keys.onPressed slot.

BUG: 433723
FIXED-IN: 5.21.2
wilder-5.22
Alexander Lohnau 5 years ago
parent 1ea9d78738
commit 83982f8e5c
  1. 7
      lookandfeel/contents/runcommand/RunCommand.qml

@ -325,7 +325,12 @@ ColumnLayout {
} else if (ctrl && event.key === Qt.Key_K) {
decrementCurrentIndex()
} else if (event.text !== "") {
queryField.text += event.text;
// This prevents unprintable control characters from being inserted
if (event.key == Qt.Key_Escape) {
root.showHistory = false
} else if (!/[\x00-\x1F\x7F]/.test(event.text)) {
queryField.text += event.text;
}
queryField.focus = true;
}
}

Loading…
Cancel
Save