Port from devicePixelRatioF() to devicePixelRatio()
This ports all of QtBase. Change-Id: If6712da44d7749b97b74f4614a04fac360f69d9e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
e1ce78d484
commit
b3c991ae8f
@ -107,9 +107,9 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */)
|
||||
//! [6] //! [7]
|
||||
} else {
|
||||
//! [7] //! [8]
|
||||
auto previewPixmap = qFuzzyCompare(pixmap.devicePixelRatioF(), qreal(1))
|
||||
auto previewPixmap = qFuzzyCompare(pixmap.devicePixelRatio(), qreal(1))
|
||||
? pixmap
|
||||
: pixmap.scaled(pixmap.size() / pixmap.devicePixelRatioF(), Qt::KeepAspectRatio,
|
||||
: pixmap.scaled(pixmap.size() / pixmap.devicePixelRatio(), Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
double scaleFactor = pixmapScale / curScale;
|
||||
int newWidth = int(previewPixmap.width() * scaleFactor);
|
||||
@ -143,7 +143,7 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */)
|
||||
//! [10]
|
||||
void MandelbrotWidget::resizeEvent(QResizeEvent * /* event */)
|
||||
{
|
||||
thread.render(centerX, centerY, curScale, size(), devicePixelRatioF());
|
||||
thread.render(centerX, centerY, curScale, size(), devicePixelRatio());
|
||||
}
|
||||
//! [10]
|
||||
|
||||
@ -212,7 +212,7 @@ void MandelbrotWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
pixmapOffset += event->position().toPoint() - lastDragPos;
|
||||
lastDragPos = QPoint();
|
||||
|
||||
const auto pixmapSize = pixmap.size() / pixmap.devicePixelRatioF();
|
||||
const auto pixmapSize = pixmap.size() / pixmap.devicePixelRatio();
|
||||
int deltaX = (width() - pixmapSize.width()) / 2 - pixmapOffset.x();
|
||||
int deltaY = (height() - pixmapSize.height()) / 2 - pixmapOffset.y();
|
||||
scroll(deltaX, deltaY);
|
||||
@ -239,7 +239,7 @@ void MandelbrotWidget::zoom(double zoomFactor)
|
||||
{
|
||||
curScale *= zoomFactor;
|
||||
update();
|
||||
thread.render(centerX, centerY, curScale, size(), devicePixelRatioF());
|
||||
thread.render(centerX, centerY, curScale, size(), devicePixelRatio());
|
||||
}
|
||||
//! [17]
|
||||
|
||||
@ -249,6 +249,6 @@ void MandelbrotWidget::scroll(int deltaX, int deltaY)
|
||||
centerX += deltaX * curScale;
|
||||
centerY += deltaY * curScale;
|
||||
update();
|
||||
thread.render(centerX, centerY, curScale, size(), devicePixelRatioF());
|
||||
thread.render(centerX, centerY, curScale, size(), devicePixelRatio());
|
||||
}
|
||||
//! [18]
|
||||
|
@ -94,7 +94,7 @@ ToolBar::ToolBar(const QString &title, QWidget *parent)
|
||||
|
||||
setIconSize(QSize(32, 32));
|
||||
|
||||
qreal dpr = devicePixelRatioF();
|
||||
qreal dpr = devicePixelRatio();
|
||||
menu = new QMenu("One", this);
|
||||
menu->setIcon(genIcon(iconSize(), 1, Qt::black, dpr));
|
||||
menu->addAction(genIcon(iconSize(), "A", Qt::blue, dpr), "A");
|
||||
|
@ -290,8 +290,8 @@ QString FontInfoDialog::text() const
|
||||
|
||||
str << "Qt " << QT_VERSION_STR << " on " << QGuiApplication::platformName()
|
||||
<< ", " << logicalDpiX() << "DPI";
|
||||
if (!qFuzzyCompare(devicePixelRatioF(), qreal(1)))
|
||||
str << ", device pixel ratio: " << devicePixelRatioF();
|
||||
if (!qFuzzyCompare(devicePixelRatio(), qreal(1)))
|
||||
str << ", device pixel ratio: " << devicePixelRatio();
|
||||
str << "\n\nDefault font : " << defaultFont.family() << ", " << defaultFont.pointSizeF() << "pt\n"
|
||||
<< "Fixed font : " << fixedFont.family() << ", " << fixedFont.pointSizeF() << "pt\n"
|
||||
<< "Title font : " << titleFont.family() << ", " << titleFont.pointSizeF() << "pt\n"
|
||||
|
@ -170,7 +170,7 @@ void IconPreviewArea::updatePixmapLabels()
|
||||
tr("Size: %1x%2\nActual size: %3x%4\nDevice pixel ratio: %5")
|
||||
.arg(size.width()).arg(size.height())
|
||||
.arg(actualSize.width()).arg(actualSize.height())
|
||||
.arg(pixmap.devicePixelRatioF());
|
||||
.arg(pixmap.devicePixelRatio());
|
||||
}
|
||||
pixmapLabel->setToolTip(toolTip);
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ QWidget *MainWindow::createIconSizeGroupBox()
|
||||
|
||||
void MainWindow::screenChanged()
|
||||
{
|
||||
devicePixelRatioLabel->setText(QString::number(devicePixelRatioF()));
|
||||
devicePixelRatioLabel->setText(QString::number(devicePixelRatio()));
|
||||
if (const QWindow *window = windowHandle()) {
|
||||
const QScreen *screen = window->screen();
|
||||
const QString screenDescription =
|
||||
|
@ -133,7 +133,7 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
|
||||
//! [4]
|
||||
void TabletCanvas::initPixmap()
|
||||
{
|
||||
qreal dpr = devicePixelRatioF();
|
||||
qreal dpr = devicePixelRatio();
|
||||
QPixmap newPixmap = QPixmap(qRound(width() * dpr), qRound(height() * dpr));
|
||||
newPixmap.setDevicePixelRatio(dpr);
|
||||
newPixmap.fill(Qt::white);
|
||||
@ -149,8 +149,8 @@ void TabletCanvas::paintEvent(QPaintEvent *event)
|
||||
if (m_pixmap.isNull())
|
||||
initPixmap();
|
||||
QPainter painter(this);
|
||||
QRect pixmapPortion = QRect(event->rect().topLeft() * devicePixelRatioF(),
|
||||
event->rect().size() * devicePixelRatioF());
|
||||
QRect pixmapPortion = QRect(event->rect().topLeft() * devicePixelRatio(),
|
||||
event->rect().size() * devicePixelRatio());
|
||||
painter.drawPixmap(event->rect().topLeft(), m_pixmap, pixmapPortion);
|
||||
}
|
||||
//! [4]
|
||||
|
@ -185,7 +185,7 @@ QPixmapIconEngine::~QPixmapIconEngine()
|
||||
void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)
|
||||
{
|
||||
auto paintDevice = painter->device();
|
||||
qreal dpr = paintDevice ? paintDevice->devicePixelRatioF() : qApp->devicePixelRatio();
|
||||
qreal dpr = paintDevice ? paintDevice->devicePixelRatio() : qApp->devicePixelRatio();
|
||||
const QSize pixmapSize = rect.size() * dpr;
|
||||
QPixmap px = pixmap(pixmapSize, mode, state);
|
||||
painter->drawPixmap(rect, px);
|
||||
|
@ -641,7 +641,7 @@ void QIconLoaderEngine::ensureLoaded()
|
||||
void QIconLoaderEngine::paint(QPainter *painter, const QRect &rect,
|
||||
QIcon::Mode mode, QIcon::State state)
|
||||
{
|
||||
QSize pixmapSize = rect.size() * painter->device()->devicePixelRatioF();
|
||||
QSize pixmapSize = rect.size() * painter->device()->devicePixelRatio();
|
||||
painter->drawPixmap(rect, pixmap(pixmapSize, mode, state));
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ QT_END_NAMESPACE
|
||||
// NSImage.
|
||||
auto nsImage = [[NSImage alloc] initWithSize:NSZeroSize];
|
||||
auto *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
|
||||
imageRep.size = (image.size() / image.devicePixelRatioF()).toCGSize();
|
||||
imageRep.size = (image.size() / image.devicePixelRatio()).toCGSize();
|
||||
[nsImage addRepresentation:[imageRep autorelease]];
|
||||
Q_ASSERT(CGSizeEqualToSize(nsImage.size, imageRep.size));
|
||||
|
||||
@ -178,7 +178,7 @@ QT_END_NAMESPACE
|
||||
continue;
|
||||
|
||||
auto *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
|
||||
imageRep.size = (image.size() / image.devicePixelRatioF()).toCGSize();
|
||||
imageRep.size = (image.size() / image.devicePixelRatio()).toCGSize();
|
||||
[nsImage addRepresentation:[imageRep autorelease]];
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ void QEmulationPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
|
||||
return;
|
||||
}
|
||||
} else if (style == Qt::TexturePattern) {
|
||||
qreal dpr = qHasPixmapTexture(brush) ? brush.texture().devicePixelRatioF() : brush.textureImage().devicePixelRatioF();
|
||||
qreal dpr = qHasPixmapTexture(brush) ? brush.texture().devicePixelRatio() : brush.textureImage().devicePixelRatio();
|
||||
if (!qFuzzyCompare(dpr, qreal(1.0))) {
|
||||
QBrush copy = brush;
|
||||
combineXForm(©, QRectF(0, 0, 1.0/dpr, 1.0/dpr));
|
||||
|
@ -951,8 +951,8 @@ void QPaintEngineEx::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, con
|
||||
{
|
||||
QBrush brush(state()->pen.color(), pixmap);
|
||||
QTransform xform = QTransform::fromTranslate(r.x() - s.x(), r.y() - s.y());
|
||||
if (!qFuzzyCompare(pixmap.devicePixelRatioF(), qreal(1.0)))
|
||||
xform.scale(1.0/pixmap.devicePixelRatioF(), 1.0/pixmap.devicePixelRatioF());
|
||||
if (!qFuzzyCompare(pixmap.devicePixelRatio(), qreal(1.0)))
|
||||
xform.scale(1.0/pixmap.devicePixelRatio(), 1.0/pixmap.devicePixelRatio());
|
||||
brush.setTransform(xform);
|
||||
|
||||
qreal pts[] = { r.x(), r.y(),
|
||||
|
@ -197,9 +197,9 @@ void QPainterPrivate::checkEmulation()
|
||||
|
||||
if (state->brush.style() == Qt::TexturePattern) {
|
||||
if (qHasPixmapTexture(state->brush))
|
||||
doEmulation |= !qFuzzyCompare(state->brush.texture().devicePixelRatioF(), qreal(1.0));
|
||||
doEmulation |= !qFuzzyCompare(state->brush.texture().devicePixelRatio(), qreal(1.0));
|
||||
else
|
||||
doEmulation |= !qFuzzyCompare(state->brush.textureImage().devicePixelRatioF(), qreal(1.0));
|
||||
doEmulation |= !qFuzzyCompare(state->brush.textureImage().devicePixelRatio(), qreal(1.0));
|
||||
}
|
||||
|
||||
if (doEmulation && extended->flags() & QPaintEngineEx::DoNotEmulate)
|
||||
@ -242,7 +242,7 @@ qreal QPainterPrivate::effectiveDevicePixelRatio() const
|
||||
if (device->devType() == QInternal::Printer)
|
||||
return qreal(1);
|
||||
|
||||
return qMax(qreal(1), device->devicePixelRatioF());
|
||||
return qMax(qreal(1), device->devicePixelRatio());
|
||||
}
|
||||
|
||||
QTransform QPainterPrivate::hidpiScaleTransform() const
|
||||
|
@ -240,10 +240,10 @@ void QTextImageHandler::drawObject(QPainter *p, const QRectF &rect, QTextDocumen
|
||||
const QTextImageFormat imageFormat = format.toImageFormat();
|
||||
|
||||
if (QCoreApplication::instance()->thread() != QThread::currentThread()) {
|
||||
const QImage image = getImage(doc, imageFormat, p->device()->devicePixelRatioF());
|
||||
const QImage image = getImage(doc, imageFormat, p->device()->devicePixelRatio());
|
||||
p->drawImage(rect, image, image.rect());
|
||||
} else {
|
||||
const QPixmap pixmap = getPixmap(doc, imageFormat, p->device()->devicePixelRatioF());
|
||||
const QPixmap pixmap = getPixmap(doc, imageFormat, p->device()->devicePixelRatio());
|
||||
p->drawPixmap(rect, pixmap, pixmap.rect());
|
||||
}
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ void QOpenGLWidgetPrivate::recreateFbo()
|
||||
if (textureFormat)
|
||||
format.setInternalTextureFormat(textureFormat);
|
||||
|
||||
const QSize deviceSize = q->size() * q->devicePixelRatioF();
|
||||
const QSize deviceSize = q->size() * q->devicePixelRatio();
|
||||
fbo = new QOpenGLFramebufferObject(deviceSize, format);
|
||||
if (samples > 0)
|
||||
resolvedFbo = new QOpenGLFramebufferObject(deviceSize);
|
||||
@ -707,7 +707,7 @@ void QOpenGLWidgetPrivate::recreateFbo()
|
||||
flushPending = true; // Make sure the FBO is initialized before use
|
||||
|
||||
paintDevice->setSize(deviceSize);
|
||||
paintDevice->setDevicePixelRatio(q->devicePixelRatioF());
|
||||
paintDevice->setDevicePixelRatio(q->devicePixelRatio());
|
||||
|
||||
emit q->resized();
|
||||
}
|
||||
@ -794,8 +794,8 @@ void QOpenGLWidgetPrivate::initialize()
|
||||
}
|
||||
|
||||
paintDevice = new QOpenGLWidgetPaintDevice(q);
|
||||
paintDevice->setSize(q->size() * q->devicePixelRatioF());
|
||||
paintDevice->setDevicePixelRatio(q->devicePixelRatioF());
|
||||
paintDevice->setSize(q->size() * q->devicePixelRatio());
|
||||
paintDevice->setDevicePixelRatio(q->devicePixelRatio());
|
||||
|
||||
context = ctx.take();
|
||||
initialized = true;
|
||||
@ -824,7 +824,7 @@ void QOpenGLWidgetPrivate::invokeUserPaint()
|
||||
QOpenGLFunctions *f = ctx->functions();
|
||||
QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbo->handle();
|
||||
|
||||
f->glViewport(0, 0, q->width() * q->devicePixelRatioF(), q->height() * q->devicePixelRatioF());
|
||||
f->glViewport(0, 0, q->width() * q->devicePixelRatio(), q->height() * q->devicePixelRatio());
|
||||
inPaintGL = true;
|
||||
q->paintGL();
|
||||
inPaintGL = false;
|
||||
@ -898,8 +898,8 @@ QImage QOpenGLWidgetPrivate::grabFramebuffer()
|
||||
}
|
||||
|
||||
const bool hasAlpha = q->format().hasAlpha();
|
||||
QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatioF(), hasAlpha, hasAlpha);
|
||||
res.setDevicePixelRatio(q->devicePixelRatioF());
|
||||
QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatio(), hasAlpha, hasAlpha);
|
||||
res.setDevicePixelRatio(q->devicePixelRatio());
|
||||
|
||||
// While we give no guarantees of what is going to be left bound, prefer the
|
||||
// multisample fbo instead of the resolved one. Clients may continue to
|
||||
@ -924,7 +924,7 @@ void QOpenGLWidgetPrivate::resizeViewportFramebuffer()
|
||||
if (!initialized)
|
||||
return;
|
||||
|
||||
if (!fbo || q->size() * q->devicePixelRatioF() != fbo->size()) {
|
||||
if (!fbo || q->size() * q->devicePixelRatio() != fbo->size()) {
|
||||
recreateFbo();
|
||||
q->update();
|
||||
}
|
||||
@ -1403,7 +1403,7 @@ bool QOpenGLWidget::event(QEvent *e)
|
||||
}
|
||||
break;
|
||||
case QEvent::ScreenChangeInternal:
|
||||
if (d->initialized && d->paintDevice->devicePixelRatioF() != devicePixelRatioF())
|
||||
if (d->initialized && d->paintDevice->devicePixelRatio() != devicePixelRatio())
|
||||
d->recreateFbo();
|
||||
break;
|
||||
default:
|
||||
|
@ -456,7 +456,7 @@ void QWasmCompositor::drawFrameWindow(QWasmFrameOptions options, QPainter *paint
|
||||
const QColor &c4 = options.palette.dark().color();
|
||||
const QBrush *fill = 0;
|
||||
|
||||
const qreal devicePixelRatio = painter->device()->devicePixelRatioF();
|
||||
const qreal devicePixelRatio = painter->device()->devicePixelRatio();
|
||||
if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
|
||||
const qreal inverseScale = qreal(1) / devicePixelRatio;
|
||||
painter->scale(inverseScale, inverseScale);
|
||||
@ -599,7 +599,7 @@ void QWasmCompositor::drawShadePanel(QWasmTitleBarOptions options, QPainter *pai
|
||||
int w = options.rect.width();
|
||||
int h = options.rect.height();
|
||||
|
||||
const qreal devicePixelRatio = painter->device()->devicePixelRatioF();
|
||||
const qreal devicePixelRatio = painter->device()->devicePixelRatio();
|
||||
if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
|
||||
const qreal inverseScale = qreal(1) / devicePixelRatio;
|
||||
painter->scale(inverseScale, inverseScale);
|
||||
|
@ -102,7 +102,7 @@ QWindowsPixmapCursorCacheKey::QWindowsPixmapCursorCacheKey(const QCursor &c)
|
||||
HCURSOR QWindowsCursor::createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot, qreal scaleFactor)
|
||||
{
|
||||
HCURSOR cur = nullptr;
|
||||
const qreal pixmapScaleFactor = scaleFactor / pixmap.devicePixelRatioF();
|
||||
const qreal pixmapScaleFactor = scaleFactor / pixmap.devicePixelRatio();
|
||||
if (!qFuzzyCompare(pixmapScaleFactor, 1)) {
|
||||
pixmap = pixmap.scaled((pixmapScaleFactor * QSizeF(pixmap.size())).toSize(),
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
@ -170,7 +170,7 @@ static HCURSOR createBitmapCursor(const QCursor &cursor, qreal scaleFactor = 1)
|
||||
Q_ASSERT(cursor.shape() == Qt::BitmapCursor && !cursor.bitmap(Qt::ReturnByValue).isNull());
|
||||
QImage bbits = cursor.bitmap(Qt::ReturnByValue).toImage();
|
||||
QImage mbits = cursor.mask(Qt::ReturnByValue).toImage();
|
||||
scaleFactor /= bbits.devicePixelRatioF();
|
||||
scaleFactor /= bbits.devicePixelRatio();
|
||||
if (!qFuzzyCompare(scaleFactor, 1)) {
|
||||
const QSize scaledSize = (QSizeF(bbits.size()) * scaleFactor).toSize();
|
||||
bbits = bbits.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
@ -3977,7 +3977,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
|
||||
|
||||
if (needsInactiveHack) {
|
||||
// First, render tab as non-selected tab on a pixamp
|
||||
const qreal pixelRatio = p->device()->devicePixelRatioF();
|
||||
const qreal pixelRatio = p->device()->devicePixelRatio();
|
||||
QImage tabPixmap(opt->rect.size() * pixelRatio, QImage::Format_ARGB32_Premultiplied);
|
||||
tabPixmap.setDevicePixelRatio(pixelRatio);
|
||||
tabPixmap.fill(Qt::transparent);
|
||||
@ -5570,7 +5570,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
|
||||
QPainterPath outerFramePath = d->windowPanelPath(outerFrameRect);
|
||||
p->fillPath(outerFramePath, opt->palette.dark());
|
||||
|
||||
const auto frameAdjust = 1.0 / p->device()->devicePixelRatioF();
|
||||
const auto frameAdjust = 1.0 / p->device()->devicePixelRatio();
|
||||
const auto innerFrameRect = outerFrameRect.adjusted(frameAdjust, frameAdjust, -frameAdjust, 0);
|
||||
QPainterPath innerFramePath = d->windowPanelPath(innerFrameRect);
|
||||
if (isActive) {
|
||||
|
@ -679,7 +679,7 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData, qreal correc
|
||||
|
||||
bool translucentToplevel = false;
|
||||
const QPaintDevice *paintDevice = painter->device();
|
||||
const qreal aditionalDevicePixelRatio = themeData.widget ? themeData.widget->devicePixelRatioF() : qreal(1);
|
||||
const qreal aditionalDevicePixelRatio = themeData.widget ? themeData.widget->devicePixelRatio() : qreal(1);
|
||||
if (paintDevice->devType() == QInternal::Widget) {
|
||||
const QWidget *window = static_cast<const QWidget *>(paintDevice)->window();
|
||||
translucentToplevel = window->testAttribute(Qt::WA_TranslucentBackground);
|
||||
@ -2495,7 +2495,7 @@ static void populateMdiButtonTheme(const QStyle *proxy, const QWidget *widget,
|
||||
// small on High DPI screens (QTBUG-75927).
|
||||
qreal mdiButtonCorrectionFactor(XPThemeData &theme, const QPaintDevice *pd = nullptr)
|
||||
{
|
||||
const auto dpr = pd ? pd->devicePixelRatioF() : qApp->devicePixelRatio();
|
||||
const auto dpr = pd ? pd->devicePixelRatio() : qApp->devicePixelRatio();
|
||||
const QSizeF nativeSize = QSizeF(theme.size()) / dpr;
|
||||
const QSizeF requestedSize(theme.rect.size());
|
||||
const auto rawFactor = qMin(requestedSize.width() / nativeSize.width(),
|
||||
|
@ -162,12 +162,12 @@ inline bool qCompare(QImage const &t1, QImage const &t2,
|
||||
}
|
||||
if (t1Null && t2Null)
|
||||
return compare_helper(true, nullptr, nullptr, nullptr, actual, expected, file, line);
|
||||
if (!qFuzzyCompare(t1.devicePixelRatioF(), t2.devicePixelRatioF())) {
|
||||
if (!qFuzzyCompare(t1.devicePixelRatio(), t2.devicePixelRatio())) {
|
||||
qsnprintf(msg, 1024, "Compared QImages differ in device pixel ratio.\n"
|
||||
" Actual (%s): %g\n"
|
||||
" Expected (%s): %g",
|
||||
actual, t1.devicePixelRatioF(),
|
||||
expected, t2.devicePixelRatioF());
|
||||
actual, t1.devicePixelRatio(),
|
||||
expected, t2.devicePixelRatio());
|
||||
return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line);
|
||||
}
|
||||
if (t1.width() != t2.width() || t1.height() != t2.height()) {
|
||||
@ -204,12 +204,12 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c
|
||||
}
|
||||
if (t1Null && t2Null)
|
||||
return compare_helper(true, nullptr, nullptr, nullptr, actual, expected, file, line);
|
||||
if (!qFuzzyCompare(t1.devicePixelRatioF(), t2.devicePixelRatioF())) {
|
||||
if (!qFuzzyCompare(t1.devicePixelRatio(), t2.devicePixelRatio())) {
|
||||
qsnprintf(msg, 1024, "Compared QPixmaps differ in device pixel ratio.\n"
|
||||
" Actual (%s): %g\n"
|
||||
" Expected (%s): %g",
|
||||
actual, t1.devicePixelRatioF(),
|
||||
expected, t2.devicePixelRatioF());
|
||||
actual, t1.devicePixelRatio(),
|
||||
expected, t2.devicePixelRatio());
|
||||
return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line);
|
||||
}
|
||||
if (t1.width() != t2.width() || t1.height() != t2.height()) {
|
||||
|
@ -719,7 +719,7 @@ void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transp
|
||||
}
|
||||
|
||||
QImage temp(img.height(), img.width(), img.format());
|
||||
temp.setDevicePixelRatio(img.devicePixelRatioF());
|
||||
temp.setDevicePixelRatio(img.devicePixelRatio());
|
||||
if (transposed >= 0) {
|
||||
if (img.depth() == 8) {
|
||||
qt_memrotate270(reinterpret_cast<const quint8*>(img.bits()),
|
||||
@ -781,7 +781,7 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source)
|
||||
if (source.format() == QImage::Format_Indexed8 || source.format() == QImage::Format_Grayscale8) {
|
||||
// assumes grayscale
|
||||
QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
|
||||
dest.setDevicePixelRatio(source.devicePixelRatioF());
|
||||
dest.setDevicePixelRatio(source.devicePixelRatio());
|
||||
|
||||
const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits());
|
||||
qsizetype sx = srcImage.bytesPerLine();
|
||||
@ -803,7 +803,7 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source)
|
||||
return dest;
|
||||
} else if (source.format() == QImage::Format_ARGB8565_Premultiplied) {
|
||||
QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
|
||||
dest.setDevicePixelRatio(source.devicePixelRatioF());
|
||||
dest.setDevicePixelRatio(source.devicePixelRatio());
|
||||
|
||||
const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits());
|
||||
qsizetype sx = srcImage.bytesPerLine();
|
||||
@ -840,7 +840,7 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source)
|
||||
}
|
||||
|
||||
QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
|
||||
dest.setDevicePixelRatio(source.devicePixelRatioF());
|
||||
dest.setDevicePixelRatio(source.devicePixelRatio());
|
||||
|
||||
const quint32 *src = reinterpret_cast<const quint32*>(const_cast<const QImage &>(srcImage).bits());
|
||||
qsizetype sx = srcImage.bytesPerLine() >> 2;
|
||||
@ -885,7 +885,7 @@ Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius,
|
||||
if (p) {
|
||||
p->scale(scale, scale);
|
||||
p->setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
p->drawImage(QRect(QPoint(0, 0), blurImage.size() / blurImage.devicePixelRatioF()), blurImage);
|
||||
p->drawImage(QRect(QPoint(0, 0), blurImage.size() / blurImage.devicePixelRatio()), blurImage);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1114,7 +1114,7 @@ void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const Q
|
||||
srcImage = std::move(srcImage).convertToFormat(format);
|
||||
destImage = QImage(rect.size(), srcImage.format());
|
||||
}
|
||||
destImage.setDevicePixelRatio(src.devicePixelRatioF());
|
||||
destImage.setDevicePixelRatio(src.devicePixelRatio());
|
||||
|
||||
// do colorizing
|
||||
QPainter destPainter(&destImage);
|
||||
@ -1323,7 +1323,7 @@ void QPixmapDropShadowFilter::draw(QPainter *p,
|
||||
return;
|
||||
|
||||
QImage tmp(px.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
tmp.setDevicePixelRatio(px.devicePixelRatioF());
|
||||
tmp.setDevicePixelRatio(px.devicePixelRatio());
|
||||
tmp.fill(0);
|
||||
QPainter tmpPainter(&tmp);
|
||||
tmpPainter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
@ -1332,7 +1332,7 @@ void QPixmapDropShadowFilter::draw(QPainter *p,
|
||||
|
||||
// blur the alpha channel
|
||||
QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
blurred.setDevicePixelRatio(px.devicePixelRatioF());
|
||||
blurred.setDevicePixelRatio(px.devicePixelRatio());
|
||||
blurred.fill(0);
|
||||
QPainter blurPainter(&blurred);
|
||||
qt_blurImage(&blurPainter, tmp, d->radius, false, true);
|
||||
|
@ -11194,7 +11194,7 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
|
||||
if (effectRect.isEmpty())
|
||||
return QPixmap();
|
||||
|
||||
const auto dpr = info ? info->painter->device()->devicePixelRatioF() : 1.0;
|
||||
const auto dpr = info ? info->painter->device()->devicePixelRatio() : 1.0;
|
||||
QPixmap pixmap(QRectF(effectRectF.topLeft(), effectRectF.size() * dpr).toAlignedRect().size());
|
||||
pixmap.setDevicePixelRatio(dpr);
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
@ -3449,7 +3449,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
|
||||
// Recreate the background pixmap, and flag the whole background as
|
||||
// exposed.
|
||||
if (d->mustResizeBackgroundPixmap) {
|
||||
const qreal dpr = d->viewport->devicePixelRatioF();
|
||||
const qreal dpr = d->viewport->devicePixelRatio();
|
||||
d->backgroundPixmap = QPixmap(viewport()->size() * dpr);
|
||||
d->backgroundPixmap.setDevicePixelRatio(dpr);
|
||||
QBrush bgBrush = viewport()->palette().brush(viewport()->backgroundRole());
|
||||
|
@ -3350,7 +3350,7 @@ void QHeaderViewPrivate::setupSectionIndicator(int section, int position)
|
||||
sectionIndicator->resize(w, h);
|
||||
#endif
|
||||
|
||||
const qreal pixmapDevicePixelRatio = q->devicePixelRatioF();
|
||||
const qreal pixmapDevicePixelRatio = q->devicePixelRatio();
|
||||
QPixmap pm(QSize(w, h) * pixmapDevicePixelRatio);
|
||||
pm.setDevicePixelRatio(pixmapDevicePixelRatio);
|
||||
pm.fill(QColor(0, 0, 0, 45));
|
||||
|
@ -3254,8 +3254,8 @@ void QTreeViewPrivate::drawAnimatedOperation(QPainter *painter) const
|
||||
QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation(const QRect &rect) const
|
||||
{
|
||||
Q_Q(const QTreeView);
|
||||
QPixmap pixmap(rect.size() * q->devicePixelRatioF());
|
||||
pixmap.setDevicePixelRatio(q->devicePixelRatioF());
|
||||
QPixmap pixmap(rect.size() * q->devicePixelRatio());
|
||||
pixmap.setDevicePixelRatio(q->devicePixelRatio());
|
||||
if (rect.size().isEmpty())
|
||||
return pixmap;
|
||||
pixmap.fill(Qt::transparent); //the base might not be opaque, and we don't want uninitialized pixels.
|
||||
|
@ -5072,7 +5072,7 @@ QPixmap QWidget::grab(const QRect &rectangle)
|
||||
if (!r.intersects(rect()))
|
||||
return QPixmap();
|
||||
|
||||
const qreal dpr = devicePixelRatioF();
|
||||
const qreal dpr = devicePixelRatio();
|
||||
QPixmap res((QSizeF(r.size()) * dpr).toSize());
|
||||
res.setDevicePixelRatio(dpr);
|
||||
if (!d->isOpaque)
|
||||
@ -5237,7 +5237,7 @@ void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset
|
||||
if (size.isNull())
|
||||
return;
|
||||
|
||||
const qreal pixmapDevicePixelRatio = painter->device()->devicePixelRatioF();
|
||||
const qreal pixmapDevicePixelRatio = painter->device()->devicePixelRatio();
|
||||
QPixmap pixmap(size * pixmapDevicePixelRatio);
|
||||
pixmap.setDevicePixelRatio(pixmapDevicePixelRatio);
|
||||
|
||||
@ -5308,7 +5308,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
|
||||
QWidgetPaintContext context(pdev, rgn, offset, flags, sharedPainter, repaintManager);
|
||||
sourced->context = &context;
|
||||
if (!sharedPainter) {
|
||||
setSystemClip(pdev->paintEngine(), pdev->devicePixelRatioF(), rgn.translated(offset));
|
||||
setSystemClip(pdev->paintEngine(), pdev->devicePixelRatio(), rgn.translated(offset));
|
||||
QPainter p(pdev);
|
||||
p.translate(offset);
|
||||
context.painter = &p;
|
||||
@ -5322,7 +5322,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
|
||||
}
|
||||
sharedPainter->save();
|
||||
sharedPainter->translate(offset);
|
||||
setSystemClip(sharedPainter->paintEngine(), sharedPainter->device()->devicePixelRatioF(), rgn.translated(offset));
|
||||
setSystemClip(sharedPainter->paintEngine(), sharedPainter->device()->devicePixelRatio(), rgn.translated(offset));
|
||||
graphicsEffect->draw(sharedPainter);
|
||||
setSystemClip(sharedPainter->paintEngine(), 1, QRegion());
|
||||
sharedPainter->restore();
|
||||
@ -5362,7 +5362,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
|
||||
setRedirected(pdev, -offset);
|
||||
|
||||
if (sharedPainter)
|
||||
setSystemClip(pdev->paintEngine(), pdev->devicePixelRatioF(), toBePainted);
|
||||
setSystemClip(pdev->paintEngine(), pdev->devicePixelRatio(), toBePainted);
|
||||
else
|
||||
paintEngine->d_func()->systemRect = q->data->crect;
|
||||
|
||||
@ -5380,7 +5380,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
|
||||
}
|
||||
|
||||
if (!sharedPainter)
|
||||
setSystemClip(pdev->paintEngine(), pdev->devicePixelRatioF(), toBePainted.translated(offset));
|
||||
setSystemClip(pdev->paintEngine(), pdev->devicePixelRatio(), toBePainted.translated(offset));
|
||||
|
||||
if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) {
|
||||
#ifndef QT_NO_OPENGL
|
||||
@ -5687,7 +5687,7 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *
|
||||
|
||||
qreal dpr(1.0);
|
||||
if (const auto *paintDevice = context->painter->device())
|
||||
dpr = paintDevice->devicePixelRatioF();
|
||||
dpr = paintDevice->devicePixelRatio();
|
||||
else
|
||||
qWarning("QWidgetEffectSourcePrivate::pixmap: Painter not active");
|
||||
QPixmap pixmap(effectRect.size() * dpr);
|
||||
@ -12842,7 +12842,7 @@ QDebug operator<<(QDebug debug, const QWidget *widget)
|
||||
frameGeometry.bottom() - geometry.bottom());
|
||||
debug << ", margins=" << margins;
|
||||
}
|
||||
debug << ", devicePixelRatio=" << widget->devicePixelRatioF();
|
||||
debug << ", devicePixelRatio=" << widget->devicePixelRatio();
|
||||
if (const WId wid = widget->internalWinId())
|
||||
debug << ", winId=0x" << Qt::hex << wid << Qt::dec;
|
||||
}
|
||||
|
@ -749,7 +749,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
|
||||
% QLatin1String(metaObject()->className()), opt, QSize(size, size))
|
||||
% HexString<uint>(pe);
|
||||
if (!QPixmapCache::find(pixmapName, &pixmap)) {
|
||||
qreal pixelRatio = p->device()->devicePixelRatioF();
|
||||
qreal pixelRatio = p->device()->devicePixelRatio();
|
||||
int border = qRound(pixelRatio*(size/5));
|
||||
int sqsize = qRound(pixelRatio*(2*(size/2)));
|
||||
QImage image(sqsize, sqsize, QImage::Format_ARGB32_Premultiplied);
|
||||
|
@ -244,7 +244,7 @@ void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
|
||||
}
|
||||
|
||||
PainterStateGuard painterGuard(p);
|
||||
const qreal devicePixelRatio = p->device()->devicePixelRatioF();
|
||||
const qreal devicePixelRatio = p->device()->devicePixelRatio();
|
||||
if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
|
||||
painterGuard.save();
|
||||
const qreal inverseScale = qreal(1) / devicePixelRatio;
|
||||
@ -358,7 +358,7 @@ void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
|
||||
}
|
||||
|
||||
PainterStateGuard painterGuard(p);
|
||||
const qreal devicePixelRatio = p->device()->devicePixelRatioF();
|
||||
const qreal devicePixelRatio = p->device()->devicePixelRatio();
|
||||
if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
|
||||
painterGuard.save();
|
||||
const qreal inverseScale = qreal(1) / devicePixelRatio;
|
||||
@ -449,7 +449,7 @@ static void qDrawWinShades(QPainter *p,
|
||||
return;
|
||||
|
||||
PainterStateGuard painterGuard(p);
|
||||
const qreal devicePixelRatio = p->device()->devicePixelRatioF();
|
||||
const qreal devicePixelRatio = p->device()->devicePixelRatio();
|
||||
if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
|
||||
painterGuard.save();
|
||||
const qreal inverseScale = qreal(1) / devicePixelRatio;
|
||||
@ -591,7 +591,7 @@ void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c,
|
||||
}
|
||||
|
||||
PainterStateGuard painterGuard(p);
|
||||
const qreal devicePixelRatio = p->device()->devicePixelRatioF();
|
||||
const qreal devicePixelRatio = p->device()->devicePixelRatio();
|
||||
if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
|
||||
painterGuard.save();
|
||||
const qreal inverseScale = qreal(1) / devicePixelRatio;
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = nullptr, const QWidget *widget = nullptr);
|
||||
static int fixedPixelMetric(QStyle::PixelMetric pm);
|
||||
static qreal devicePixelRatio(const QWidget *widget = nullptr)
|
||||
{ return widget ? widget->devicePixelRatioF() : QWindowsStylePrivate::appDevicePixelRatio(); }
|
||||
{ return widget ? widget->devicePixelRatio() : QWindowsStylePrivate::appDevicePixelRatio(); }
|
||||
static qreal nativeMetricScaleFactor(const QWidget *widget = nullptr);
|
||||
static bool isDarkMode();
|
||||
|
||||
|
@ -1129,7 +1129,7 @@ void QLabel::paintEvent(QPaintEvent *)
|
||||
if (d->pixmap && !d->pixmap->isNull()) {
|
||||
QPixmap pix;
|
||||
if (d->scaledcontents) {
|
||||
QSize scaledSize = cr.size() * devicePixelRatioF();
|
||||
QSize scaledSize = cr.size() * devicePixelRatio();
|
||||
if (!d->scaledpixmap || d->scaledpixmap->size() != scaledSize) {
|
||||
if (!d->cachedimage)
|
||||
d->cachedimage = new QImage(d->pixmap->toImage());
|
||||
@ -1138,7 +1138,7 @@ void QLabel::paintEvent(QPaintEvent *)
|
||||
d->cachedimage->scaled(scaledSize,
|
||||
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
d->scaledpixmap = new QPixmap(QPixmap::fromImage(std::move(scaledImage)));
|
||||
d->scaledpixmap->setDevicePixelRatio(devicePixelRatioF());
|
||||
d->scaledpixmap->setDevicePixelRatio(devicePixelRatio());
|
||||
}
|
||||
pix = *d->scaledpixmap;
|
||||
} else
|
||||
|
@ -2226,8 +2226,8 @@ void QTabBarPrivate::setupMovableTab()
|
||||
else
|
||||
grabRect.adjust(-taboverlap, 0, taboverlap, 0);
|
||||
|
||||
QPixmap grabImage(grabRect.size() * q->devicePixelRatioF());
|
||||
grabImage.setDevicePixelRatio(q->devicePixelRatioF());
|
||||
QPixmap grabImage(grabRect.size() * q->devicePixelRatio());
|
||||
grabImage.setDevicePixelRatio(q->devicePixelRatio());
|
||||
grabImage.fill(Qt::transparent);
|
||||
QStylePainter p(&grabImage, q);
|
||||
|
||||
|
@ -255,7 +255,7 @@ void tst_QScreen::grabWindow()
|
||||
void resizeEvent(QResizeEvent *e) override
|
||||
{
|
||||
const QSize sz = e->size();
|
||||
image = image.scaled(sz * image.devicePixelRatioF());
|
||||
image = image.scaled(sz * image.devicePixelRatio());
|
||||
QPainter painter(&image);
|
||||
painter.fillRect(0, 0, sz.width(), sz.height(), Qt::black);
|
||||
painter.setPen(QPen(Qt::red, 2));
|
||||
|
@ -2295,7 +2295,7 @@ void PaintCommands::command_pixmap_setDevicePixelRatio(QRegularExpressionMatch r
|
||||
|
||||
if (m_verboseMode)
|
||||
printf(" -(lance) pixmap_setDevicePixelRatio(%s), %.1f -> %.1f\n",
|
||||
qPrintable(name), m_pixmapMap[name].devicePixelRatioF(), dpr);
|
||||
qPrintable(name), m_pixmapMap[name].devicePixelRatio(), dpr);
|
||||
|
||||
m_pixmapMap[name].setDevicePixelRatio(dpr);
|
||||
}
|
||||
@ -2374,7 +2374,7 @@ void PaintCommands::command_image_setDevicePixelRatio(QRegularExpressionMatch re
|
||||
|
||||
if (m_verboseMode)
|
||||
printf(" -(lance) image_setDevicePixelRatio(%s), %.1f -> %.1f\n",
|
||||
qPrintable(name), m_imageMap[name].devicePixelRatioF(), dpr);
|
||||
qPrintable(name), m_imageMap[name].devicePixelRatio(), dpr);
|
||||
|
||||
m_imageMap[name].setDevicePixelRatio(dpr);
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ void tst_QDialog::toolDialogPosition()
|
||||
dialog.move(QPoint(100,100));
|
||||
const QPoint beforeShowPosition = dialog.pos();
|
||||
dialog.show();
|
||||
const int fuzz = int(dialog.devicePixelRatioF());
|
||||
const int fuzz = int(dialog.devicePixelRatio());
|
||||
const QPoint afterShowPosition = dialog.pos();
|
||||
QVERIFY2(HighDpi::fuzzyCompare(afterShowPosition, beforeShowPosition, fuzz),
|
||||
HighDpi::msgPointMismatch(afterShowPosition, beforeShowPosition).constData());
|
||||
|
@ -400,13 +400,13 @@ void tst_QPixmapFilter::blurIndexed8()
|
||||
QImage original = img;
|
||||
qt_blurImage(img, 10, true, false);
|
||||
QCOMPARE(original.size(), img.size());
|
||||
QVERIFY2(qFuzzyCompare(img.devicePixelRatioF(), qreal(2)),
|
||||
QByteArray::number(img.devicePixelRatioF()).constData());
|
||||
QVERIFY2(qFuzzyCompare(img.devicePixelRatio(), qreal(2)),
|
||||
QByteArray::number(img.devicePixelRatio()).constData());
|
||||
|
||||
original = img;
|
||||
qt_blurImage(img, 10, true, true);
|
||||
QVERIFY2(qFuzzyCompare(img.devicePixelRatioF(), qreal(2)),
|
||||
QByteArray::number(img.devicePixelRatioF()).constData());
|
||||
QVERIFY2(qFuzzyCompare(img.devicePixelRatio(), qreal(2)),
|
||||
QByteArray::number(img.devicePixelRatio()).constData());
|
||||
QCOMPARE(original.size(), QSize(img.height(), img.width()));
|
||||
}
|
||||
|
||||
|
@ -3602,7 +3602,7 @@ protected:
|
||||
static QPixmap grabFromWidget(QWidget *w, const QRect &rect)
|
||||
{
|
||||
QPixmap pixmap = w->grab(rect);
|
||||
const qreal devicePixelRatio = pixmap.devicePixelRatioF();
|
||||
const qreal devicePixelRatio = pixmap.devicePixelRatio();
|
||||
if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
|
||||
pixmap = pixmap.scaled((QSizeF(pixmap.size()) / devicePixelRatio).toSize(),
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
@ -5638,7 +5638,7 @@ bool verifyColor(QWidget &child, const QRegion ®ion, const QColor &color, int
|
||||
const QPixmap pixmap = grabBackingStore
|
||||
? child.grab(rect)
|
||||
: grabWindow(window, rect.left(), rect.top(), rect.width(), rect.height());
|
||||
const QSize actualSize = pixmap.size() / pixmap.devicePixelRatioF();
|
||||
const QSize actualSize = pixmap.size() / pixmap.devicePixelRatio();
|
||||
if (!QTest::qCompare(actualSize, rect.size(), "pixmap.size()", "rect.size()", __FILE__, callerLine))
|
||||
return false;
|
||||
QPixmap expectedPixmap(pixmap); /* ensure equal formats */
|
||||
@ -9270,8 +9270,8 @@ void tst_QWidget::translucentWidget()
|
||||
widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size()));
|
||||
#endif
|
||||
const QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32);
|
||||
QImage expected = pm.toImage().scaled(label.devicePixelRatioF() * pm.size());
|
||||
expected.setDevicePixelRatio(label.devicePixelRatioF());
|
||||
QImage expected = pm.toImage().scaled(label.devicePixelRatio() * pm.size());
|
||||
expected.setDevicePixelRatio(label.devicePixelRatio());
|
||||
QCOMPARE(actual.size(),expected.size());
|
||||
QCOMPARE(actual,expected);
|
||||
|
||||
|
@ -100,7 +100,7 @@ static void dumpWidgetRecursion(QTextStream &str, const QWidget *w,
|
||||
if (w->isWindow()) {
|
||||
str << ' ' << w->logicalDpiX() << "DPI";
|
||||
#if QT_VERSION > 0x050600
|
||||
const qreal dpr = w->devicePixelRatioF();
|
||||
const qreal dpr = w->devicePixelRatio();
|
||||
if (!qFuzzyCompare(dpr, qreal(1)))
|
||||
str << " dpr=" << dpr;
|
||||
#endif // Qt 5.6
|
||||
|
@ -162,8 +162,8 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
|
||||
mimeData->setData("application/x-hotspot",
|
||||
QByteArray::number(hotSpot.x()) + ' ' + QByteArray::number(hotSpot.y()));
|
||||
|
||||
const qreal dpr = devicePixelRatioF() > 1 && !(QGuiApplication::keyboardModifiers() & Qt::ShiftModifier)
|
||||
? devicePixelRatioF() : 1;
|
||||
const qreal dpr = devicePixelRatio() > 1 && !(QGuiApplication::keyboardModifiers() & Qt::ShiftModifier)
|
||||
? devicePixelRatio() : 1;
|
||||
|
||||
QPixmap pixmap(child->size() * dpr);
|
||||
pixmap.setDevicePixelRatio(dpr);
|
||||
|
@ -1293,7 +1293,7 @@ QT_DPI_ADJUSTMENT_POLICY=AdjustDpi|DontAdjustDpi|AdjustUpOnly)";
|
||||
<< "\n\n";
|
||||
}
|
||||
|
||||
str << "widget devicePixelRatio: " << this->devicePixelRatioF()
|
||||
str << "widget devicePixelRatio: " << this->devicePixelRatio()
|
||||
<< "\nwidget logicalDpi: " << this->logicalDpiX()
|
||||
<< "\n\nQT_FONT_DPI: " << qgetenv("QT_FONT_DPI")
|
||||
<< "\nQT_SCALE_FACTOR: " << qgetenv("QT_SCALE_FACTOR")
|
||||
|
@ -286,7 +286,7 @@ void MainWindow::updateDescription()
|
||||
QString text;
|
||||
QTextStream str(&text);
|
||||
str << "Qt " << QT_VERSION_STR << ", platform: " << QGuiApplication::platformName()
|
||||
<< ", Style: \"" << style()->objectName() << "\", DPR=" << devicePixelRatioF()
|
||||
<< ", Style: \"" << style()->objectName() << "\", DPR=" << devicePixelRatio()
|
||||
<< ' ' << logicalDpiX() << ',' << logicalDpiY() << "DPI";
|
||||
if (const QWindow *w = windowHandle())
|
||||
str << ", Screen: \"" << w->screen()->name() << '"';
|
||||
|
Loading…
x
Reference in New Issue
Block a user