From ef3a210b980592d2bde5b541494ce60c7c976c36 Mon Sep 17 00:00:00 2001 From: Felix Kauselmann <2039670+selmf@users.noreply.github.com> Date: Wed, 2 Dec 2015 16:18:08 +0100 Subject: [PATCH] Add zoom controls to main window viewer --- YACReader/main_window_viewer.cpp | 35 +++++++++++++++++++++++- YACReader/main_window_viewer.h | 4 +++ shortcuts_management/shortcuts_manager.h | 2 ++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index f40daa8b..ff4000b8 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -407,6 +407,20 @@ void MainWindowViewer::createActions() adjustToFullSizeAction->setData(ADJUST_TO_FULL_SIZE_ACTION_Y); adjustToFullSizeAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_TO_FULL_SIZE_ACTION_Y)); connect(adjustToFullSizeAction,SIGNAL(triggered()),this,SLOT(adjustToFullSizeSwitch())); + + increasePageZoomAction = new QAction(tr("Zoom+"),this); + increasePageZoomAction->setDisabled(true); + increasePageZoomAction->setData(ZOOM_PLUS_ACTION_Y); + increasePageZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_PLUS_ACTION_Y)); + + connect(increasePageZoomAction,SIGNAL(triggered()),this,SLOT(increasePageZoomLevel())); + + decreasePageZoomAction = new QAction(tr("Zoom-"),this); + decreasePageZoomAction->setDisabled(true); + decreasePageZoomAction->setData(ZOOM_MINUS_ACTION_Y); + decreasePageZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_MINUS_ACTION_Y)); + + connect(decreasePageZoomAction,SIGNAL(triggered()),this,SLOT(decreasePageZoomLevel())); showFlowAction = new QAction(tr("Show go to flow"),this); showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png")); @@ -578,6 +592,8 @@ void MainWindowViewer::createToolBars() YACReader::addSperator(viewer); viewer->addAction(showMagnifyingGlassAction); + viewer->addAction(increasePageZoomAction); + viewer->addAction(decreasePageZoomAction); YACReader::addSperator(viewer); viewer->addAction(setBookmarkAction); @@ -820,6 +836,8 @@ void MainWindowViewer::enableActions() doublePageAction->setDisabled(false); doubleMangaPageAction->setDisabled(false); adjustToFullSizeAction->setDisabled(false); + increasePageZoomAction->setDisabled(false); + decreasePageZoomAction->setDisabled(false); //setBookmark->setDisabled(false); showBookmarksAction->setDisabled(false); showInfoAction->setDisabled(false); //TODO enable goTo and showInfo (or update) when numPages emited @@ -948,11 +966,13 @@ void MainWindowViewer::showToolBars() void MainWindowViewer::fitToWidth() { Configuration::getConfiguration().setFitMode(YACReader::FitMode::ToWidth); + viewer->setZoomFactor(1); viewer->updatePage(); } void MainWindowViewer::fitToHeight() { Configuration::getConfiguration().setFitMode(YACReader::FitMode::ToHeight); + viewer->setZoomFactor(1); viewer->updatePage(); } @@ -1081,7 +1101,9 @@ void MainWindowViewer::setUpShortcutsManagement() << rightRotationAction << doublePageAction << doubleMangaPageAction - << adjustToFullSizeAction); + << adjustToFullSizeAction + << increasePageZoomAction + << decreasePageZoomAction); allActions << tmpList; @@ -1361,9 +1383,20 @@ void MainWindowViewer::alwaysOnTopSwitch() void MainWindowViewer::adjustToFullSizeSwitch() { Configuration::getConfiguration().setFitMode(YACReader::FitMode::FullRes); + viewer->setZoomFactor(1); viewer->updatePage(); } +void MainWindowViewer::increasePageZoomLevel() +{ + viewer->increaseZoomFactor(); +} + +void MainWindowViewer::decreasePageZoomLevel() +{ + viewer->decreaseZoomFactor(); +} + void MainWindowViewer::sendComic() { YACReaderLocalClient * client = new YACReaderLocalClient; diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index bab2ca85..ee7e3d16 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -54,6 +54,8 @@ class EditShortcutsDialog; void openFolderFromPath(QString pathFile, QString atFileName); void alwaysOnTopSwitch(); void adjustToFullSizeSwitch(); + void increasePageZoomLevel(); + void decreasePageZoomLevel(); void reloadOptions(); void fitToWidth(); void fitToHeight(); @@ -124,6 +126,8 @@ class EditShortcutsDialog; QAction *showDictionaryAction; QAction *alwaysOnTopAction; QAction *adjustToFullSizeAction; + QAction *increasePageZoomAction; + QAction *decreasePageZoomAction; QAction *showFlowAction; QAction *showEditShortcutsAction; diff --git a/shortcuts_management/shortcuts_manager.h b/shortcuts_management/shortcuts_manager.h index a67851cc..7b6e3d5e 100644 --- a/shortcuts_management/shortcuts_manager.h +++ b/shortcuts_management/shortcuts_manager.h @@ -118,6 +118,8 @@ public: #define TOGGLE_FULL_SCREEN_ACTION_Y "TOGGLE_FULL_SCREEN_ACTION_Y" #define TOGGLE_TOOL_BARS_ACTION_Y "TOGGLE_TOOL_BARS_ACTION_Y" #define CHANGE_FIT_ACTION_Y "CHANGE_FIT_ACTION_Y" +#define ZOOM_PLUS_ACTION_Y "ZOOM_PLUS_ACTION_Y" +#define ZOOM_MINUS_ACTION_Y "ZOOM_MINUS_ACTION_Y" //viewer #define AUTO_SCROLL_FORWARD_ACTION_Y "AUTO_SCROLL_FORWARD_ACTION_Y" #define AUTO_SCROLL_BACKWARD_ACTION_Y "AUTO_SCROLL_BACKWARD_ACTION_Y"