Widgets: pass dpr to QIcon::pixmap()
Change the remaining calls to QIcon::pixmap() to pass a valid devicePixelRatio parameter. Pick-to: 6.9 Change-Id: I0e71e20c8109e296446e9e13cddba31d53c05df9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
d4c518b210
commit
efc318e05a
@ -1924,8 +1924,7 @@ void QMessageBox::about(QWidget *parent, const QString &title, const QString &te
|
||||
);
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
QIcon icon = msgBox->windowIcon();
|
||||
QSize size = icon.actualSize(QSize(64, 64));
|
||||
msgBox->setIconPixmap(icon.pixmap(size));
|
||||
msgBox->setIconPixmap(icon.pixmap(QSize(64, 64), msgBox->devicePixelRatio()));
|
||||
|
||||
// should perhaps be a style hint
|
||||
#ifdef Q_OS_MAC
|
||||
|
@ -78,7 +78,9 @@
|
||||
QPixmap pix;
|
||||
QRect textRect = btn->rect;
|
||||
if (!btn->icon.isNull()) {
|
||||
pix = btn->icon.pixmap(btn->iconSize, btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
|
||||
const auto dpr = p->device()->devicePixelRatio();
|
||||
pix = btn->icon.pixmap(btn->iconSize, dpr,
|
||||
btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
|
||||
drawItemPixmap(p, btn->rect, alignment, pix);
|
||||
if (btn->direction == Qt::RightToLeft)
|
||||
textRect.setRight(textRect.right() - btn->iconSize.width() - 4);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <qtextlayout.h>
|
||||
#include <private/qabstractitemdelegate_p.h>
|
||||
#include <private/qabstractitemmodel_p.h>
|
||||
#include <private/qstylehelper_p.h>
|
||||
#include <private/qtextengine_p.h>
|
||||
#include <qdebug.h>
|
||||
#include <qlocale.h>
|
||||
@ -934,7 +935,8 @@ QPixmap QItemDelegate::decoration(const QStyleOptionViewItem &option, const QVar
|
||||
case QMetaType::QIcon: {
|
||||
QIcon::Mode mode = d->iconMode(option.state);
|
||||
QIcon::State state = d->iconState(option.state);
|
||||
return qvariant_cast<QIcon>(variant).pixmap(option.decorationSize, mode, state); }
|
||||
const auto dpr = QStyleHelper::getDpr(option.widget);
|
||||
return qvariant_cast<QIcon>(variant).pixmap(option.decorationSize, dpr, mode, state); }
|
||||
case QMetaType::QColor: {
|
||||
static QPixmap pixmap(option.decorationSize);
|
||||
pixmap.fill(qvariant_cast<QColor>(variant));
|
||||
|
@ -2182,7 +2182,8 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
|
||||
titleBar->icon.paint(painter, iconRect);
|
||||
} else {
|
||||
QStyleOption tool = *titleBar;
|
||||
QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16);
|
||||
QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget)
|
||||
.pixmap(QSize(16, 16), QStyleHelper::getDpr(painter));
|
||||
tool.rect = iconRect;
|
||||
painter->save();
|
||||
proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
|
||||
|
@ -1055,11 +1055,10 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
||||
QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
|
||||
if (act && !dis)
|
||||
mode = QIcon::Active;
|
||||
QPixmap pixmap;
|
||||
if (checked)
|
||||
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
|
||||
else
|
||||
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
|
||||
const auto size = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
|
||||
const auto dpr = QStyleHelper::getDpr(p);
|
||||
const auto state = checked ? QIcon::On : QIcon::Off;
|
||||
const auto pixmap = menuitem->icon.pixmap(QSize(size, size), dpr, mode, state);
|
||||
QRect pmr(QPoint(0, 0), pixmap.deviceIndependentSize().toSize());
|
||||
pmr.moveCenter(vCheckRect.center());
|
||||
p->setPen(menuitem->palette.text().color());
|
||||
|
@ -520,7 +520,7 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
|
||||
#if QT_CONFIG(label)
|
||||
if (!icon.isNull()) {
|
||||
QLabel *iconLabel = new QLabel;
|
||||
iconLabel->setPixmap(icon.pixmap(iconSize, iconSize));
|
||||
iconLabel->setPixmap(icon.pixmap(QSize(iconSize, iconSize), devicePixelRatio()));
|
||||
iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
iconLabel->setMargin(2);
|
||||
layout->addWidget(iconLabel, 0, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user