mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-14 02:14:21 +01:00
Don't run searches for a preview widget while it's hidden, and run one as soon as the sort page is shown
This commit is contained in:
parent
ffdfc0ed34
commit
d214d36a1d
@ -57,11 +57,15 @@ public:
|
||||
|
||||
class QueryWizardPlugin::SortPage : public QWizardPage {
|
||||
public:
|
||||
SortPage(QWidget* parent, int next_id)
|
||||
: QWizardPage(parent), next_id_(next_id) {}
|
||||
SortPage(QueryWizardPlugin* plugin, QWidget* parent, int next_id)
|
||||
: QWizardPage(parent), next_id_(next_id), plugin_(plugin) {}
|
||||
|
||||
void showEvent(QShowEvent*) { plugin_->UpdateSortPreview(); }
|
||||
|
||||
int nextId() const { return next_id_; }
|
||||
int next_id_;
|
||||
|
||||
QueryWizardPlugin* plugin_;
|
||||
};
|
||||
|
||||
|
||||
@ -86,7 +90,7 @@ int QueryWizardPlugin::CreatePages(QWizard* wizard, int finish_page_id) {
|
||||
// Create the UI
|
||||
search_page_ = new SearchPage(wizard);
|
||||
|
||||
QWizardPage* sort_page = new SortPage(wizard, finish_page_id);
|
||||
QWizardPage* sort_page = new SortPage(this, wizard, finish_page_id);
|
||||
sort_ui_.reset(new Ui_SmartPlaylistQuerySortPage);
|
||||
sort_ui_->setupUi(sort_page);
|
||||
|
||||
|
@ -63,8 +63,8 @@ void SearchPreview::Update(const Search& search) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (generator_) {
|
||||
// It's busy generating something already
|
||||
if (generator_ || isHidden()) {
|
||||
// It's busy generating something already, or the widget isn't visible
|
||||
pending_search_ = search;
|
||||
return;
|
||||
}
|
||||
@ -72,6 +72,16 @@ void SearchPreview::Update(const Search& search) {
|
||||
RunSearch(search);
|
||||
}
|
||||
|
||||
void SearchPreview::showEvent(QShowEvent* e) {
|
||||
if (pending_search_.is_valid() && !generator_) {
|
||||
// There was a search waiting while we were hidden, so run it now
|
||||
RunSearch(pending_search_);
|
||||
pending_search_ = Search();
|
||||
}
|
||||
|
||||
QWidget::showEvent(e);
|
||||
}
|
||||
|
||||
void SearchPreview::RunSearch(const Search& search) {
|
||||
generator_.reset(new QueryGenerator);
|
||||
generator_->set_library(backend_);
|
||||
|
@ -42,6 +42,9 @@ public:
|
||||
|
||||
void Update(const Search& search);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent*);
|
||||
|
||||
private:
|
||||
void RunSearch(const Search& search);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user