Clicking an artist or tag in the song info tabs now does a global search instead of searching just last.fm
This commit is contained in:
parent
ccb1a745f6
commit
d74d4d65f0
@ -258,6 +258,15 @@ void GlobalSearchWidget::SwapModels() {
|
||||
RepositionPopup();
|
||||
}
|
||||
|
||||
void GlobalSearchWidget::StartSearch(const QString& query) {
|
||||
ui_->search->setText(query);
|
||||
TextEdited(query);
|
||||
|
||||
// Swap models immediately
|
||||
swap_models_timer_->stop();
|
||||
SwapModels();
|
||||
}
|
||||
|
||||
void GlobalSearchWidget::AddResults(int id, const SearchProvider::ResultList& results) {
|
||||
if (id != last_id_)
|
||||
return;
|
||||
|
@ -70,6 +70,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void ReloadSettings();
|
||||
void StartSearch(const QString& query);
|
||||
|
||||
signals:
|
||||
void AddToPlaylist(QMimeData* data);
|
||||
|
@ -221,7 +221,7 @@ void SongInfoBase::ConnectWidget(QWidget* widget) {
|
||||
connect(widget, SIGNAL(ShowSettingsDialog()), SIGNAL(ShowSettingsDialog()));
|
||||
}
|
||||
|
||||
if (m->indexOfSignal("AddToPlaylist(QMimeData*)") != -1) {
|
||||
connect(widget, SIGNAL(AddToPlaylist(QMimeData*)), SIGNAL(AddToPlaylist(QMimeData*)));
|
||||
if (m->indexOfSignal("DoGlobalSearch(QString)") != -1) {
|
||||
connect(widget, SIGNAL(DoGlobalSearch(QString)), SIGNAL(DoGlobalSearch(QString)));
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public slots:
|
||||
|
||||
signals:
|
||||
void ShowSettingsDialog();
|
||||
void AddToPlaylist(QMimeData* data);
|
||||
void DoGlobalSearch(const QString& query);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* e);
|
||||
|
@ -113,8 +113,7 @@ void TagWidgetTag::contextMenuEvent(QContextMenuEvent*) {
|
||||
|
||||
TagWidget::TagWidget(Type type, QWidget* parent)
|
||||
: QWidget(parent),
|
||||
type_(type),
|
||||
menu_(NULL)
|
||||
type_(type)
|
||||
{
|
||||
setLayout(new FlowLayout(4, 6, 4));
|
||||
}
|
||||
@ -130,70 +129,10 @@ void TagWidget::AddTag(const QString& tag) {
|
||||
tags_ << widget;
|
||||
}
|
||||
|
||||
void TagWidget::EnsureMenuCreated() {
|
||||
if (menu_)
|
||||
return;
|
||||
|
||||
menu_ = new QMenu(this);
|
||||
switch (type_) {
|
||||
case Type_Tags:
|
||||
menu_->addAction(QIcon(":/last.fm/as.png"), tr("Play last.fm tag radio"),
|
||||
this, SLOT(PlayLastFmTagRadio()));
|
||||
break;
|
||||
|
||||
case Type_Artists:
|
||||
menu_->addAction(QIcon(":/last.fm/as.png"), tr("Play last.fm artist radio"),
|
||||
this, SLOT(PlayLastFmArtistRadio()));
|
||||
menu_->addAction(IconLoader::Load("folder-sound"), tr("Play from my Library"),
|
||||
this, SLOT(PlayFromLibrary()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TagWidget::TagClicked() {
|
||||
TagWidgetTag* tag = qobject_cast<TagWidgetTag*>(sender());
|
||||
if (!tag)
|
||||
return;
|
||||
|
||||
EnsureMenuCreated();
|
||||
|
||||
context_item_ = tag->text();
|
||||
menu_->popup(tag->mapToGlobal(tag->rect().bottomLeft()));
|
||||
}
|
||||
|
||||
void TagWidget::PlayLastFmArtistRadio() {
|
||||
PlayLastFm("lastfm://artist/%1/similarartists");
|
||||
}
|
||||
|
||||
void TagWidget::PlayLastFmTagRadio() {
|
||||
PlayLastFm("lastfm://globaltags/%1");
|
||||
}
|
||||
|
||||
void TagWidget::PlayFromLibrary() {
|
||||
using smart_playlists::GeneratorMimeData;
|
||||
using smart_playlists::GeneratorPtr;
|
||||
using smart_playlists::QueryGenerator;
|
||||
using smart_playlists::Search;
|
||||
using smart_playlists::SearchTerm;
|
||||
|
||||
GeneratorPtr gen(new QueryGenerator(QString(), Search(
|
||||
Search::Type_And, Search::TermList() <<
|
||||
SearchTerm(SearchTerm::Field_Artist, SearchTerm::Op_Contains, context_item_),
|
||||
Search::Sort_FieldAsc, SearchTerm::Field_Album, 100)));
|
||||
emit AddToPlaylist(new GeneratorMimeData(gen));
|
||||
}
|
||||
|
||||
void TagWidget::PlayLastFm(const QString& url_pattern) {
|
||||
LastFMService* last_fm = InternetModel::Service<LastFMService>();
|
||||
if (!last_fm->IsAuthenticated()) {
|
||||
last_fm->ShowConfig();
|
||||
return;
|
||||
}
|
||||
|
||||
QUrl url(url_pattern.arg(context_item_));
|
||||
PlaylistItemPtr item(last_fm->PlaylistItemForUrl(url));
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
emit AddToPlaylist(new PlaylistItemMimeData(item));
|
||||
emit DoGlobalSearch(tag->text());
|
||||
}
|
||||
|
@ -83,25 +83,18 @@ public:
|
||||
|
||||
signals:
|
||||
void AddToPlaylist(QMimeData* data);
|
||||
void DoGlobalSearch(const QString& query);
|
||||
|
||||
private slots:
|
||||
void TagClicked();
|
||||
|
||||
void PlayLastFmTagRadio();
|
||||
void PlayLastFmArtistRadio();
|
||||
void PlayFromLibrary();
|
||||
|
||||
private:
|
||||
void EnsureMenuCreated();
|
||||
void PlayLastFm(const QString& url_pattern);
|
||||
|
||||
private:
|
||||
Type type_;
|
||||
QIcon icon_;
|
||||
QList<TagWidgetTag*> tags_;
|
||||
|
||||
QString context_item_;
|
||||
QMenu* menu_;
|
||||
};
|
||||
|
||||
#endif // TAGWIDGET_H
|
||||
|
@ -111,17 +111,17 @@ msgid "%L1 total plays"
|
||||
msgstr ""
|
||||
|
||||
#: transcoder/transcodedialog.cpp:198
|
||||
#, c-format
|
||||
#, c-format, qt-plural-format
|
||||
msgid "%n failed"
|
||||
msgstr ""
|
||||
|
||||
#: transcoder/transcodedialog.cpp:193
|
||||
#, c-format
|
||||
#, c-format, qt-plural-format
|
||||
msgid "%n finished"
|
||||
msgstr ""
|
||||
|
||||
#: transcoder/transcodedialog.cpp:188
|
||||
#, c-format
|
||||
#, c-format, qt-plural-format
|
||||
msgid "%n remaining"
|
||||
msgstr ""
|
||||
|
||||
@ -632,7 +632,7 @@ msgstr ""
|
||||
msgid "Are you sure you want to delete the \"%1\" preset?"
|
||||
msgstr ""
|
||||
|
||||
#: internet/groovesharkservice.cpp:905
|
||||
#: internet/groovesharkservice.cpp:906
|
||||
msgid "Are you sure you want to delete this playlist?"
|
||||
msgstr ""
|
||||
|
||||
@ -1044,7 +1044,7 @@ msgstr ""
|
||||
msgid "Convert any music that the device can't play"
|
||||
msgstr ""
|
||||
|
||||
#: internet/groovesharkservice.cpp:792
|
||||
#: internet/groovesharkservice.cpp:793
|
||||
msgid "Copy to clipboard"
|
||||
msgstr ""
|
||||
|
||||
@ -1124,7 +1124,7 @@ msgstr ""
|
||||
msgid "Covers from %1"
|
||||
msgstr ""
|
||||
|
||||
#: internet/groovesharkservice.cpp:462 internet/groovesharkservice.cpp:857
|
||||
#: internet/groovesharkservice.cpp:462 internet/groovesharkservice.cpp:858
|
||||
msgid "Create a new Grooveshark playlist"
|
||||
msgstr ""
|
||||
|
||||
@ -1264,7 +1264,7 @@ msgstr ""
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
#: internet/groovesharkservice.cpp:465 internet/groovesharkservice.cpp:904
|
||||
#: internet/groovesharkservice.cpp:465 internet/groovesharkservice.cpp:905
|
||||
msgid "Delete Grooveshark playlist"
|
||||
msgstr ""
|
||||
|
||||
@ -1593,7 +1593,7 @@ msgstr ""
|
||||
|
||||
#: internet/magnatunedownloaddialog.cpp:225 library/libraryview.cpp:453
|
||||
#: ui/edittagdialog.cpp:719 ui/mainwindow.cpp:1802 ui/mainwindow.cpp:1907
|
||||
#: ui/mainwindow.cpp:2125
|
||||
#: ui/mainwindow.cpp:2126
|
||||
msgid "Error"
|
||||
msgstr ""
|
||||
|
||||
@ -2597,7 +2597,7 @@ msgstr ""
|
||||
msgid "My Recommendations"
|
||||
msgstr ""
|
||||
|
||||
#: internet/groovesharkservice.cpp:858 ui/equalizer.cpp:172
|
||||
#: internet/groovesharkservice.cpp:859 ui/equalizer.cpp:172
|
||||
#: ../bin/src/ui_deviceproperties.h:369
|
||||
#: ../bin/src/ui_magnatunedownloaddialog.h:135
|
||||
#: ../bin/src/ui_wizardfinishpage.h:84
|
||||
@ -2921,10 +2921,6 @@ msgstr ""
|
||||
msgid "Play custom radio..."
|
||||
msgstr ""
|
||||
|
||||
#: songinfo/tagwidget.cpp:147
|
||||
msgid "Play from my Library"
|
||||
msgstr ""
|
||||
|
||||
#: core/commandlineoptions.cpp:152
|
||||
msgid "Play if stopped, pause if playing"
|
||||
msgstr ""
|
||||
@ -2934,14 +2930,6 @@ msgstr ""
|
||||
msgid "Play if there is nothing already playing"
|
||||
msgstr ""
|
||||
|
||||
#: songinfo/tagwidget.cpp:145
|
||||
msgid "Play last.fm artist radio"
|
||||
msgstr ""
|
||||
|
||||
#: songinfo/tagwidget.cpp:140
|
||||
msgid "Play last.fm tag radio"
|
||||
msgstr ""
|
||||
|
||||
#: internet/lastfmservice.cpp:105
|
||||
msgid "Play tag radio..."
|
||||
msgstr ""
|
||||
@ -4469,7 +4457,7 @@ msgstr ""
|
||||
msgid "Your Magnatune credentials were incorrect"
|
||||
msgstr ""
|
||||
|
||||
#: ui/edittagdialog.cpp:719 ui/mainwindow.cpp:2125
|
||||
#: ui/edittagdialog.cpp:719 ui/mainwindow.cpp:2126
|
||||
msgid ""
|
||||
"Your gstreamer installation is missing the 'ofa' plugin. This is required "
|
||||
"for automatic tag fetching. Try installing the 'gstreamer-plugins-bad' "
|
||||
@ -4503,7 +4491,7 @@ msgid "Zero"
|
||||
msgstr ""
|
||||
|
||||
#: playlist/playlistundocommands.cpp:37
|
||||
#, c-format
|
||||
#, c-format, qt-plural-format
|
||||
msgid "add %n songs"
|
||||
msgstr ""
|
||||
|
||||
@ -4558,7 +4546,7 @@ msgstr ""
|
||||
msgid "does not contain"
|
||||
msgstr ""
|
||||
|
||||
#: globalsearch/globalsearchwidget.cpp:731
|
||||
#: globalsearch/globalsearchwidget.cpp:740
|
||||
msgid "e.g."
|
||||
msgstr ""
|
||||
|
||||
@ -4627,7 +4615,7 @@ msgid "press enter"
|
||||
msgstr ""
|
||||
|
||||
#: playlist/playlistundocommands.cpp:65 playlist/playlistundocommands.cpp:88
|
||||
#, c-format
|
||||
#, c-format, qt-plural-format
|
||||
msgid "remove %n songs"
|
||||
msgstr ""
|
||||
|
||||
|
@ -2063,7 +2063,8 @@ void MainWindow::ConnectInfoView(SongInfoBase* view) {
|
||||
connect(player_, SIGNAL(Stopped()), view, SLOT(SongFinished()));
|
||||
|
||||
connect(view, SIGNAL(ShowSettingsDialog()), SLOT(ShowSongInfoConfig()));
|
||||
connect(view, SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*)));
|
||||
connect(view, SIGNAL(DoGlobalSearch(QString)),
|
||||
ui_->global_search, SLOT(StartSearch(QString)));
|
||||
}
|
||||
|
||||
void MainWindow::AddSongInfoGenerator(smart_playlists::GeneratorPtr gen) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user