From 565bc3a5d0db54d8f481257ba4aa404ca369edf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 14 Jan 2022 19:22:50 +0100 Subject: [PATCH] Replace all uses of devicePixelRatio with devicePixelRatioF --- YACReader/magnifying_glass.cpp | 4 ++-- YACReader/viewer.cpp | 2 +- YACReaderLibrary/server_config_dialog.cpp | 4 ++-- common/gl/yacreader_flow_gl.cpp | 8 ++++---- custom_widgets/yacreader_library_item_widget.cpp | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/YACReader/magnifying_glass.cpp b/YACReader/magnifying_glass.cpp index 9db4b137..594a550e 100644 --- a/YACReader/magnifying_glass.cpp +++ b/YACReader/magnifying_glass.cpp @@ -77,7 +77,7 @@ void MagnifyingGlass::updateImage(int x, int y) } if (outImage) { QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32); - img.setDevicePixelRatio(devicePixelRatio()); + img.setDevicePixelRatio(devicePixelRatioF()); img.fill(Configuration::getConfiguration().getBackgroundColor()); if (zw > 0 && zh > 0) { QPainter painter(&img); @@ -118,7 +118,7 @@ void MagnifyingGlass::updateImage(int x, int y) } if (outImage) { QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32); - img.setDevicePixelRatio(devicePixelRatio()); + img.setDevicePixelRatio(devicePixelRatioF()); img.fill(Configuration::getConfiguration().getBackgroundColor()); if (zw > 0 && zh > 0) { QPainter painter(&img); diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 808d535e..bcf34b00 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -981,7 +981,7 @@ void Viewer::setPageUnavailableMessage() void Viewer::configureContent(QString msg) { content->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - if (!(devicePixelRatio() > 1)) + if (!(devicePixelRatioF() > 1)) content->setScaledContents(true); content->setAlignment(Qt::AlignTop | Qt::AlignHCenter); content->setText(msg); diff --git a/YACReaderLibrary/server_config_dialog.cpp b/YACReaderLibrary/server_config_dialog.cpp index 68ce85ce..ab4b4e68 100644 --- a/YACReaderLibrary/server_config_dialog.cpp +++ b/YACReaderLibrary/server_config_dialog.cpp @@ -267,12 +267,12 @@ void ServerConfigDialog::generateQR(const QString &serverAddress) if (image.isNull()) { qrCode->setText(tr("Could not load libqrencode.")); } else { - image = image.scaled(qrCode->size() * devicePixelRatio()); + image = image.scaled(qrCode->size() * devicePixelRatioF()); QPixmap pMask(image.size()); pMask.fill(QColor(66, 66, 66)); pMask.setMask(image.createMaskFromColor(Qt::white)); - pMask.setDevicePixelRatio(devicePixelRatio()); + pMask.setDevicePixelRatio(devicePixelRatioF()); qrCode->setPixmap(pMask); } diff --git a/common/gl/yacreader_flow_gl.cpp b/common/gl/yacreader_flow_gl.cpp index 9aa54306..a2dd76b4 100644 --- a/common/gl/yacreader_flow_gl.cpp +++ b/common/gl/yacreader_flow_gl.cpp @@ -342,7 +342,7 @@ void YACReaderFlowGL::paintGL() void YACReaderFlowGL::resizeGL(int width, int height) { - float pixelRatio = devicePixelRatio(); + float pixelRatio = devicePixelRatioF(); fontSize = (width + height) * 0.010 * pixelRatio; if (fontSize < 10) fontSize = 10; @@ -356,7 +356,7 @@ void YACReaderFlowGL::resizeGL(int width, int height) void YACReaderFlowGL::udpatePerspective(int width, int height) { - float pixelRatio = devicePixelRatio(); + float pixelRatio = devicePixelRatioF(); glViewport(0, 0, width * pixelRatio, height * pixelRatio); glMatrixMode(GL_PROJECTION); @@ -1101,8 +1101,8 @@ QVector3D YACReaderFlowGL::getPlaneIntersection(int x, int y, YACReader3DImage p doneCurrent(); // create the picking ray - QVector3D ray_origin(x * devicePixelRatio(), y * devicePixelRatio(), 0); - QVector3D ray_end(x * devicePixelRatio(), y * devicePixelRatio(), 1.0); + QVector3D ray_origin(x * devicePixelRatioF(), y * devicePixelRatioF(), 0); + QVector3D ray_end(x * devicePixelRatioF(), y * devicePixelRatioF(), 1.0); // TODO: These should be cached in the class diff --git a/custom_widgets/yacreader_library_item_widget.cpp b/custom_widgets/yacreader_library_item_widget.cpp index 9b17a633..5fd08dcf 100644 --- a/custom_widgets/yacreader_library_item_widget.cpp +++ b/custom_widgets/yacreader_library_item_widget.cpp @@ -25,12 +25,12 @@ YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n /*ame*/, QStrin // TODO fix this crazy hack for having a propper retina icon for the options // this hack has been perpetrated using Qt 5.5.0 QString sourceOptionsImage; - if (devicePixelRatio() > 1) + if (devicePixelRatioF() > 1) sourceOptionsImage = ":/images/sidebar/libraryOptions@2x.png"; else sourceOptionsImage = ":/images/sidebar/libraryOptions.png"; QPixmap iconOptionsPixmap(sourceOptionsImage); - iconOptionsPixmap.setDevicePixelRatio(devicePixelRatio()); + iconOptionsPixmap.setDevicePixelRatio(devicePixelRatioF()); QLabel *helperLabel = new QLabel(options); helperLabel->move(4, 2); helperLabel->setFixedSize(14, 14);