Handle device pixel ratio in QIconLoaderEngine::paint()

QIcon::paint() paints blurry icons on HighDPI screens.
In particular, it is called by QCommonStyle to paint
icons for CE_ItemViewItem's.

Change-Id: Iffe6bd01a8756e617656195ef63fe13c968e0832
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Alexander Volkov 2019-03-18 16:03:59 +03:00
parent f48a76bbbf
commit b0145f029c

View File

@ -629,7 +629,10 @@ void QIconLoaderEngine::ensureLoaded()
void QIconLoaderEngine::paint(QPainter *painter, const QRect &rect,
QIcon::Mode mode, QIcon::State state)
{
QSize pixmapSize = rect.size();
const qreal dpr = !qApp->testAttribute(Qt::AA_UseHighDpiPixmaps) ?
qreal(1.0) : painter->device()->devicePixelRatioF();
QSize pixmapSize = rect.size() * dpr;
painter->drawPixmap(rect, pixmap(pixmapSize, mode, state));
}