Fix TryLoadPixmap and ShowCover

This commit is contained in:
Jonas Kvinge
2019-07-09 01:05:42 +02:00
parent e11958dd58
commit f94a3095fd
3 changed files with 20 additions and 23 deletions

View File

@@ -256,14 +256,11 @@ void AlbumCoverChoiceController::ShowCover(const Song &song) {
} }
void AlbumCoverChoiceController::ShowCover(const Song &song, const QImage image) { void AlbumCoverChoiceController::ShowCover(const Song &song, const QImage &image) {
QUrl url_manual(song.art_manual()); if (song.art_manual().isLocalFile() || song.art_automatic().isLocalFile()) {
QUrl url_automatic(song.art_automatic());
if (url_manual.isLocalFile() || url_automatic.isLocalFile()) {
QPixmap pixmap = AlbumCoverLoader::TryLoadPixmap(song.art_automatic(), song.art_manual(), song.url().toLocalFile()); QPixmap pixmap = AlbumCoverLoader::TryLoadPixmap(song.art_automatic(), song.art_manual(), song.url().toLocalFile());
ShowCover(song, pixmap); if (!pixmap.isNull()) ShowCover(song, pixmap);
} }
else if (!image.isNull()) ShowCover(song, QPixmap::fromImage(image)); else if (!image.isNull()) ShowCover(song, QPixmap::fromImage(image));

View File

@@ -105,7 +105,7 @@ class AlbumCoverChoiceController : public QWidget {
// Shows the cover of given song in it's original size. // Shows the cover of given song in it's original size.
void ShowCover(const Song &song); void ShowCover(const Song &song);
void ShowCover(const Song &song, const QImage image); void ShowCover(const Song &song, const QImage &image);
void ShowCover(const Song &song, const QPixmap &pixmap); void ShowCover(const Song &song, const QPixmap &pixmap);
// Search for covers automatically // Search for covers automatically

View File

@@ -407,31 +407,31 @@ QImage AlbumCoverLoader::ScaleAndPad(const AlbumCoverLoaderOptions &options, con
} }
QPixmap AlbumCoverLoader::TryLoadPixmap(const QUrl &automatic, const QUrl &manual, const QString &filename) { QPixmap AlbumCoverLoader::TryLoadPixmap(const QUrl &art_automatic, const QUrl &art_manual, const QString &filename) {
QPixmap ret; QPixmap ret;
if (manual.path() == Song::kManuallyUnsetCover) return ret;
if (!manual.path().isEmpty()) { if (!art_manual.path().isEmpty()) {
if (manual.scheme().isEmpty()) { if (art_manual.path() == Song::kManuallyUnsetCover) return ret;
ret.load(manual.path()); else if (art_manual.isLocalFile()) {
ret.load(art_manual.toLocalFile());
} }
else if (manual.scheme() == "file") { else if (art_manual.scheme().isEmpty()) {
ret.load(manual.toLocalFile()); ret.load(art_manual.path());
} }
} }
if (ret.isNull()) { if (ret.isNull() && !art_automatic.path().isEmpty()) {
if (automatic.path() == Song::kEmbeddedCover && !filename.isEmpty()) { if (art_automatic.path() == Song::kEmbeddedCover && !filename.isEmpty() && filename.isLocalFile()) {
ret = QPixmap::fromImage(TagReaderClient::Instance()->LoadEmbeddedArtBlocking(filename)); ret = QPixmap::fromImage(TagReaderClient::Instance()->LoadEmbeddedArtBlocking(filename));
} }
else if (!automatic.path().isEmpty()) { else if (art_automatic.isLocalFile()) {
if (automatic.scheme().isEmpty()) { ret.load(art_automatic.toLocalFile());
ret.load(automatic.path()); }
} else if (art_automatic.scheme().isEmpty()) {
else if (manual.scheme() == "file") { ret.load(art_automatic.path());
ret.load(automatic.toLocalFile());
}
} }
} }
return ret; return ret;
} }