mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 19:31:02 +01:00
Make sure the OSD and album cover manager use a "no cover" image when there's no artwork
This commit is contained in:
parent
f3c732019f
commit
bdc5d1ab1c
@ -101,7 +101,7 @@ void AlbumCoverLoader::NextState(Task* task) {
|
|||||||
ProcessTask(task);
|
ProcessTask(task);
|
||||||
} else {
|
} else {
|
||||||
// Give up
|
// Give up
|
||||||
emit ImageLoaded(task->id, QImage());
|
emit ImageLoaded(task->id, default_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (filename == kManuallyUnsetCover)
|
if (filename == kManuallyUnsetCover)
|
||||||
return TryLoadResult(false, true, QImage());
|
return TryLoadResult(false, true, default_);
|
||||||
|
|
||||||
if (filename.toLower().startsWith("http://")) {
|
if (filename.toLower().startsWith("http://")) {
|
||||||
network_->Get(QUrl(filename), this, "RemoteFetchFinished", task.id, true);
|
network_->Get(QUrl(filename), this, "RemoteFetchFinished", task.id, true);
|
||||||
@ -124,7 +124,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
QImage image(filename);
|
QImage image(filename);
|
||||||
return TryLoadResult(false, !image.isNull(), image);
|
return TryLoadResult(false, !image.isNull(), image.isNull() ? default_ : image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlbumCoverLoader::RemoteFetchFinished(quint64 id, QNetworkReply* reply) {
|
void AlbumCoverLoader::RemoteFetchFinished(quint64 id, QNetworkReply* reply) {
|
||||||
@ -177,3 +177,7 @@ QPixmap AlbumCoverLoader::TryLoadPixmap(const QString &automatic, const QString
|
|||||||
ret.load(automatic);
|
ret.load(automatic);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AlbumCoverLoader::SetDefaultOutputImage(const QImage &image) {
|
||||||
|
default_ = ScaleAndPad(image);
|
||||||
|
}
|
||||||
|
@ -41,6 +41,7 @@ class AlbumCoverLoader : public QObject {
|
|||||||
|
|
||||||
void SetDesiredHeight(int height) { height_ = height; }
|
void SetDesiredHeight(int height) { height_ = height; }
|
||||||
void SetPadOutputImage(bool padding) { padding_ = padding; }
|
void SetPadOutputImage(bool padding) { padding_ = padding; }
|
||||||
|
void SetDefaultOutputImage(const QImage& image);
|
||||||
quint64 LoadImageAsync(const QString& art_automatic, const QString& art_manual);
|
quint64 LoadImageAsync(const QString& art_automatic, const QString& art_manual);
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
@ -87,6 +88,7 @@ class AlbumCoverLoader : public QObject {
|
|||||||
|
|
||||||
int height_;
|
int height_;
|
||||||
bool padding_;
|
bool padding_;
|
||||||
|
QImage default_;
|
||||||
|
|
||||||
QMutex mutex_;
|
QMutex mutex_;
|
||||||
QQueue<Task> tasks_;
|
QQueue<Task> tasks_;
|
||||||
|
@ -123,6 +123,7 @@ void AlbumCoverManager::Init() {
|
|||||||
|
|
||||||
void AlbumCoverManager::CoverLoaderInitialised() {
|
void AlbumCoverManager::CoverLoaderInitialised() {
|
||||||
cover_loader_->Worker()->SetNetwork(network_);
|
cover_loader_->Worker()->SetNetwork(network_);
|
||||||
|
cover_loader_->Worker()->SetDefaultOutputImage(QImage(":nocover.png"));
|
||||||
connect(cover_loader_->Worker().get(), SIGNAL(ImageLoaded(quint64,QImage)),
|
connect(cover_loader_->Worker().get(), SIGNAL(ImageLoaded(quint64,QImage)),
|
||||||
SLOT(CoverImageLoaded(quint64,QImage)));
|
SLOT(CoverImageLoaded(quint64,QImage)));
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ OSD::~OSD() {
|
|||||||
void OSD::CoverLoaderInitialised() {
|
void OSD::CoverLoaderInitialised() {
|
||||||
cover_loader_->Worker()->SetNetwork(network_);
|
cover_loader_->Worker()->SetNetwork(network_);
|
||||||
cover_loader_->Worker()->SetPadOutputImage(false);
|
cover_loader_->Worker()->SetPadOutputImage(false);
|
||||||
|
cover_loader_->Worker()->SetDefaultOutputImage(QImage(":nocover.png"));
|
||||||
connect(cover_loader_->Worker().get(), SIGNAL(ImageLoaded(quint64,QImage)),
|
connect(cover_loader_->Worker().get(), SIGNAL(ImageLoaded(quint64,QImage)),
|
||||||
SLOT(AlbumArtLoaded(quint64,QImage)));
|
SLOT(AlbumArtLoaded(quint64,QImage)));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user