diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index d930c8cd..eef11f61 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -372,6 +372,45 @@ void Viewer::updateContentSize() content->update(); //TODO, it shouldn't be neccesary } +void Viewer::increaseZoomFactor() +{ + zoom += 0.1; + if (zoom > 5) + { + zoom = 5; + } + updateContentSize(); + notificationsLabel->setText(QString::number(getZoomFactor()*100)+"%"); + notificationsLabel->flash(); +} +void Viewer::decreaseZoomFactor() +{ + zoom -= 0.1; + if (zoom < 0.1) + zoom = 0.1; + updateContentSize(); + notificationsLabel->setText(QString::number(getZoomFactor()*100)+"%"); + notificationsLabel->flash(); +} + +qreal Viewer::getZoomFactor() +{ + //this function is a placeholder for future refactoring work + return zoom; +} + +void Viewer::setZoomFactor(qreal z) +{ + //this function is mostly used to reset the zoom after a fitmode switch + if (z > 5) + zoom = 5; + else if (z < 0.1) + zoom = 0.1; + else + zoom = z; +// updateContentSize() +} + void Viewer::updateVerticalScrollBar() { if(direction > 0) diff --git a/YACReader/viewer.h b/YACReader/viewer.h index 44270da0..856985c7 100644 --- a/YACReader/viewer.h +++ b/YACReader/viewer.h @@ -37,6 +37,11 @@ class NotificationsLabelWidget; public: bool fullscreen; //TODO, change by the right use of windowState(); public slots: + void increaseZoomFactor(); + void decreaseZoomFactor(); + void setZoomFactor(qreal); + qreal getZoomFactor(); + void prepareForOpening(); void open(QString pathFile, int atPage = -1); void open(QString pathFile, const ComicDB & comic);