From acc912a7655e3e272899830f6c0445262530b0a6 Mon Sep 17 00:00:00 2001 From: Felix Kauselmann <2039670+selmf@users.noreply.github.com> Date: Wed, 2 Dec 2015 15:38:58 +0100 Subject: [PATCH] Add bare metal zoom handling to viewer --- YACReader/viewer.cpp | 26 ++++++++++++++++---------- YACReader/viewer.h | 3 +++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index baecaf98..d930c8cd 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -38,7 +38,8 @@ restoreMagnifyingGlass(false), drag(false), numScrollSteps(22), shouldOpenNext(false), -shouldOpenPrevious(false) +shouldOpenPrevious(false), +zoom(1) { translator = new YACReaderTranslator(this); translator->hide(); @@ -350,16 +351,21 @@ void Viewer::updateContentSize() pagefit.scale(size(), Qt::KeepAspectRatio); break; } - //apply scaling - content->resize(pagefit); - //TODO: updtateContentSize should only scale the pixmap once - if(devicePixelRatio()>1)//only in retina display - { - QPixmap page = currentPage->scaled(content->width()*devicePixelRatio(), content->height()*devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation); - page.setDevicePixelRatio(devicePixelRatio()); - content->setPixmap(page); - } + if(zoom != 1) + { + pagefit.scale(pagefit.width()*zoom, 0, Qt::KeepAspectRatioByExpanding); + } + //apply scaling + content->resize(pagefit); + + //TODO: updtateContentSize should only scale the pixmap once + if(devicePixelRatio()>1)//only in retina display + { + QPixmap page = currentPage->scaled(content->width()*devicePixelRatio(), content->height()*devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + page.setDevicePixelRatio(devicePixelRatio()); + content->setPixmap(page); + } emit backgroundChanges(); } diff --git a/YACReader/viewer.h b/YACReader/viewer.h index f7b1e9f0..44270da0 100644 --- a/YACReader/viewer.h +++ b/YACReader/viewer.h @@ -96,6 +96,9 @@ virtual void mouseReleaseEvent ( QMouseEvent * event ); bool information; bool doublePage; bool doubleMangaPage; + + qreal zoom; + PageLabelWidget * informationLabel; //QTimer * scroller; QPropertyAnimation * verticalScroller;