Skip to content

Commit

Permalink
CoverArtDelegate: simplify pixmap drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Oct 24, 2019
1 parent 146f399 commit 6810aa4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/library/coverartdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,9 @@ void CoverArtDelegate::paintItem(QPainter *painter,
// BaseSqlTableModel when a row's cover is ready.
QPixmap pixmap = pCache->requestCover(info, this, option.rect.width() * scaleFactor,
m_bOnlyCachedCover, true);
pixmap.setDevicePixelRatio(scaleFactor);
if (!pixmap.isNull()) {
int width = math_min(pixmap.width(), option.rect.width()) * scaleFactor;
int height = math_min(pixmap.height(), option.rect.height()) * scaleFactor;
QRect target(option.rect.x(), option.rect.y(), width, height);
QRect source(0, 0, target.width() * scaleFactor, target.height() * scaleFactor);
painter->drawPixmap(target, pixmap, source);
pixmap.setDevicePixelRatio(scaleFactor);
painter->drawPixmap(option.rect.topLeft(), pixmap);
} else if (!m_bOnlyCachedCover) {
// If we asked for a non-cache image and got a null pixmap, then our
// request was queued.
Expand Down

0 comments on commit 6810aa4

Please sign in to comment.