mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-01 11:56:45 +01:00
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)
|
||||
: QWidget(NULL),
|
||||
desktop_(qApp->desktop()),
|
||||
event_target_(event_target)
|
||||
event_target_(event_target),
|
||||
active_result_(0)
|
||||
{
|
||||
setWindowFlags(Qt::Popup);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
@ -57,6 +58,8 @@ void GlobalSearchTooltip::SetResults(const SearchProvider::ResultList& results)
|
||||
widgets_.clear();
|
||||
result_buttons_.clear();
|
||||
|
||||
active_result_ = 0;
|
||||
|
||||
// Using a QVBoxLayout here made some weird flickering that I couldn't figure
|
||||
// out how to fix, so do layout manually.
|
||||
int w = 0;
|
||||
@ -239,9 +242,7 @@ void GlobalSearchTooltip::SwitchProvider() {
|
||||
|
||||
// Check the new one. The auto exclusive group will take care of unchecking
|
||||
// the old one.
|
||||
const int new_index = (old_index + 1) % result_buttons_.count();
|
||||
result_buttons_[new_index]->setChecked(true);
|
||||
|
||||
emit ActiveResultChanged(new_index);
|
||||
active_result_ = (old_index + 1) % result_buttons_.count();
|
||||
result_buttons_[active_result_]->setChecked(true);
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,11 @@ public:
|
||||
void SetResults(const SearchProvider::ResultList& results);
|
||||
void ShowAt(const QPoint& pointing_to);
|
||||
|
||||
int ActiveResultIndex() const { return active_result_; }
|
||||
qreal ArrowOffset() const;
|
||||
|
||||
bool event(QEvent* e);
|
||||
|
||||
signals:
|
||||
void ActiveResultChanged(int new_index);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*);
|
||||
|
||||
@ -74,6 +72,7 @@ private:
|
||||
|
||||
QWidgetList widgets_;
|
||||
QList<QAbstractButton*> result_buttons_;
|
||||
int active_result_;
|
||||
};
|
||||
|
||||
#endif // GLOBALSEARCHTOOLTIP_H
|
||||
|
@ -482,8 +482,18 @@ void GlobalSearchWidget::LoadTracks(QAction* trigger) {
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
int id = engine_->LoadTracksAsync(
|
||||
index.data(Role_PrimaryResult).value<SearchProvider::Result>());
|
||||
int result_index = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user