From bb01aebd69bdd488c4fd64a9d228b018b214db2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 9 Nov 2014 11:55:38 +0100 Subject: [PATCH] added retina support for rendering pages with the right resolution in YACReader --- YACReader/viewer.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 917abeb1..a74578f0 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -342,6 +342,18 @@ void Viewer::updateContentSize() content->resize(static_cast(height()*aspectRatio),height()); } } + + QPixmap page; + if(devicePixelRatio()>1) + { + page = currentPage->scaled(content->width()*devicePixelRatio(), content->height()*devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + page.setDevicePixelRatio(devicePixelRatio()); + } + else + page = currentPage->scaled(content->width(), content->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + + content->setPixmap(page); + emit backgroundChanges(); } content->update(); //TODO, it shouldn't be neccesary @@ -765,7 +777,7 @@ void Viewer::setPageUnavailableMessage() void Viewer::configureContent(QString msg) { content->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - content->setScaledContents(true); + //content->setScaledContents(true); content->setAlignment(Qt::AlignTop|Qt::AlignHCenter); content->setText(msg); content->setFont(QFont("courier new", 12));