mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
Don't re-show the results list if more results arrive after the user has explicitly closed it. Also don't continue to show results when the user has backspaced to < 3 characters.
This commit is contained in:
parent
f80ac47931
commit
b3f6e46c23
@ -54,6 +54,7 @@ GlobalSearchWidget::GlobalSearchWidget(QWidget* parent)
|
||||
engine_(NULL),
|
||||
last_id_(0),
|
||||
order_arrived_counter_(0),
|
||||
closed_since_search_began_(false),
|
||||
front_model_(new QStandardItemModel(this)),
|
||||
back_model_(new QStandardItemModel(this)),
|
||||
current_model_(front_model_),
|
||||
@ -218,9 +219,11 @@ void GlobalSearchWidget::showEvent(QShowEvent* e) {
|
||||
|
||||
void GlobalSearchWidget::TextEdited(const QString& text) {
|
||||
const QString trimmed_text = text.trimmed();
|
||||
closed_since_search_began_ = false;
|
||||
|
||||
if (trimmed_text.length() < 3) {
|
||||
RepositionPopup();
|
||||
last_id_ = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -245,7 +248,9 @@ void GlobalSearchWidget::SwapModels() {
|
||||
view_->setModel(front_proxy_);
|
||||
connect(view_->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
|
||||
SLOT(UpdateTooltip()));
|
||||
RepositionPopup();
|
||||
|
||||
if (!closed_since_search_began_)
|
||||
RepositionPopup();
|
||||
}
|
||||
|
||||
void GlobalSearchWidget::AddResults(int id, const SearchProvider::ResultList& results) {
|
||||
@ -305,7 +310,8 @@ void GlobalSearchWidget::AddResults(int id, const SearchProvider::ResultList& re
|
||||
|
||||
order_arrived_counter_ ++;
|
||||
|
||||
RepositionPopup();
|
||||
if (!closed_since_search_began_)
|
||||
RepositionPopup();
|
||||
}
|
||||
|
||||
void GlobalSearchWidget::RepositionPopup() {
|
||||
@ -314,6 +320,8 @@ void GlobalSearchWidget::RepositionPopup() {
|
||||
return;
|
||||
}
|
||||
|
||||
closed_since_search_began_ = false;
|
||||
|
||||
int h = view_->sizeHintForRow(0) * float(0.5 +
|
||||
qBound(kMinVisibleItems, front_model_->rowCount(), kMaxVisibleItems));
|
||||
int w = ui_->search->width();
|
||||
@ -652,6 +660,7 @@ void GlobalSearchWidget::CombineResults(const QModelIndex& superior, const QMode
|
||||
}
|
||||
|
||||
void GlobalSearchWidget::HidePopup() {
|
||||
closed_since_search_began_ = true;
|
||||
if (tooltip_)
|
||||
tooltip_->hide();
|
||||
view_->hide();
|
||||
|
@ -127,6 +127,7 @@ private:
|
||||
GlobalSearch* engine_;
|
||||
int last_id_;
|
||||
int order_arrived_counter_;
|
||||
bool closed_since_search_began_;
|
||||
|
||||
QMap<int, QModelIndex> art_requests_;
|
||||
QMap<int, QAction*> track_requests_;
|
||||
|
@ -335,7 +335,7 @@ msgstr ""
|
||||
msgid "Add action"
|
||||
msgstr ""
|
||||
|
||||
#: globalsearch/globalsearchwidget.cpp:100
|
||||
#: globalsearch/globalsearchwidget.cpp:101
|
||||
msgid "Add and play now"
|
||||
msgstr ""
|
||||
|
||||
@ -439,7 +439,7 @@ msgstr ""
|
||||
msgid "Add to another playlist"
|
||||
msgstr ""
|
||||
|
||||
#: globalsearch/globalsearchwidget.cpp:99
|
||||
#: globalsearch/globalsearchwidget.cpp:100
|
||||
#: ../bin/src/ui_albumcovermanager.h:152
|
||||
msgid "Add to playlist"
|
||||
msgstr ""
|
||||
@ -3095,7 +3095,7 @@ msgstr ""
|
||||
msgid "Queue selected tracks"
|
||||
msgstr ""
|
||||
|
||||
#: globalsearch/globalsearchwidget.cpp:101 library/libraryview.cpp:251
|
||||
#: globalsearch/globalsearchwidget.cpp:102 library/libraryview.cpp:251
|
||||
#: ui/mainwindow.cpp:1338
|
||||
msgid "Queue track"
|
||||
msgstr ""
|
||||
@ -3234,11 +3234,11 @@ msgstr ""
|
||||
msgid "Repeat track"
|
||||
msgstr ""
|
||||
|
||||
#: globalsearch/globalsearchwidget.cpp:103
|
||||
#: globalsearch/globalsearchwidget.cpp:104
|
||||
msgid "Replace and play now"
|
||||
msgstr ""
|
||||
|
||||
#: devices/deviceview.cpp:218 globalsearch/globalsearchwidget.cpp:102
|
||||
#: devices/deviceview.cpp:218 globalsearch/globalsearchwidget.cpp:103
|
||||
#: internet/internetservice.cpp:63 library/libraryview.cpp:245
|
||||
#: widgets/fileviewlist.cpp:33
|
||||
msgid "Replace current playlist"
|
||||
@ -4542,7 +4542,7 @@ msgstr ""
|
||||
msgid "does not contain"
|
||||
msgstr ""
|
||||
|
||||
#: globalsearch/globalsearchwidget.cpp:699
|
||||
#: globalsearch/globalsearchwidget.cpp:708
|
||||
msgid "e.g."
|
||||
msgstr ""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user