If a track does not have a cover, we need to set 'img' to the 'noCover' variant - so that the notification uses the correct image.
This commit is contained in:
committed by
craig.p.drummond
parent
2adc5ecef0
commit
7c398b304d
@@ -177,7 +177,7 @@ void CoverWidget::update(const QPixmap &p)
|
||||
{
|
||||
QSize pixSize=size()-QSize(constBorder*2, constBorder*2);
|
||||
setPixmap(p.size()==pixSize ? p : p.scaled(pixSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
img=QImage();
|
||||
img=p.toImage();
|
||||
empty=true;
|
||||
}
|
||||
|
||||
@@ -186,13 +186,17 @@ void CoverWidget::update(const Song &s)
|
||||
if (s.albumArtist()!=current.albumArtist() || s.album!=current.album || s.isStream()!=current.isStream()) {
|
||||
current=s;
|
||||
if (!s.albumArtist().isEmpty() && !s.album.isEmpty()) {
|
||||
Covers::Image img=Covers::self()->get(s);
|
||||
valid=!img.img.isNull();
|
||||
Covers::Image cImg=Covers::self()->get(s);
|
||||
valid=!cImg.img.isNull();
|
||||
if (valid) {
|
||||
update(img.img);
|
||||
coverFileName=img.fileName;
|
||||
emit coverImage(img.img);
|
||||
emit coverFile(img.fileName);
|
||||
update(cImg.img);
|
||||
coverFileName=cImg.fileName;
|
||||
emit coverImage(cImg.img);
|
||||
emit coverFile(cImg.fileName);
|
||||
} else {
|
||||
// We ned to set the image here, so that TrayItem gets the correct 'noCover' image
|
||||
// ...but if Covers does eventually download a cover, we dont want valid->noCover->valid
|
||||
img=stdPixmap(current.isStream() && !current.isCdda()).toImage();
|
||||
}
|
||||
} else {
|
||||
valid=false;
|
||||
@@ -277,17 +281,6 @@ void CoverWidget::resizeEvent(QResizeEvent *e)
|
||||
resize(sz, sz);
|
||||
}
|
||||
|
||||
const QImage & CoverWidget::image() const
|
||||
{
|
||||
if (img.isNull()) {
|
||||
const QPixmap *pix = pixmap();
|
||||
if (pix && !pix->isNull()) {
|
||||
img=pix->toImage();
|
||||
}
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
// This commented out section draws a rounded cover - but all other covers are square, so not
|
||||
// sure if I want this or not...
|
||||
// static QPainterPath buildPath(const QRectF &r, double radius)
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
bool isEmpty() const { return empty; }
|
||||
bool isValid() const { return !empty && valid; }
|
||||
const QString & fileName() const { return coverFileName; }
|
||||
const QImage &image() const;
|
||||
const QImage &image() const { return img; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void coverImage(const QImage &img);
|
||||
|
||||
Reference in New Issue
Block a user