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);
|
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QIcon icon = msgBox->windowIcon();
|
QIcon icon = msgBox->windowIcon();
|
||||||
QSize size = icon.actualSize(QSize(64, 64));
|
msgBox->setIconPixmap(icon.pixmap(QSize(64, 64), msgBox->devicePixelRatio()));
|
||||||
msgBox->setIconPixmap(icon.pixmap(size));
|
|
||||||
|
|
||||||
// should perhaps be a style hint
|
// should perhaps be a style hint
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
|
@ -78,7 +78,9 @@
|
|||||||
QPixmap pix;
|
QPixmap pix;
|
||||||
QRect textRect = btn->rect;
|
QRect textRect = btn->rect;
|
||||||
if (!btn->icon.isNull()) {
|
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);
|
drawItemPixmap(p, btn->rect, alignment, pix);
|
||||||
if (btn->direction == Qt::RightToLeft)
|
if (btn->direction == Qt::RightToLeft)
|
||||||
textRect.setRight(textRect.right() - btn->iconSize.width() - 4);
|
textRect.setRight(textRect.right() - btn->iconSize.width() - 4);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <qtextlayout.h>
|
#include <qtextlayout.h>
|
||||||
#include <private/qabstractitemdelegate_p.h>
|
#include <private/qabstractitemdelegate_p.h>
|
||||||
#include <private/qabstractitemmodel_p.h>
|
#include <private/qabstractitemmodel_p.h>
|
||||||
|
#include <private/qstylehelper_p.h>
|
||||||
#include <private/qtextengine_p.h>
|
#include <private/qtextengine_p.h>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include <qlocale.h>
|
#include <qlocale.h>
|
||||||
@ -934,7 +935,8 @@ QPixmap QItemDelegate::decoration(const QStyleOptionViewItem &option, const QVar
|
|||||||
case QMetaType::QIcon: {
|
case QMetaType::QIcon: {
|
||||||
QIcon::Mode mode = d->iconMode(option.state);
|
QIcon::Mode mode = d->iconMode(option.state);
|
||||||
QIcon::State state = d->iconState(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: {
|
case QMetaType::QColor: {
|
||||||
static QPixmap pixmap(option.decorationSize);
|
static QPixmap pixmap(option.decorationSize);
|
||||||
pixmap.fill(qvariant_cast<QColor>(variant));
|
pixmap.fill(qvariant_cast<QColor>(variant));
|
||||||
|
@ -2182,7 +2182,8 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
|
|||||||
titleBar->icon.paint(painter, iconRect);
|
titleBar->icon.paint(painter, iconRect);
|
||||||
} else {
|
} else {
|
||||||
QStyleOption tool = *titleBar;
|
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;
|
tool.rect = iconRect;
|
||||||
painter->save();
|
painter->save();
|
||||||
proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
|
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;
|
QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
|
||||||
if (act && !dis)
|
if (act && !dis)
|
||||||
mode = QIcon::Active;
|
mode = QIcon::Active;
|
||||||
QPixmap pixmap;
|
const auto size = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
|
||||||
if (checked)
|
const auto dpr = QStyleHelper::getDpr(p);
|
||||||
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
|
const auto state = checked ? QIcon::On : QIcon::Off;
|
||||||
else
|
const auto pixmap = menuitem->icon.pixmap(QSize(size, size), dpr, mode, state);
|
||||||
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
|
|
||||||
QRect pmr(QPoint(0, 0), pixmap.deviceIndependentSize().toSize());
|
QRect pmr(QPoint(0, 0), pixmap.deviceIndependentSize().toSize());
|
||||||
pmr.moveCenter(vCheckRect.center());
|
pmr.moveCenter(vCheckRect.center());
|
||||||
p->setPen(menuitem->palette.text().color());
|
p->setPen(menuitem->palette.text().color());
|
||||||
|
@ -520,7 +520,7 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
|
|||||||
#if QT_CONFIG(label)
|
#if QT_CONFIG(label)
|
||||||
if (!icon.isNull()) {
|
if (!icon.isNull()) {
|
||||||
QLabel *iconLabel = new QLabel;
|
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->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
iconLabel->setMargin(2);
|
iconLabel->setMargin(2);
|
||||||
layout->addWidget(iconLabel, 0, 0);
|
layout->addWidget(iconLabel, 0, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user