-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
…on required -> or enter to become active. This fixes #10977
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
#include <QAbstractItemView> | ||
#include <QApplication> | ||
#include <QCompleter> | ||
#include <QFont> | ||
#include <QLineEdit> | ||
#include <QShortcut> | ||
|
@@ -288,7 +289,18 @@ void WSearchLineEdit::resizeEvent(QResizeEvent* e) { | |
QString WSearchLineEdit::getSearchText() const { | ||
if (isEnabled()) { | ||
DEBUG_ASSERT(!currentText().isNull()); | ||
return currentText(); | ||
QString text = currentText(); | ||
QLineEdit* pEdit = lineEdit(); | ||
QCompleter* pCompleter = completer(); | ||
if (pCompleter && pEdit && pEdit->hasSelectedText()) { | ||
if (text.startsWith(pCompleter->completionPrefix()) && | ||
pCompleter->completionPrefix().size() == pEdit->cursorPosition()) { | ||
// Search for the entered text until the user has confirmed the | ||
// completion by -> or enter | ||
return pCompleter->completionPrefix(); | ||
} | ||
} | ||
return text; | ||
} else { | ||
return QString(); | ||
} | ||
|
@@ -347,11 +359,23 @@ void WSearchLineEdit::keyPressEvent(QKeyEvent* keyEvent) { | |
slotSaveSearch(); | ||
} | ||
break; | ||
case Qt::Key_Left: | ||
case Qt::Key_Right: | ||
QComboBox::keyPressEvent(keyEvent); | ||
slotTriggerSearch(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ronso0
Member
|
||
return; | ||
case Qt::Key_Enter: | ||
case Qt::Key_Return: | ||
case Qt::Key_Return: { | ||
if (slotClearSearchIfClearButtonHasFocus()) { | ||
return; | ||
} | ||
QLineEdit* pEdit = lineEdit(); | ||
if (pEdit && pEdit->hasSelectedText()) { | ||
QComboBox::keyPressEvent(keyEvent); | ||
slotTriggerSearch(); | ||
return; | ||
} | ||
|
||
if (findCurrentTextIndex() == -1) { | ||
slotSaveSearch(); | ||
} | ||
|
@@ -362,6 +386,7 @@ void WSearchLineEdit::keyPressEvent(QKeyEvent* keyEvent) { | |
emit setLibraryFocus(FocusWidget::TracksTable); | ||
} | ||
return; | ||
} | ||
case Qt::Key_Space: | ||
// Open/close popup with Ctrl + space | ||
if (keyEvent->modifiers() == Qt::ControlModifier) { | ||
|
I don't understand the purpose of this code that causes a severe regression.
#11287