Fix updating of toolbar coverwidget if cover is downloaded after song has started.
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
3. Convert filename to UTF16 before passing to TagLib for windows builds.
|
||||
4. When emiting signal to say cover is loaded, need to adjust size by pixel
|
||||
ratio.
|
||||
5. Fix updating of toolbar coverwidget if cover is downloaded after song has
|
||||
started.
|
||||
|
||||
1.5.0.1
|
||||
-------
|
||||
|
||||
@@ -1315,7 +1315,7 @@ void Covers::artistImageDownloaded(const Song &song, const QImage &img, const QS
|
||||
gotArtistImage(song, img, file);
|
||||
}
|
||||
|
||||
void Covers::updateCache(const Song &song, const QImage &img, bool dummyEntriesOnly)
|
||||
bool Covers::updateCache(const Song &song, const QImage &img, bool dummyEntriesOnly)
|
||||
{
|
||||
// Only remove all scaled entries from disk if the cover has been set by the CoverDialog
|
||||
// This is the only case where dummyEntriesOnly==false
|
||||
@@ -1328,6 +1328,8 @@ void Covers::updateCache(const Song &song, const QImage &img, bool dummyEntriesO
|
||||
#else
|
||||
bool emitLoaded=true;
|
||||
#endif
|
||||
bool updated=false;
|
||||
|
||||
foreach (int s, cacheSizes) {
|
||||
QString key=cacheKey(song, s);
|
||||
QPixmap *pix(cache.object(key));
|
||||
@@ -1353,10 +1355,13 @@ void Covers::updateCache(const Song &song, const QImage &img, bool dummyEntriesO
|
||||
}
|
||||
#endif
|
||||
emit loaded(song, s);
|
||||
updated=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
void Covers::tryToLocate(const Song &song)
|
||||
@@ -1810,10 +1815,11 @@ void Covers::gotAlbumCover(const Song &song, const QImage &img, const QString &f
|
||||
mutex.unlock();
|
||||
// }
|
||||
if (emitResult) {
|
||||
bool updatedCover=false;
|
||||
if (!img.isNull()) {
|
||||
updateCache(song, img, true);
|
||||
updatedCover=updateCache(song, img, true);
|
||||
}
|
||||
if (!song.isSpecificSizeRequest()) {
|
||||
if (updatedCover || !song.isSpecificSizeRequest()) {
|
||||
DBUG << "emit cover" << song.file << song.artist << song.albumartist << song.album << song.mbAlbumId() << img.width() << img.height() << fileName;
|
||||
emit cover(song, img, fileName.startsWith(constCoverInTagPrefix) ? QString() : fileName);
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ private:
|
||||
void tryToDownload(const Song &song);
|
||||
void tryToLoad(const Song &song);
|
||||
Image findImage(const Song &song, bool emitResult);
|
||||
void updateCache(const Song &song, const QImage &img, bool dummyEntriesOnly);
|
||||
bool updateCache(const Song &song, const QImage &img, bool dummyEntriesOnly);
|
||||
void gotAlbumCover(const Song &song, const QImage &img, const QString &fileName, bool emitResult=true);
|
||||
void gotArtistImage(const Song &song, const QImage &img, const QString &fileName, bool emitResult=true);
|
||||
QString getFilename(const Song &s, bool isArtist);
|
||||
|
||||
@@ -216,14 +216,15 @@ void CurrentCover::update(const Song &s)
|
||||
}
|
||||
}
|
||||
|
||||
void CurrentCover::coverRetrieved(const Song &s, const QImage &img, const QString &file)
|
||||
void CurrentCover::coverRetrieved(const Song &s, const QImage &newImage, const QString &file)
|
||||
{
|
||||
if (!s.isArtistImageRequest() && s.albumArtist()==current.albumArtist() && s.album==current.album) {
|
||||
valid=!img.isNull();
|
||||
valid=!newImage.isNull();
|
||||
if (valid) {
|
||||
coverFileName=file;
|
||||
img=newImage;
|
||||
emit coverFile(file);
|
||||
emit coverImage(img);
|
||||
emit coverImage(newImage);
|
||||
} else {
|
||||
coverFileName=current.isStandardStream() ? noStreamCoverFileName : noCoverFileName;
|
||||
emit coverFile(coverFileName);
|
||||
|
||||
Reference in New Issue
Block a user