4
4
#include " library/coverartdelegate.h"
5
5
#include " library/coverartcache.h"
6
6
#include " library/dao/trackschema.h"
7
+ #include " util/compatibility.h"
7
8
#include " util/math.h"
8
9
9
10
CoverArtDelegate::CoverArtDelegate (QTableView* parent)
@@ -23,10 +24,8 @@ CoverArtDelegate::CoverArtDelegate(QTableView* parent)
23
24
24
25
CoverArtCache* pCache = CoverArtCache::instance ();
25
26
if (pCache) {
26
- connect (pCache, SIGNAL (coverFound (const QObject*, const CoverInfoRelative&,
27
- QPixmap, bool )),
28
- this , SLOT (slotCoverFound (const QObject*, const CoverInfoRelative&,
29
- QPixmap, bool )));
27
+ connect (pCache, &CoverArtCache::coverFound,
28
+ this , &CoverArtDelegate::slotCoverFound);
30
29
}
31
30
32
31
TrackModel* pTrackModel = NULL ;
@@ -108,17 +107,14 @@ void CoverArtDelegate::paintItem(QPainter *painter,
108
107
info.hash = index .sibling (index .row (), m_iCoverHashColumn).data ().toUInt ();
109
108
info.trackLocation = index .sibling (index .row (), m_iTrackLocationColumn).data ().toString ();
110
109
110
+ double scaleFactor = getDevicePixelRatioF (static_cast <QWidget*>(parent ()));
111
111
// We listen for updates via slotCoverFound above and signal to
112
112
// BaseSqlTableModel when a row's cover is ready.
113
- QPixmap pixmap = pCache->requestCover (info, this , option.rect .width (),
113
+ QPixmap pixmap = pCache->requestCover (info, this , option.rect .width () * scaleFactor ,
114
114
m_bOnlyCachedCover, true );
115
115
if (!pixmap.isNull ()) {
116
- int width = math_min (pixmap.width (), option.rect .width ());
117
- int height = math_min (pixmap.height (), option.rect .height ());
118
- QRect target (option.rect .x (), option.rect .y (),
119
- width, height);
120
- QRect source (0 , 0 , target.width (), target.height ());
121
- painter->drawPixmap (target, pixmap, source);
116
+ pixmap.setDevicePixelRatio (scaleFactor);
117
+ painter->drawPixmap (option.rect .topLeft (), pixmap);
122
118
} else if (!m_bOnlyCachedCover) {
123
119
// If we asked for a non-cache image and got a null pixmap, then our
124
120
// request was queued.
0 commit comments