Respect device pixel ratio when scaling card imgs (#4467)

This commit is contained in:
Johannes 2021-11-13 22:01:27 +00:00 committed by GitHub
parent 26acfd5102
commit 5652b56b45

View file

@ -6,6 +6,7 @@
#include "thememanager.h" #include "thememanager.h"
#include <QApplication> #include <QApplication>
#include <QScreen>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
@ -572,7 +573,10 @@ void PictureLoader::getPixmap(QPixmap &pixmap, CardInfoPtr card, QSize size)
// load the image and create a copy of the correct size // load the image and create a copy of the correct size
QPixmap bigPixmap; QPixmap bigPixmap;
if (QPixmapCache::find(key, &bigPixmap)) { if (QPixmapCache::find(key, &bigPixmap)) {
pixmap = bigPixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation); QScreen * screen = qApp->primaryScreen();
int dpr = screen->devicePixelRatio();
pixmap = bigPixmap.scaled(size * dpr, Qt::KeepAspectRatio, Qt::SmoothTransformation);
pixmap.setDevicePixelRatio(dpr);
QPixmapCache::insert(sizeKey, pixmap); QPixmapCache::insert(sizeKey, pixmap);
return; return;
} }