From 548a1f30cafdafa1a1e75be3f8e2dc0eec86bf90 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sun, 7 Mar 2021 23:03:02 +0100 Subject: [PATCH] Support saving by filename in SaveAndSetCover --- src/covermanager/albumcovermanager.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/covermanager/albumcovermanager.cpp b/src/covermanager/albumcovermanager.cpp index 7d4256f53..5775ebc7c 100644 --- a/src/covermanager/albumcovermanager.cpp +++ b/src/covermanager/albumcovermanager.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -965,13 +966,23 @@ void AlbumCoverManager::SaveAndSetCover(AlbumItem *item, const AlbumCoverImageRe quint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, result.image_data); cover_save_tasks_.insert(id, item); } - else { + else if (!result.image.isNull()) { quint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, result.image); cover_save_tasks_.insert(id, item); } + else if (!result.cover_url.isEmpty() && result.cover_url.isLocalFile()) { + quint64 id = app_->album_cover_loader()->SaveEmbeddedCoverAsync(urls, result.cover_url.toLocalFile()); + cover_save_tasks_.insert(id, item); + } } else { - QUrl cover_url = album_cover_choice_controller_->SaveCoverToFileAutomatic(Song::Source_Collection, albumartist, album, QString(), urls.first().adjusted(QUrl::RemoveFilename).path(), result, false); + QUrl cover_url; + if (!result.image_data.isNull() || !result.image.isNull()) { + cover_url = album_cover_choice_controller_->SaveCoverToFileAutomatic(Song::Source_Collection, albumartist, album, QString(), urls.first().adjusted(QUrl::RemoveFilename).path(), result, false); + } + else if (!result.cover_url.isEmpty() && !result.cover_url.isLocalFile()) { + cover_url = result.cover_url; + } if (cover_url.isEmpty()) return;