Fix TryLoadPixmap and ShowCover

This commit is contained in:
Jonas Kvinge
2019-07-09 01:14:58 +02:00
parent f94a3095fd
commit aa8679dff5
3 changed files with 8 additions and 8 deletions

View File

@@ -251,18 +251,18 @@ QUrl AlbumCoverChoiceController::UnsetCover(Song *song) {
void AlbumCoverChoiceController::ShowCover(const Song &song) { void AlbumCoverChoiceController::ShowCover(const Song &song) {
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());
ShowCover(song, pixmap); ShowCover(song, pixmap);
} }
void AlbumCoverChoiceController::ShowCover(const Song &song, const QImage &image) { void AlbumCoverChoiceController::ShowCover(const Song &song, const QImage &image) {
if (song.art_manual().isLocalFile() || song.art_automatic().isLocalFile()) { if (!image.isNull()) ShowCover(song, QPixmap::fromImage(image));
QPixmap pixmap = AlbumCoverLoader::TryLoadPixmap(song.art_automatic(), song.art_manual(), song.url().toLocalFile()); else if (!song.art_manual().isEmpty() || !song.art_automatic().isEmpty()) {
QPixmap pixmap = AlbumCoverLoader::TryLoadPixmap(song.art_automatic(), song.art_manual(), song.url());
if (!pixmap.isNull()) ShowCover(song, pixmap); if (!pixmap.isNull()) ShowCover(song, pixmap);
} }
else if (!image.isNull()) ShowCover(song, QPixmap::fromImage(image));
} }

View File

@@ -407,7 +407,7 @@ QImage AlbumCoverLoader::ScaleAndPad(const AlbumCoverLoaderOptions &options, con
} }
QPixmap AlbumCoverLoader::TryLoadPixmap(const QUrl &art_automatic, const QUrl &art_manual, const QString &filename) { QPixmap AlbumCoverLoader::TryLoadPixmap(const QUrl &art_automatic, const QUrl &art_manual, const QUrl &url) {
QPixmap ret; QPixmap ret;
@@ -421,8 +421,8 @@ QPixmap AlbumCoverLoader::TryLoadPixmap(const QUrl &art_automatic, const QUrl &a
} }
} }
if (ret.isNull() && !art_automatic.path().isEmpty()) { if (ret.isNull() && !art_automatic.path().isEmpty()) {
if (art_automatic.path() == Song::kEmbeddedCover && !filename.isEmpty() && filename.isLocalFile()) { if (art_automatic.path() == Song::kEmbeddedCover && !url.isEmpty() && url.isLocalFile()) {
ret = QPixmap::fromImage(TagReaderClient::Instance()->LoadEmbeddedArtBlocking(filename)); ret = QPixmap::fromImage(TagReaderClient::Instance()->LoadEmbeddedArtBlocking(url.toLocalFile()));
} }
else if (art_automatic.isLocalFile()) { else if (art_automatic.isLocalFile()) {
ret.load(art_automatic.toLocalFile()); ret.load(art_automatic.toLocalFile());

View File

@@ -65,7 +65,7 @@ class AlbumCoverLoader : public QObject {
void CancelTask(const quint64 id); void CancelTask(const quint64 id);
void CancelTasks(const QSet<quint64> &ids); void CancelTasks(const QSet<quint64> &ids);
static QPixmap TryLoadPixmap(const QUrl &automatic, const QUrl &manual, const QString &filename = QString()); static QPixmap TryLoadPixmap(const QUrl &automatic, const QUrl &manual, const QUrl &url = QUrl());
static QImage ScaleAndPad(const AlbumCoverLoaderOptions &options, const QImage &image); static QImage ScaleAndPad(const AlbumCoverLoaderOptions &options, const QImage &image);
signals: signals: