Make sure the OSD and album cover manager use a "no cover" image when there's no artwork

This commit is contained in:
David Sansome 2010-05-16 22:53:42 +00:00
parent f3c732019f
commit bdc5d1ab1c
4 changed files with 11 additions and 3 deletions

View File

@ -101,7 +101,7 @@ void AlbumCoverLoader::NextState(Task* task) {
ProcessTask(task);
} else {
// Give up
emit ImageLoaded(task->id, QImage());
emit ImageLoaded(task->id, default_);
}
}
@ -114,7 +114,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(
}
if (filename == kManuallyUnsetCover)
return TryLoadResult(false, true, QImage());
return TryLoadResult(false, true, default_);
if (filename.toLower().startsWith("http://")) {
network_->Get(QUrl(filename), this, "RemoteFetchFinished", task.id, true);
@ -124,7 +124,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(
}
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) {
@ -177,3 +177,7 @@ QPixmap AlbumCoverLoader::TryLoadPixmap(const QString &automatic, const QString
ret.load(automatic);
return ret;
}
void AlbumCoverLoader::SetDefaultOutputImage(const QImage &image) {
default_ = ScaleAndPad(image);
}

View File

@ -41,6 +41,7 @@ class AlbumCoverLoader : public QObject {
void SetDesiredHeight(int height) { height_ = height; }
void SetPadOutputImage(bool padding) { padding_ = padding; }
void SetDefaultOutputImage(const QImage& image);
quint64 LoadImageAsync(const QString& art_automatic, const QString& art_manual);
void Clear();
@ -87,6 +88,7 @@ class AlbumCoverLoader : public QObject {
int height_;
bool padding_;
QImage default_;
QMutex mutex_;
QQueue<Task> tasks_;

View File

@ -123,6 +123,7 @@ void AlbumCoverManager::Init() {
void AlbumCoverManager::CoverLoaderInitialised() {
cover_loader_->Worker()->SetNetwork(network_);
cover_loader_->Worker()->SetDefaultOutputImage(QImage(":nocover.png"));
connect(cover_loader_->Worker().get(), SIGNAL(ImageLoaded(quint64,QImage)),
SLOT(CoverImageLoaded(quint64,QImage)));
}

View File

@ -51,6 +51,7 @@ OSD::~OSD() {
void OSD::CoverLoaderInitialised() {
cover_loader_->Worker()->SetNetwork(network_);
cover_loader_->Worker()->SetPadOutputImage(false);
cover_loader_->Worker()->SetDefaultOutputImage(QImage(":nocover.png"));
connect(cover_loader_->Worker().get(), SIGNAL(ImageLoaded(quint64,QImage)),
SLOT(AlbumArtLoaded(quint64,QImage)));
}