From b3c991ae8f9da6d8eb26f10b3d4ab08587588c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 1 Sep 2020 13:45:24 +0200 Subject: Port from devicePixelRatioF() to devicePixelRatio() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ports all of QtBase. Change-Id: If6712da44d7749b97b74f4614a04fac360f69d9e Reviewed-by: Tor Arne Vestbø --- examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp | 12 ++++++------ examples/widgets/mainwindows/mainwindow/toolbar.cpp | 2 +- examples/widgets/widgets/charactermap/mainwindow.cpp | 4 ++-- examples/widgets/widgets/icons/iconpreviewarea.cpp | 2 +- examples/widgets/widgets/icons/mainwindow.cpp | 2 +- examples/widgets/widgets/tablet/tabletcanvas.cpp | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) (limited to 'examples') diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp index 9eda882347..b0c3733b22 100644 --- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp +++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp @@ -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] diff --git a/examples/widgets/mainwindows/mainwindow/toolbar.cpp b/examples/widgets/mainwindows/mainwindow/toolbar.cpp index fd510c8a57..2c663a1618 100644 --- a/examples/widgets/mainwindows/mainwindow/toolbar.cpp +++ b/examples/widgets/mainwindows/mainwindow/toolbar.cpp @@ -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"); diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp index 1bab0d6082..18dc672c37 100644 --- a/examples/widgets/widgets/charactermap/mainwindow.cpp +++ b/examples/widgets/widgets/charactermap/mainwindow.cpp @@ -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" diff --git a/examples/widgets/widgets/icons/iconpreviewarea.cpp b/examples/widgets/widgets/icons/iconpreviewarea.cpp index 8a1ef8a3c4..d0ee50fbb1 100644 --- a/examples/widgets/widgets/icons/iconpreviewarea.cpp +++ b/examples/widgets/widgets/icons/iconpreviewarea.cpp @@ -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); } diff --git a/examples/widgets/widgets/icons/mainwindow.cpp b/examples/widgets/widgets/icons/mainwindow.cpp index bd14bff518..7280ba9a42 100644 --- a/examples/widgets/widgets/icons/mainwindow.cpp +++ b/examples/widgets/widgets/icons/mainwindow.cpp @@ -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 = diff --git a/examples/widgets/widgets/tablet/tabletcanvas.cpp b/examples/widgets/widgets/tablet/tabletcanvas.cpp index 9215d5b10c..e397d70cd6 100644 --- a/examples/widgets/widgets/tablet/tabletcanvas.cpp +++ b/examples/widgets/widgets/tablet/tabletcanvas.cpp @@ -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] -- cgit v1.2.3