Skip to content

Commit

Permalink
Merge pull request #4 from ronso0/search-clear-fix
Browse files Browse the repository at this point in the history
Search clear fix
  • Loading branch information
poelzi authored Feb 15, 2021
2 parents 895d3c0 + 6a4f9d9 commit 9ab695e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/widget/wsearchlineedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ bool WSearchLineEdit::eventFilter(QObject* obj, QEvent* event) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Up) {
if (findCurrentTextIndex() == 0) {
setCurrentIndex(-1);
setCurrentText("");
if (findCurrentTextIndex() == 0 ||
(findCurrentTextIndex() == -1 && !currentText().isEmpty())) {
slotClearSearch();
return true;
}
} else if (keyEvent->key() == Qt::Key_Down) {
Expand Down Expand Up @@ -521,7 +521,9 @@ void WSearchLineEdit::slotClearSearch() {
// before returning the whole (and probably huge) library.
// No need to manually trigger a search at this point!
// See also: https://bugs.launchpad.net/mixxx/+bug/1635087
clear();
// Note that clear() would not just clear the line edit but
// erase all combobox items, thus clear the entire search history.
setCurrentText("");
// Refocus the edit field
setFocus(Qt::OtherFocusReason);
}
Expand Down

0 comments on commit 9ab695e

Please sign in to comment.