Port to QImage and QPixmap deviceIndependentSize()
Replace the “size() / devicePixelRatio()” pattern with a call to deviceIndependentSize(). Change-Id: I9d9359e80b9e6643e7395028cd43e3261d449ae7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
4e460aa3f7
commit
81a7344e1d
@ -109,7 +109,7 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */)
|
|||||||
//! [7] //! [8]
|
//! [7] //! [8]
|
||||||
auto previewPixmap = qFuzzyCompare(pixmap.devicePixelRatio(), qreal(1))
|
auto previewPixmap = qFuzzyCompare(pixmap.devicePixelRatio(), qreal(1))
|
||||||
? pixmap
|
? pixmap
|
||||||
: pixmap.scaled(pixmap.size() / pixmap.devicePixelRatio(), Qt::KeepAspectRatio,
|
: pixmap.scaled(pixmap.deviceIndependentSize().toSize(), Qt::KeepAspectRatio,
|
||||||
Qt::SmoothTransformation);
|
Qt::SmoothTransformation);
|
||||||
double scaleFactor = pixmapScale / curScale;
|
double scaleFactor = pixmapScale / curScale;
|
||||||
int newWidth = int(previewPixmap.width() * scaleFactor);
|
int newWidth = int(previewPixmap.width() * scaleFactor);
|
||||||
@ -216,7 +216,7 @@ void MandelbrotWidget::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
pixmapOffset += event->position().toPoint() - lastDragPos;
|
pixmapOffset += event->position().toPoint() - lastDragPos;
|
||||||
lastDragPos = QPoint();
|
lastDragPos = QPoint();
|
||||||
|
|
||||||
const auto pixmapSize = pixmap.size() / pixmap.devicePixelRatio();
|
const auto pixmapSize = pixmap.deviceIndependentSize().toSize();
|
||||||
int deltaX = (width() - pixmapSize.width()) / 2 - pixmapOffset.x();
|
int deltaX = (width() - pixmapSize.width()) / 2 - pixmapOffset.x();
|
||||||
int deltaY = (height() - pixmapSize.height()) / 2 - pixmapOffset.y();
|
int deltaY = (height() - pixmapSize.height()) / 2 - pixmapOffset.y();
|
||||||
scroll(deltaX, deltaY);
|
scroll(deltaX, deltaY);
|
||||||
|
@ -104,9 +104,7 @@ void QShapedPixmapWindow::updateGeometry(const QPoint &pos)
|
|||||||
{
|
{
|
||||||
QSize size(1, 1);
|
QSize size(1, 1);
|
||||||
if (!m_pixmap.isNull()) {
|
if (!m_pixmap.isNull()) {
|
||||||
size = qFuzzyCompare(m_pixmap.devicePixelRatio(), qreal(1.0))
|
size = m_pixmap.deviceIndependentSize().toSize();
|
||||||
? m_pixmap.size()
|
|
||||||
: (QSizeF(m_pixmap.size()) / m_pixmap.devicePixelRatio()).toSize();
|
|
||||||
}
|
}
|
||||||
setGeometry(QRect(pos - m_hotSpot, size));
|
setGeometry(QRect(pos - m_hotSpot, size));
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ QT_END_NAMESPACE
|
|||||||
// NSImage.
|
// NSImage.
|
||||||
auto nsImage = [[NSImage alloc] initWithSize:NSZeroSize];
|
auto nsImage = [[NSImage alloc] initWithSize:NSZeroSize];
|
||||||
auto *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
|
auto *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
|
||||||
imageRep.size = (image.size() / image.devicePixelRatio()).toCGSize();
|
imageRep.size = image.deviceIndependentSize().toCGSize();
|
||||||
[nsImage addRepresentation:[imageRep autorelease]];
|
[nsImage addRepresentation:[imageRep autorelease]];
|
||||||
Q_ASSERT(CGSizeEqualToSize(nsImage.size, imageRep.size));
|
Q_ASSERT(CGSizeEqualToSize(nsImage.size, imageRep.size));
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ QT_END_NAMESPACE
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
|
auto *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
|
||||||
imageRep.size = (image.size() / image.devicePixelRatio()).toCGSize();
|
imageRep.size = image.deviceIndependentSize().toCGSize();
|
||||||
[nsImage addRepresentation:[imageRep autorelease]];
|
[nsImage addRepresentation:[imageRep autorelease]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,12 +967,12 @@ void QPaintEngineEx::drawPolygon(const QPoint *points, int pointCount, PolygonDr
|
|||||||
|
|
||||||
void QPaintEngineEx::drawPixmap(const QPointF &pos, const QPixmap &pm)
|
void QPaintEngineEx::drawPixmap(const QPointF &pos, const QPixmap &pm)
|
||||||
{
|
{
|
||||||
drawPixmap(QRectF(pos, pm.size() / pm.devicePixelRatio()), pm, pm.rect());
|
drawPixmap(QRectF(pos, pm.deviceIndependentSize()), pm, pm.rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QPaintEngineEx::drawImage(const QPointF &pos, const QImage &image)
|
void QPaintEngineEx::drawImage(const QPointF &pos, const QImage &image)
|
||||||
{
|
{
|
||||||
drawImage(QRectF(pos, image.size() / image.devicePixelRatio()), image, image.rect());
|
drawImage(QRectF(pos, image.deviceIndependentSize()), image, image.rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QPaintEngineEx::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s)
|
void QPaintEngineEx::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s)
|
||||||
|
@ -102,20 +102,19 @@ static QSize getPixmapSize(QTextDocument *doc, const QTextImageFormat &format)
|
|||||||
QSize size(width, height);
|
QSize size(width, height);
|
||||||
if (!hasWidth || !hasHeight) {
|
if (!hasWidth || !hasHeight) {
|
||||||
pm = getPixmap(doc, format);
|
pm = getPixmap(doc, format);
|
||||||
const int pmWidth = pm.width() / pm.devicePixelRatio();
|
const QSizeF pmSize = pm.deviceIndependentSize();
|
||||||
const int pmHeight = pm.height() / pm.devicePixelRatio();
|
|
||||||
|
|
||||||
if (!hasWidth) {
|
if (!hasWidth) {
|
||||||
if (!hasHeight)
|
if (!hasHeight)
|
||||||
size.setWidth(pmWidth);
|
size.setWidth(pmSize.width());
|
||||||
else
|
else
|
||||||
size.setWidth(qRound(height * (pmWidth / (qreal) pmHeight)));
|
size.setWidth(qRound(height * (pmSize.width() / (qreal) pmSize.height())));
|
||||||
}
|
}
|
||||||
if (!hasHeight) {
|
if (!hasHeight) {
|
||||||
if (!hasWidth)
|
if (!hasWidth)
|
||||||
size.setHeight(pmHeight);
|
size.setHeight(pmSize.height());
|
||||||
else
|
else
|
||||||
size.setHeight(qRound(width * (pmHeight / (qreal) pmWidth)));
|
size.setHeight(qRound(width * (pmSize.height() / (qreal) pmSize.width())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,10 +170,11 @@ static QSize getImageSize(QTextDocument *doc, const QTextImageFormat &format)
|
|||||||
QSize size(width, height);
|
QSize size(width, height);
|
||||||
if (!hasWidth || !hasHeight) {
|
if (!hasWidth || !hasHeight) {
|
||||||
image = getImage(doc, format);
|
image = getImage(doc, format);
|
||||||
|
QSizeF imageSize = image.deviceIndependentSize();
|
||||||
if (!hasWidth)
|
if (!hasWidth)
|
||||||
size.setWidth(image.width() / image.devicePixelRatio());
|
size.setWidth(imageSize.width());
|
||||||
if (!hasHeight)
|
if (!hasHeight)
|
||||||
size.setHeight(image.height() / image.devicePixelRatio());
|
size.setHeight(imageSize.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal scale = 1.0;
|
qreal scale = 1.0;
|
||||||
|
@ -3568,9 +3568,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
|
|||||||
QPixmap pixmap = header->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), mode);
|
QPixmap pixmap = header->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), mode);
|
||||||
|
|
||||||
QRect pixr = header->rect;
|
QRect pixr = header->rect;
|
||||||
pixr.setY(header->rect.center().y() - (pixmap.height() / pixmap.devicePixelRatio() - 1) / 2);
|
QSizeF size = pixmap.deviceIndependentSize();
|
||||||
|
pixr.setY(header->rect.center().y() - (size.height() - 1) / 2);
|
||||||
proxy()->drawItemPixmap(p, pixr, Qt::AlignVCenter, pixmap);
|
proxy()->drawItemPixmap(p, pixr, Qt::AlignVCenter, pixmap);
|
||||||
textr.translate(pixmap.width() / pixmap.devicePixelRatio() + 2, 0);
|
textr.translate(size.width() + 2, 0);
|
||||||
}
|
}
|
||||||
QString text = header->text;
|
QString text = header->text;
|
||||||
if (const QStyleOptionHeaderV2 *headerV2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(header)) {
|
if (const QStyleOptionHeaderV2 *headerV2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(header)) {
|
||||||
@ -3627,12 +3628,13 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
|
|||||||
// Draw the text if it's needed.
|
// Draw the text if it's needed.
|
||||||
if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) {
|
if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) {
|
||||||
needText = true;
|
needText = true;
|
||||||
|
QSizeF size = pixmap.deviceIndependentSize();
|
||||||
if (tb->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
|
if (tb->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
|
||||||
pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio() + 6);
|
pr.setHeight(size.height() + 6);
|
||||||
cr.adjust(0, pr.bottom(), 0, -3);
|
cr.adjust(0, pr.bottom(), 0, -3);
|
||||||
alignment |= Qt::AlignCenter;
|
alignment |= Qt::AlignCenter;
|
||||||
} else {
|
} else {
|
||||||
pr.setWidth(pixmap.width() / pixmap.devicePixelRatio() + 8);
|
pr.setWidth(size.width() + 8);
|
||||||
cr.adjust(pr.right(), 0, 0, 0);
|
cr.adjust(pr.right(), 0, 0, 0);
|
||||||
alignment |= Qt::AlignLeft | Qt::AlignVCenter;
|
alignment |= Qt::AlignLeft | Qt::AlignVCenter;
|
||||||
}
|
}
|
||||||
@ -3812,12 +3814,11 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
|
|||||||
if (btn.state & State_On)
|
if (btn.state & State_On)
|
||||||
state = QIcon::On;
|
state = QIcon::On;
|
||||||
QPixmap pixmap = btn.icon.pixmap(btn.iconSize, p->device()->devicePixelRatio(), mode, state);
|
QPixmap pixmap = btn.icon.pixmap(btn.iconSize, p->device()->devicePixelRatio(), mode, state);
|
||||||
int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio();
|
QSizeF pixmapSize = pixmap.deviceIndependentSize();
|
||||||
int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio();
|
contentW += pixmapSize.width() + QMacStylePrivate::PushButtonContentPadding;
|
||||||
contentW += pixmapWidth + QMacStylePrivate::PushButtonContentPadding;
|
|
||||||
int iconLeftOffset = freeContentRect.x() + (freeContentRect.width() - contentW) / 2;
|
int iconLeftOffset = freeContentRect.x() + (freeContentRect.width() - contentW) / 2;
|
||||||
int iconTopOffset = freeContentRect.y() + (freeContentRect.height() - pixmapHeight) / 2;
|
int iconTopOffset = freeContentRect.y() + (freeContentRect.height() - pixmapSize.height()) / 2;
|
||||||
QRect iconDestRect(iconLeftOffset, iconTopOffset, pixmapWidth, pixmapHeight);
|
QRect iconDestRect(iconLeftOffset, iconTopOffset, pixmapSize.width(), pixmapSize.height());
|
||||||
QRect visualIconDestRect = visualRect(btn.direction, freeContentRect, iconDestRect);
|
QRect visualIconDestRect = visualRect(btn.direction, freeContentRect, iconDestRect);
|
||||||
proxy()->drawItemPixmap(p, visualIconDestRect, Qt::AlignLeft | Qt::AlignVCenter, pixmap);
|
proxy()->drawItemPixmap(p, visualIconDestRect, Qt::AlignLeft | Qt::AlignVCenter, pixmap);
|
||||||
int newOffset = iconDestRect.x() + iconDestRect.width()
|
int newOffset = iconDestRect.x() + iconDestRect.width()
|
||||||
@ -4314,13 +4315,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
QPixmap pixmap = mi->icon.pixmap(iconSize, p->device()->devicePixelRatio(), mode);
|
QPixmap pixmap = mi->icon.pixmap(iconSize, p->device()->devicePixelRatio(), mode);
|
||||||
int pixw = pixmap.width() / pixmap.devicePixelRatio();
|
|
||||||
int pixh = pixmap.height() / pixmap.devicePixelRatio();
|
|
||||||
QRect cr(xpos, mi->rect.y(), checkcol, mi->rect.height());
|
QRect cr(xpos, mi->rect.y(), checkcol, mi->rect.height());
|
||||||
QRect pmr(0, 0, pixw, pixh);
|
QSize size = pixmap.deviceIndependentSize().toSize();
|
||||||
|
QRect pmr(QPoint(0, 0), size);
|
||||||
pmr.moveCenter(cr.center());
|
pmr.moveCenter(cr.center());
|
||||||
p->drawPixmap(pmr.topLeft(), pixmap);
|
p->drawPixmap(pmr.topLeft(), pixmap);
|
||||||
xpos += pixw + 6;
|
xpos += size.width() + 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString s = mi->text;
|
QString s = mi->text;
|
||||||
|
@ -1273,9 +1273,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On);
|
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On);
|
||||||
else
|
else
|
||||||
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode);
|
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode);
|
||||||
const int pixw = pixmap.width() / pixmap.devicePixelRatio();
|
QRect pmr(QPoint(0, 0), pixmap.deviceIndependentSize().toSize());
|
||||||
const int pixh = pixmap.height() / pixmap.devicePixelRatio();
|
|
||||||
QRect pmr(0, 0, pixw, pixh);
|
|
||||||
pmr.moveCenter(vCheckRect.center());
|
pmr.moveCenter(vCheckRect.center());
|
||||||
painter->setPen(menuitem->palette.text().color());
|
painter->setPen(menuitem->palette.text().color());
|
||||||
painter->drawPixmap(pmr.topLeft(), pixmap);
|
painter->drawPixmap(pmr.topLeft(), pixmap);
|
||||||
|
@ -1974,9 +1974,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
QPixmap pixmap = checked ?
|
QPixmap pixmap = checked ?
|
||||||
menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On) :
|
menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On) :
|
||||||
menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode);
|
menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode);
|
||||||
const int pixw = pixmap.width() / pixmap.devicePixelRatio();
|
QRect iconRect(QPoint(0, 0), pixmap.deviceIndependentSize().toSize());
|
||||||
const int pixh = pixmap.height() / pixmap.devicePixelRatio();
|
|
||||||
QRect iconRect(0, 0, pixw, pixh);
|
|
||||||
iconRect.moveCenter(QRect(xpos, y, checkcol, h).center());
|
iconRect.moveCenter(QRect(xpos, y, checkcol, h).center());
|
||||||
QRect vIconRect = visualRect(option->direction, option->rect, iconRect);
|
QRect vIconRect = visualRect(option->direction, option->rect, iconRect);
|
||||||
p->setPen(menuitem->palette.text().color());
|
p->setPen(menuitem->palette.text().color());
|
||||||
|
@ -452,7 +452,7 @@ public:
|
|||||||
|
|
||||||
QSize minimumSizeHint() const override {
|
QSize minimumSizeHint() const override {
|
||||||
if (!pixmap(Qt::ReturnByValue).isNull())
|
if (!pixmap(Qt::ReturnByValue).isNull())
|
||||||
return pixmap(Qt::ReturnByValue).size() / pixmap(Qt::ReturnByValue).devicePixelRatio();
|
return pixmap(Qt::ReturnByValue).deviceIndependentSize().toSize();
|
||||||
return QFrame::minimumSizeHint();
|
return QFrame::minimumSizeHint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,7 +885,7 @@ Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius,
|
|||||||
if (p) {
|
if (p) {
|
||||||
p->scale(scale, scale);
|
p->scale(scale, scale);
|
||||||
p->setRenderHint(QPainter::SmoothPixmapTransform);
|
p->setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
p->drawImage(QRect(QPoint(0, 0), blurImage.size() / blurImage.devicePixelRatio()), blurImage);
|
p->drawImage(QRect(QPoint(0, 0), blurImage.deviceIndependentSize().toSize()), blurImage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9585,9 +9585,9 @@ QRectF QGraphicsPixmapItem::boundingRect() const
|
|||||||
return QRectF();
|
return QRectF();
|
||||||
if (d->flags & ItemIsSelectable) {
|
if (d->flags & ItemIsSelectable) {
|
||||||
qreal pw = 1.0;
|
qreal pw = 1.0;
|
||||||
return QRectF(d->offset, QSizeF(d->pixmap.size()) / d->pixmap.devicePixelRatio()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
|
return QRectF(d->offset, d->pixmap.deviceIndependentSize()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
|
||||||
} else {
|
} else {
|
||||||
return QRectF(d->offset, QSizeF(d->pixmap.size()) / d->pixmap.devicePixelRatio());
|
return QRectF(d->offset, d->pixmap.deviceIndependentSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1051,10 +1051,10 @@ QRect QItemDelegate::rect(const QStyleOptionViewItem &option,
|
|||||||
break;
|
break;
|
||||||
case QMetaType::QPixmap: {
|
case QMetaType::QPixmap: {
|
||||||
const QPixmap &pixmap = qvariant_cast<QPixmap>(value);
|
const QPixmap &pixmap = qvariant_cast<QPixmap>(value);
|
||||||
return QRect(QPoint(0, 0), pixmap.size() / pixmap.devicePixelRatio() ); }
|
return QRect(QPoint(0, 0), pixmap.deviceIndependentSize().toSize()); }
|
||||||
case QMetaType::QImage: {
|
case QMetaType::QImage: {
|
||||||
const QImage &image = qvariant_cast<QImage>(value);
|
const QImage &image = qvariant_cast<QImage>(value);
|
||||||
return QRect(QPoint(0, 0), image.size() / image.devicePixelRatio() ); }
|
return QRect(QPoint(0, 0), image.deviceIndependentSize().toSize()); }
|
||||||
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);
|
||||||
|
@ -343,13 +343,13 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option,
|
|||||||
case QMetaType::QImage: {
|
case QMetaType::QImage: {
|
||||||
QImage image = qvariant_cast<QImage>(*value);
|
QImage image = qvariant_cast<QImage>(*value);
|
||||||
option->icon = QIcon(QPixmap::fromImage(image));
|
option->icon = QIcon(QPixmap::fromImage(image));
|
||||||
option->decorationSize = image.size() / image.devicePixelRatio();
|
option->decorationSize = image.deviceIndependentSize().toSize();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QMetaType::QPixmap: {
|
case QMetaType::QPixmap: {
|
||||||
QPixmap pixmap = qvariant_cast<QPixmap>(*value);
|
QPixmap pixmap = qvariant_cast<QPixmap>(*value);
|
||||||
option->icon = QIcon(pixmap);
|
option->icon = QIcon(pixmap);
|
||||||
option->decorationSize = pixmap.size() / pixmap.devicePixelRatio();
|
option->decorationSize = pixmap.deviceIndependentSize().toSize();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -1652,10 +1652,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
|
|||||||
else
|
else
|
||||||
pixmap = menuItem->icon.pixmap(iconSize, painter->device()->devicePixelRatio(), mode);
|
pixmap = menuItem->icon.pixmap(iconSize, painter->device()->devicePixelRatio(), mode);
|
||||||
|
|
||||||
const int pixw = pixmap.width() / pixmap.devicePixelRatio();
|
QRect pmr(QPoint(0, 0), pixmap.deviceIndependentSize().toSize());
|
||||||
const int pixh = pixmap.height() / pixmap.devicePixelRatio();
|
|
||||||
|
|
||||||
QRect pmr(0, 0, pixw, pixh);
|
|
||||||
pmr.moveCenter(vCheckRect.center());
|
pmr.moveCenter(vCheckRect.center());
|
||||||
painter->setPen(menuItem->palette.text().color());
|
painter->setPen(menuItem->palette.text().color());
|
||||||
if (!ignoreCheckMark && checkable && checked) {
|
if (!ignoreCheckMark && checkable && checked) {
|
||||||
|
@ -573,8 +573,9 @@ QRect QStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pi
|
|||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
rect.getRect(&x, &y, &w, &h);
|
rect.getRect(&x, &y, &w, &h);
|
||||||
|
|
||||||
const int pixmapWidth = pixmap.width()/pixmap.devicePixelRatio();
|
QSizeF pixmapSize = pixmap.deviceIndependentSize();
|
||||||
const int pixmapHeight = pixmap.height()/pixmap.devicePixelRatio();
|
const int pixmapWidth = pixmapSize.width();
|
||||||
|
const int pixmapHeight = pixmapSize.height();
|
||||||
|
|
||||||
if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
|
if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
|
||||||
y += h/2 - pixmapHeight/2;
|
y += h/2 - pixmapHeight/2;
|
||||||
|
@ -1157,9 +1157,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
|||||||
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
|
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
|
||||||
else
|
else
|
||||||
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
|
pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
|
||||||
const int pixw = pixmap.width() / pixmap.devicePixelRatio();
|
QRect pmr(QPoint(0, 0), pixmap.deviceIndependentSize().toSize());
|
||||||
const int pixh = pixmap.height() / pixmap.devicePixelRatio();
|
|
||||||
QRect pmr(0, 0, pixw, pixh);
|
|
||||||
pmr.moveCenter(vCheckRect.center());
|
pmr.moveCenter(vCheckRect.center());
|
||||||
p->setPen(menuitem->palette.text().color());
|
p->setPen(menuitem->palette.text().color());
|
||||||
p->drawPixmap(pmr.topLeft(), pixmap);
|
p->drawPixmap(pmr.topLeft(), pixmap);
|
||||||
|
@ -604,7 +604,7 @@ QSize QLabelPrivate::sizeForWidth(int w) const
|
|||||||
|
|
||||||
if (pixmap && !pixmap->isNull()) {
|
if (pixmap && !pixmap->isNull()) {
|
||||||
br = pixmap->rect();
|
br = pixmap->rect();
|
||||||
br.setSize(br.size() / pixmap->devicePixelRatio());
|
br.setSize(pixmap->deviceIndependentSize().toSize());
|
||||||
#ifndef QT_NO_PICTURE
|
#ifndef QT_NO_PICTURE
|
||||||
} else if (picture && !picture->isNull()) {
|
} else if (picture && !picture->isNull()) {
|
||||||
br = picture->boundingRect();
|
br = picture->boundingRect();
|
||||||
@ -612,7 +612,7 @@ QSize QLabelPrivate::sizeForWidth(int w) const
|
|||||||
#if QT_CONFIG(movie)
|
#if QT_CONFIG(movie)
|
||||||
} else if (movie && !movie->currentPixmap().isNull()) {
|
} else if (movie && !movie->currentPixmap().isNull()) {
|
||||||
br = movie->currentPixmap().rect();
|
br = movie->currentPixmap().rect();
|
||||||
br.setSize(br.size() / movie->currentPixmap().devicePixelRatio());
|
br.setSize(movie->currentPixmap().deviceIndependentSize().toSize());
|
||||||
#endif
|
#endif
|
||||||
} else if (isTextLabel) {
|
} else if (isTextLabel) {
|
||||||
int align = QStyle::visualAlignment(textDirection(), QFlag(this->align));
|
int align = QStyle::visualAlignment(textDirection(), QFlag(this->align));
|
||||||
|
@ -422,7 +422,7 @@ ControlLabel::ControlLabel(QMdiSubWindow *subWindow, QWidget *parent)
|
|||||||
Q_UNUSED(subWindow);
|
Q_UNUSED(subWindow);
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
updateWindowIcon();
|
updateWindowIcon();
|
||||||
setFixedSize(label.size() / label.devicePixelRatio());
|
setFixedSize(label.deviceIndependentSize().toSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -430,7 +430,7 @@ ControlLabel::ControlLabel(QMdiSubWindow *subWindow, QWidget *parent)
|
|||||||
*/
|
*/
|
||||||
QSize ControlLabel::sizeHint() const
|
QSize ControlLabel::sizeHint() const
|
||||||
{
|
{
|
||||||
return label.size() / label.devicePixelRatio();
|
return label.deviceIndependentSize().toSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -284,7 +284,7 @@ void QSplashScreen::setPixmap(const QPixmap &pixmap)
|
|||||||
d->pixmap = pixmap;
|
d->pixmap = pixmap;
|
||||||
setAttribute(Qt::WA_TranslucentBackground, pixmap.hasAlpha());
|
setAttribute(Qt::WA_TranslucentBackground, pixmap.hasAlpha());
|
||||||
|
|
||||||
const QRect r(QPoint(), pixmap.size() / pixmap.devicePixelRatio());
|
const QRect r(QPoint(), pixmap.deviceIndependentSize().toSize());
|
||||||
resize(r.size());
|
resize(r.size());
|
||||||
|
|
||||||
move(screen()->geometry().center() - r.center());
|
move(screen()->geometry().center() - r.center());
|
||||||
|
@ -584,7 +584,7 @@ void tst_QLabel::taskQTBUG_48157_dprPixmap()
|
|||||||
pixmap.load(QFINDTESTDATA(QStringLiteral("red@2x.png")));
|
pixmap.load(QFINDTESTDATA(QStringLiteral("red@2x.png")));
|
||||||
QCOMPARE(pixmap.devicePixelRatio(), 2.0);
|
QCOMPARE(pixmap.devicePixelRatio(), 2.0);
|
||||||
label.setPixmap(pixmap);
|
label.setPixmap(pixmap);
|
||||||
QCOMPARE(label.sizeHint(), pixmap.rect().size() / pixmap.devicePixelRatio());
|
QCOMPARE(label.sizeHint(), pixmap.deviceIndependentSize().toSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QLabel::taskQTBUG_48157_dprMovie()
|
void tst_QLabel::taskQTBUG_48157_dprMovie()
|
||||||
@ -595,7 +595,7 @@ void tst_QLabel::taskQTBUG_48157_dprMovie()
|
|||||||
movie.start();
|
movie.start();
|
||||||
QCOMPARE(movie.currentPixmap().devicePixelRatio(), 2.0);
|
QCOMPARE(movie.currentPixmap().devicePixelRatio(), 2.0);
|
||||||
label.setMovie(&movie);
|
label.setMovie(&movie);
|
||||||
QCOMPARE(label.sizeHint(), movie.currentPixmap().size() / movie.currentPixmap().devicePixelRatio());
|
QCOMPARE(label.sizeHint(), movie.currentPixmap().deviceIndependentSize().toSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QLabel::resourceProvider()
|
void tst_QLabel::resourceProvider()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user