Replace all uses of devicePixelRatio with devicePixelRatioF

This commit is contained in:
Luis Ángel San Martín 2022-01-14 19:22:50 +01:00
parent 380aea2a66
commit 565bc3a5d0
5 changed files with 11 additions and 11 deletions

View File

@ -77,7 +77,7 @@ void MagnifyingGlass::updateImage(int x, int y)
} }
if (outImage) { if (outImage) {
QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32); QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32);
img.setDevicePixelRatio(devicePixelRatio()); img.setDevicePixelRatio(devicePixelRatioF());
img.fill(Configuration::getConfiguration().getBackgroundColor()); img.fill(Configuration::getConfiguration().getBackgroundColor());
if (zw > 0 && zh > 0) { if (zw > 0 && zh > 0) {
QPainter painter(&img); QPainter painter(&img);
@ -118,7 +118,7 @@ void MagnifyingGlass::updateImage(int x, int y)
} }
if (outImage) { if (outImage) {
QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32); QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32);
img.setDevicePixelRatio(devicePixelRatio()); img.setDevicePixelRatio(devicePixelRatioF());
img.fill(Configuration::getConfiguration().getBackgroundColor()); img.fill(Configuration::getConfiguration().getBackgroundColor());
if (zw > 0 && zh > 0) { if (zw > 0 && zh > 0) {
QPainter painter(&img); QPainter painter(&img);

View File

@ -981,7 +981,7 @@ void Viewer::setPageUnavailableMessage()
void Viewer::configureContent(QString msg) void Viewer::configureContent(QString msg)
{ {
content->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); content->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
if (!(devicePixelRatio() > 1)) if (!(devicePixelRatioF() > 1))
content->setScaledContents(true); content->setScaledContents(true);
content->setAlignment(Qt::AlignTop | Qt::AlignHCenter); content->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
content->setText(msg); content->setText(msg);

View File

@ -267,12 +267,12 @@ void ServerConfigDialog::generateQR(const QString &serverAddress)
if (image.isNull()) { if (image.isNull()) {
qrCode->setText(tr("Could not load libqrencode.")); qrCode->setText(tr("Could not load libqrencode."));
} else { } else {
image = image.scaled(qrCode->size() * devicePixelRatio()); image = image.scaled(qrCode->size() * devicePixelRatioF());
QPixmap pMask(image.size()); QPixmap pMask(image.size());
pMask.fill(QColor(66, 66, 66)); pMask.fill(QColor(66, 66, 66));
pMask.setMask(image.createMaskFromColor(Qt::white)); pMask.setMask(image.createMaskFromColor(Qt::white));
pMask.setDevicePixelRatio(devicePixelRatio()); pMask.setDevicePixelRatio(devicePixelRatioF());
qrCode->setPixmap(pMask); qrCode->setPixmap(pMask);
} }

View File

@ -342,7 +342,7 @@ void YACReaderFlowGL::paintGL()
void YACReaderFlowGL::resizeGL(int width, int height) void YACReaderFlowGL::resizeGL(int width, int height)
{ {
float pixelRatio = devicePixelRatio(); float pixelRatio = devicePixelRatioF();
fontSize = (width + height) * 0.010 * pixelRatio; fontSize = (width + height) * 0.010 * pixelRatio;
if (fontSize < 10) if (fontSize < 10)
fontSize = 10; fontSize = 10;
@ -356,7 +356,7 @@ void YACReaderFlowGL::resizeGL(int width, int height)
void YACReaderFlowGL::udpatePerspective(int width, int height) void YACReaderFlowGL::udpatePerspective(int width, int height)
{ {
float pixelRatio = devicePixelRatio(); float pixelRatio = devicePixelRatioF();
glViewport(0, 0, width * pixelRatio, height * pixelRatio); glViewport(0, 0, width * pixelRatio, height * pixelRatio);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
@ -1101,8 +1101,8 @@ QVector3D YACReaderFlowGL::getPlaneIntersection(int x, int y, YACReader3DImage p
doneCurrent(); doneCurrent();
// create the picking ray // create the picking ray
QVector3D ray_origin(x * devicePixelRatio(), y * devicePixelRatio(), 0); QVector3D ray_origin(x * devicePixelRatioF(), y * devicePixelRatioF(), 0);
QVector3D ray_end(x * devicePixelRatio(), y * devicePixelRatio(), 1.0); QVector3D ray_end(x * devicePixelRatioF(), y * devicePixelRatioF(), 1.0);
// TODO: These should be cached in the class // TODO: These should be cached in the class

View File

@ -25,12 +25,12 @@ YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n /*ame*/, QStrin
// TODO fix this crazy hack for having a propper retina icon for the options // TODO fix this crazy hack for having a propper retina icon for the options
// this hack has been perpetrated using Qt 5.5.0 // this hack has been perpetrated using Qt 5.5.0
QString sourceOptionsImage; QString sourceOptionsImage;
if (devicePixelRatio() > 1) if (devicePixelRatioF() > 1)
sourceOptionsImage = ":/images/sidebar/libraryOptions@2x.png"; sourceOptionsImage = ":/images/sidebar/libraryOptions@2x.png";
else else
sourceOptionsImage = ":/images/sidebar/libraryOptions.png"; sourceOptionsImage = ":/images/sidebar/libraryOptions.png";
QPixmap iconOptionsPixmap(sourceOptionsImage); QPixmap iconOptionsPixmap(sourceOptionsImage);
iconOptionsPixmap.setDevicePixelRatio(devicePixelRatio()); iconOptionsPixmap.setDevicePixelRatio(devicePixelRatioF());
QLabel *helperLabel = new QLabel(options); QLabel *helperLabel = new QLabel(options);
helperLabel->move(4, 2); helperLabel->move(4, 2);
helperLabel->setFixedSize(14, 14); helperLabel->setFixedSize(14, 14);