diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/General/lyrics/lyrics.cpp | 13 | ||||
| -rw-r--r-- | src/plugins/General/lyrics/lyrics.h | 1 | ||||
| -rw-r--r-- | src/plugins/General/lyrics/lyricswidget.cpp | 13 |
3 files changed, 27 insertions, 0 deletions
diff --git a/src/plugins/General/lyrics/lyrics.cpp b/src/plugins/General/lyrics/lyrics.cpp index 4ef1fe4e9..dea479ddf 100644 --- a/src/plugins/General/lyrics/lyrics.cpp +++ b/src/plugins/General/lyrics/lyrics.cpp @@ -35,6 +35,7 @@ Lyrics::Lyrics(QPointer<LyricsWidget> *lyricsWidget, QObject *parent) : QObject( m_action->setShortcut(tr("Ctrl+L")); UiHelper::instance()->addAction(m_action, UiHelper::PLAYLIST_MENU); connect(m_action, SIGNAL(triggered ()), SLOT(showLyrics())); + connect(SoundCore::instance(), SIGNAL(trackInfoChanged()), SLOT(onTrackInfoChanged())); } Lyrics::~Lyrics() @@ -61,3 +62,15 @@ void Lyrics::showLyrics() } } } + +void Lyrics::onTrackInfoChanged() +{ + if(!m_lyricsWidget->isNull()) + { + TrackInfo info = SoundCore::instance()->trackInfo(); + if (!info.value(Qmmp::ARTIST).isEmpty() && !info.value(Qmmp::TITLE).isEmpty()) + { + m_lyricsWidget->data()->fetch(&info); + } + } +} diff --git a/src/plugins/General/lyrics/lyrics.h b/src/plugins/General/lyrics/lyrics.h index e0a216a80..6db784462 100644 --- a/src/plugins/General/lyrics/lyrics.h +++ b/src/plugins/General/lyrics/lyrics.h @@ -42,6 +42,7 @@ public: private slots: void showLyrics(); + void onTrackInfoChanged(); private: QAction *m_action; diff --git a/src/plugins/General/lyrics/lyricswidget.cpp b/src/plugins/General/lyrics/lyricswidget.cpp index 375a9034c..f5a60e946 100644 --- a/src/plugins/General/lyrics/lyricswidget.cpp +++ b/src/plugins/General/lyrics/lyricswidget.cpp @@ -100,6 +100,8 @@ void LyricsWidget::fetch(const TrackInfo *info) m_ui.trackSpinBox->setValue(info->value(Qmmp::TRACK).toInt()); m_ui.yearSpinBox->setValue(info->value(Qmmp::YEAR).toInt()); + m_ui.providerComboBox->clear(); + if(!loadFromCache()) on_refreshButton_clicked(); } @@ -107,6 +109,11 @@ void LyricsWidget::fetch(const TrackInfo *info) void LyricsWidget::onRequestFinished(QNetworkReply *reply) { QString name = m_tasks.take(reply); + if(name.isEmpty()) + { + reply->deleteLater(); + return; + } QVariant redirectTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); int code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); @@ -172,6 +179,12 @@ void LyricsWidget::on_refreshButton_clicked() m_info.setValue(Qmmp::TRACK, m_ui.trackSpinBox->value()); m_info.setValue(Qmmp::YEAR, m_ui.yearSpinBox->value()); + //abort previous tasks + for(QNetworkReply *reply : m_tasks.keys()) + reply->abort(); + + m_tasks.clear(); + for(LyricsProvider *provider : m_parser.providers()) { if(m_enabledProviders.contains(provider->name())) |
