Use the selected provider when adding songs to the playlist
This commit is contained in:
parent
847d90d117
commit
f2062cb68a
@ -38,7 +38,8 @@ const qreal GlobalSearchTooltip::kArrowHeight = 10.0;
|
|||||||
GlobalSearchTooltip::GlobalSearchTooltip(QWidget* event_target)
|
GlobalSearchTooltip::GlobalSearchTooltip(QWidget* event_target)
|
||||||
: QWidget(NULL),
|
: QWidget(NULL),
|
||||||
desktop_(qApp->desktop()),
|
desktop_(qApp->desktop()),
|
||||||
event_target_(event_target)
|
event_target_(event_target),
|
||||||
|
active_result_(0)
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::Popup);
|
setWindowFlags(Qt::Popup);
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
@ -57,6 +58,8 @@ void GlobalSearchTooltip::SetResults(const SearchProvider::ResultList& results)
|
|||||||
widgets_.clear();
|
widgets_.clear();
|
||||||
result_buttons_.clear();
|
result_buttons_.clear();
|
||||||
|
|
||||||
|
active_result_ = 0;
|
||||||
|
|
||||||
// Using a QVBoxLayout here made some weird flickering that I couldn't figure
|
// Using a QVBoxLayout here made some weird flickering that I couldn't figure
|
||||||
// out how to fix, so do layout manually.
|
// out how to fix, so do layout manually.
|
||||||
int w = 0;
|
int w = 0;
|
||||||
@ -239,9 +242,7 @@ void GlobalSearchTooltip::SwitchProvider() {
|
|||||||
|
|
||||||
// Check the new one. The auto exclusive group will take care of unchecking
|
// Check the new one. The auto exclusive group will take care of unchecking
|
||||||
// the old one.
|
// the old one.
|
||||||
const int new_index = (old_index + 1) % result_buttons_.count();
|
active_result_ = (old_index + 1) % result_buttons_.count();
|
||||||
result_buttons_[new_index]->setChecked(true);
|
result_buttons_[active_result_]->setChecked(true);
|
||||||
|
|
||||||
emit ActiveResultChanged(new_index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,13 +43,11 @@ public:
|
|||||||
void SetResults(const SearchProvider::ResultList& results);
|
void SetResults(const SearchProvider::ResultList& results);
|
||||||
void ShowAt(const QPoint& pointing_to);
|
void ShowAt(const QPoint& pointing_to);
|
||||||
|
|
||||||
|
int ActiveResultIndex() const { return active_result_; }
|
||||||
qreal ArrowOffset() const;
|
qreal ArrowOffset() const;
|
||||||
|
|
||||||
bool event(QEvent* e);
|
bool event(QEvent* e);
|
||||||
|
|
||||||
signals:
|
|
||||||
void ActiveResultChanged(int new_index);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent*);
|
void paintEvent(QPaintEvent*);
|
||||||
|
|
||||||
@ -74,6 +72,7 @@ private:
|
|||||||
|
|
||||||
QWidgetList widgets_;
|
QWidgetList widgets_;
|
||||||
QList<QAbstractButton*> result_buttons_;
|
QList<QAbstractButton*> result_buttons_;
|
||||||
|
int active_result_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLOBALSEARCHTOOLTIP_H
|
#endif // GLOBALSEARCHTOOLTIP_H
|
||||||
|
@ -482,8 +482,18 @@ void GlobalSearchWidget::LoadTracks(QAction* trigger) {
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int id = engine_->LoadTracksAsync(
|
int result_index = 0;
|
||||||
index.data(Role_PrimaryResult).value<SearchProvider::Result>());
|
if (tooltip_ && tooltip_->isVisible()) {
|
||||||
|
result_index = tooltip_->ActiveResultIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
const SearchProvider::ResultList results =
|
||||||
|
index.data(Role_AllResults).value<SearchProvider::ResultList>();
|
||||||
|
|
||||||
|
if (result_index < 0 || result_index >= results.count())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int id = engine_->LoadTracksAsync(results[result_index]);
|
||||||
track_requests_[id] = trigger;
|
track_requests_[id] = trigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user