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());
QUrl url_automatic(song.art_automatic());
if (url_manual.isLocalFile() || url_automatic.isLocalFile()) {
if (song.art_manual().isLocalFile() || song.art_automatic().isLocalFile()) {
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));

View File

@ -105,7 +105,7 @@ class AlbumCoverChoiceController : public QWidget {
// Shows the cover of given song in it's original size.
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);
// 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;
if (manual.path() == Song::kManuallyUnsetCover) return ret;
if (!manual.path().isEmpty()) {
if (manual.scheme().isEmpty()) {
ret.load(manual.path());
if (!art_manual.path().isEmpty()) {
if (art_manual.path() == Song::kManuallyUnsetCover) return ret;
else if (art_manual.isLocalFile()) {
ret.load(art_manual.toLocalFile());
}
else if (manual.scheme() == "file") {
ret.load(manual.toLocalFile());
else if (art_manual.scheme().isEmpty()) {
ret.load(art_manual.path());
}
}
if (ret.isNull()) {
if (automatic.path() == Song::kEmbeddedCover && !filename.isEmpty()) {
if (ret.isNull() && !art_automatic.path().isEmpty()) {
if (art_automatic.path() == Song::kEmbeddedCover && !filename.isEmpty() && filename.isLocalFile()) {
ret = QPixmap::fromImage(TagReaderClient::Instance()->LoadEmbeddedArtBlocking(filename));
}
else if (!automatic.path().isEmpty()) {
if (automatic.scheme().isEmpty()) {
ret.load(automatic.path());
}
else if (manual.scheme() == "file") {
ret.load(automatic.toLocalFile());
}
else if (art_automatic.isLocalFile()) {
ret.load(art_automatic.toLocalFile());
}
else if (art_automatic.scheme().isEmpty()) {
ret.load(art_automatic.path());
}
}
return ret;
}