Lyrics fetching: Add message when loading and error message when not found

This commit is contained in:
Célestin Matte 2024-03-11 16:50:55 +01:00
parent e1f90dde79
commit f121577809
3 changed files with 13 additions and 3 deletions

View File

@ -631,7 +631,11 @@ void ContextView::UpdateLyrics(const quint64 id, const QString &provider, const
if (static_cast<qint64>(id) != lyrics_id_) return;
lyrics_ = lyrics + "\n\n(Lyrics from " + provider + ")\n";
if (lyrics == nullptr) {
lyrics_ = "\n\nLyrics not found.\n";
} else {
lyrics_ = lyrics + "\n\n(Lyrics from " + provider + ")\n";
}
lyrics_id_ = -1;
if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) {

View File

@ -1423,6 +1423,7 @@ void EditTagDialog::FetchLyrics() {
if (ui_->song_list->selectionModel()->selectedIndexes().isEmpty()) return;
const Song song = data_[ui_->song_list->selectionModel()->selectedIndexes().first().row()].current_;
lyrics_fetcher_->Clear();
ui_->lyrics->setPlainText(tr("loading..."));
lyrics_id_ = static_cast<qint64>(lyrics_fetcher_->Search(song.effective_albumartist(), song.artist(), song.album(), song.title()));
}
@ -1433,8 +1434,11 @@ void EditTagDialog::UpdateLyrics(const quint64 id, const QString &provider, cons
if (static_cast<qint64>(id) != lyrics_id_) return;
lyrics_id_ = -1;
ui_->lyrics->setPlainText(lyrics);
if (lyrics != nullptr) {
ui_->lyrics->setPlainText(lyrics);
} else {
ui_->lyrics->setPlainText(tr("Not found."));
}
}
void EditTagDialog::SongSaveTagsComplete(TagReaderReply *reply, const QString &filename, Song song, const UpdateCoverAction cover_action) {

View File

@ -133,6 +133,8 @@ void LyricsFetcherSearch::AllProvidersFinished() {
if (!results_.isEmpty()) {
qLog(Debug) << "Using lyrics from" << results_.last().provider << "for" << request_.artist << request_.title << "with score" << results_.last().score;
emit LyricsFetched(id_, results_.last().provider, results_.last().lyrics);
} else {
emit LyricsFetched(id_, nullptr, nullptr);
}
emit SearchFinished(id_, results_);