From 5bf074758f357625e757565026497d71259119de Mon Sep 17 00:00:00 2001 From: Felix Kauselmann <2039670+selmf@users.noreply.github.com> Date: Sun, 30 Nov 2014 17:37:07 +0100 Subject: [PATCH] Add zoom and fit to page modes to scaling --- YACReader/configuration.h | 4 ++++ YACReader/viewer.cpp | 15 ++++++++++++++- common/yacreader_global.h | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/YACReader/configuration.h b/YACReader/configuration.h index ba9e1531..edd42b29 100644 --- a/YACReader/configuration.h +++ b/YACReader/configuration.h @@ -60,8 +60,12 @@ using namespace YACReader; void setGotoSlideSize(const QSize & gss) { settings->setValue(GO_TO_FLOW_SIZE,gss);} float getZoomLevel() { return settings->value(ZOOM_LEVEL).toFloat();} void setZoomLevel(float zl) { settings->setValue(ZOOM_LEVEL,zl);} + float getPageZoomLevel() { return settings->value(PAGE_ZOOM_LEVEL).toFloat();} + void setPageZoomLevel(float zl) { settings->setValue(PAGE_ZOOM_LEVEL,zl);} bool getAdjustToWidth() {return settings->value(FIT).toBool();} void setAdjustToWidth(bool atw=true) {settings->setValue(FIT,atw);} + bool getFitToPage() {return settings->value(PAGEFIT).toBool();} + void setFitToPage(bool b=true) {settings->setValue(PAGEFIT,b);} FlowType getFlowType(){return (FlowType)settings->value(FLOW_TYPE_SW).toInt();} void setFlowType(FlowType type){settings->setValue(FLOW_TYPE_SW,type);} bool getFullScreen(){return settings->value(FULLSCREEN).toBool();} diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 40e8dbba..97ff6d96 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -316,7 +316,13 @@ void Viewer::updateContentSize() { if(Configuration::getConfiguration().getAdjustToFullSize()) { - content->resize(currentPage->width(),currentPage->height()); + content->resize(currentPage->size()); + } + else if(Configuration::getConfiguration().getFitToPage()) + { + QSize pagefit=currentPage->size(); + pagefit.scale(size(), Qt::KeepAspectRatio); + content->resize(pagefit); } else { @@ -343,6 +349,13 @@ void Viewer::updateContentSize() } } + if(Configuration::getConfiguration().getPageZoomLevel()) + { + QSize pagesize=content->size(); + pagesize.scale(content->width()*Configuration::getConfiguration().getPageZoomLevel(), content->height(), Qt::KeepAspectRatio); + content->resize(pagesize); + } + if(devicePixelRatio()>1)//only in retina display { QPixmap page = currentPage->scaled(content->width()*devicePixelRatio(), content->height()*devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation); diff --git a/common/yacreader_global.h b/common/yacreader_global.h index c9a8826f..faa516f3 100644 --- a/common/yacreader_global.h +++ b/common/yacreader_global.h @@ -14,10 +14,12 @@ #define PATH "PATH" #define MAG_GLASS_SIZE "MAG_GLASS_SIZE" #define ZOOM_LEVEL "ZOOM_LEVEL" +#define PAGE_ZOOM_LEVEL "PAGE_ZOOM_LEVEL" #define SLIDE_SIZE "SLIDE_SIZE" #define GO_TO_FLOW_SIZE "GO_TO_FLOW_SIZE" #define FLOW_TYPE_SW "FLOW_TYPE_SW" #define FIT "FIT" +#define PAGEFIT "PAGEFIT" #define FLOW_TYPE "FLOW_TYPE" #define FULLSCREEN "FULLSCREEN" #define FIT_TO_WIDTH_RATIO "FIT_TO_WIDTH_RATIO"