Added reset zoom action and fitting mode actions are now checkable and exclusive

This commit is contained in:
Luis Ángel San Martín 2015-12-09 21:41:28 +01:00
parent 0c192d2f24
commit 1af953b295
3 changed files with 88 additions and 39 deletions

View File

@ -97,6 +97,7 @@ MainWindowViewer::~MainWindowViewer()
delete doubleMangaPageAction; delete doubleMangaPageAction;
delete increasePageZoomAction; delete increasePageZoomAction;
delete decreasePageZoomAction; delete decreasePageZoomAction;
delete resetZoomAction;
delete goToPageAction; delete goToPageAction;
delete optionsAction; delete optionsAction;
delete helpAboutAction; delete helpAboutAction;
@ -267,6 +268,7 @@ void MainWindowViewer::createActions()
//adjustWidth->setIcon(QIcon(":/images/fitWidth.png")); //adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
adjustHeightAction->setData(ADJUST_HEIGHT_ACTION_Y); adjustHeightAction->setData(ADJUST_HEIGHT_ACTION_Y);
adjustHeightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_HEIGHT_ACTION_Y)); adjustHeightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_HEIGHT_ACTION_Y));
adjustHeightAction->setCheckable(true);
connect(adjustHeightAction, SIGNAL(triggered()),this,SLOT(fitToHeight())); connect(adjustHeightAction, SIGNAL(triggered()),this,SLOT(fitToHeight()));
adjustWidthAction = new QAction(tr("Fit Width"),this); adjustWidthAction = new QAction(tr("Fit Width"),this);
@ -277,8 +279,73 @@ void MainWindowViewer::createActions()
//adjustWidth->setIcon(QIcon(":/images/fitWidth.png")); //adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
adjustWidthAction->setData(ADJUST_WIDTH_ACTION_Y); adjustWidthAction->setData(ADJUST_WIDTH_ACTION_Y);
adjustWidthAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_WIDTH_ACTION_Y)); adjustWidthAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_WIDTH_ACTION_Y));
adjustWidthAction->setCheckable(true);
connect(adjustWidthAction, SIGNAL(triggered()),this,SLOT(fitToWidth())); connect(adjustWidthAction, SIGNAL(triggered()),this,SLOT(fitToWidth()));
adjustToFullSizeAction = new QAction(tr("Show full size"),this);
adjustToFullSizeAction->setIcon(QIcon(":/images/viewer_toolbar/full.png"));
adjustToFullSizeAction->setCheckable(false);
adjustToFullSizeAction->setDisabled(true);
adjustToFullSizeAction->setData(ADJUST_TO_FULL_SIZE_ACTION_Y);
adjustToFullSizeAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_TO_FULL_SIZE_ACTION_Y));
adjustToFullSizeAction->setCheckable(true);
connect(adjustToFullSizeAction,SIGNAL(triggered()),this,SLOT(adjustToFullSizeSwitch()));
fitToPageAction = new QAction(tr("Fit to page"),this);
fitToPageAction->setIcon(QIcon(":/images/viewer_toolbar/fitToPage.png"));
fitToPageAction->setDisabled(true);
fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y);
fitToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FIT_TO_PAGE_ACTION_Y));
fitToPageAction->setCheckable(true);
connect(fitToPageAction,SIGNAL(triggered()),this,SLOT(fitToPageSwitch()));
//fit modes have to be exclusive and checkable
QActionGroup *fitModes = new QActionGroup(this);
fitModes->addAction(adjustHeightAction);
fitModes->addAction(adjustWidthAction);
fitModes->addAction(adjustToFullSizeAction);
fitModes->addAction(fitToPageAction);
switch(Configuration::getConfiguration().getFitMode())
{
case YACReader::FitMode::ToWidth:
adjustWidthAction->setChecked(true);
break;
case YACReader::FitMode::ToHeight:
adjustHeightAction->setChecked(true);
break;
case YACReader::FitMode::FullRes:
adjustToFullSizeAction->setChecked(true);
break;
case YACReader::FitMode::FullPage:
fitToPageAction->setChecked(true);
break;
default:
fitToPageAction->setChecked(true);
}
resetZoomAction = new QAction(tr("Reset zoom"), this);
resetZoomAction->setDisabled(true);
resetZoomAction->setData(RESET_ZOOM_ACTION_Y);
resetZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RESET_ZOOM_ACTION_Y));
connect(resetZoomAction,SIGNAL(triggered()),this,SLOT(resetZoomLevel()));
showZoomSliderlAction = new QAction(tr("Show zoom slider"), this);
showZoomSliderlAction->setIcon(QIcon(":/images/viewer_toolbar/zoom.png"));
showZoomSliderlAction->setDisabled(true);
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()));
leftRotationAction = new QAction(tr("Rotate image to the left"),this); leftRotationAction = new QAction(tr("Rotate image to the left"),this);
leftRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateL.png")); leftRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateL.png"));
leftRotationAction->setDisabled(true); leftRotationAction->setDisabled(true);
@ -295,7 +362,7 @@ void MainWindowViewer::createActions()
doublePageAction = new QAction(tr("Double page mode"),this); doublePageAction = new QAction(tr("Double page mode"),this);
doublePageAction->setToolTip(tr("Switch to double page mode")); doublePageAction->setToolTip(tr("Switch to double page mode"));
doublePageAction->setIcon(QIcon(":/images/viewer_toolbar/doublePage.png")); doublePageAction->setIcon(QIcon(":/images/viewer_toolbar/doublePage.png"));
doublePageAction->setDisabled(true); doublePageAction->setDisabled(true);
doublePageAction->setCheckable(true); doublePageAction->setCheckable(true);
doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage()); doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage());
@ -310,8 +377,8 @@ void MainWindowViewer::createActions()
doubleMangaPageAction->setDisabled(true); doubleMangaPageAction->setDisabled(true);
doubleMangaPageAction->setCheckable(true); doubleMangaPageAction->setCheckable(true);
doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage()); doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage());
doubleMangaPageAction->setData(DOUBLE_MANGA_PAGE_ACTION_Y); doubleMangaPageAction->setData(DOUBLE_MANGA_PAGE_ACTION_Y);
doubleMangaPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DOUBLE_MANGA_PAGE_ACTION_Y)); doubleMangaPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DOUBLE_MANGA_PAGE_ACTION_Y));
connect(doubleMangaPageAction, SIGNAL(triggered()),viewer,SLOT(doubleMangaPageSwitch())); connect(doubleMangaPageAction, SIGNAL(triggered()),viewer,SLOT(doubleMangaPageSwitch()));
goToPageAction = new QAction(tr("Go To"),this); goToPageAction = new QAction(tr("Go To"),this);
@ -403,39 +470,6 @@ void MainWindowViewer::createActions()
alwaysOnTopAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ALWAYS_ON_TOP_ACTION_Y)); alwaysOnTopAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ALWAYS_ON_TOP_ACTION_Y));
connect(alwaysOnTopAction,SIGNAL(triggered()),this,SLOT(alwaysOnTopSwitch())); connect(alwaysOnTopAction,SIGNAL(triggered()),this,SLOT(alwaysOnTopSwitch()));
adjustToFullSizeAction = new QAction(tr("Show full size"),this);
adjustToFullSizeAction->setIcon(QIcon(":/images/viewer_toolbar/full.png"));
adjustToFullSizeAction->setCheckable(false);
adjustToFullSizeAction->setDisabled(true);
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()));
fitToPageAction = new QAction(tr("Fit to page"),this);
fitToPageAction->setIcon(QIcon(":/images/viewer_toolbar/fitToPage.png"));
fitToPageAction->setDisabled(true);
fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y);
fitToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FIT_TO_PAGE_ACTION_Y));
connect(fitToPageAction,SIGNAL(triggered()),this,SLOT(fitToPageSwitch()));
showZoomSliderlAction = new QAction(tr("Show zoom slider"), this);
showZoomSliderlAction->setIcon(QIcon(":/images/viewer_toolbar/zoom.png"));
showZoomSliderlAction->setDisabled(true);
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 = new QAction(tr("Show go to flow"),this);
showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png")); showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png"));
showFlowAction->setDisabled(true); showFlowAction->setDisabled(true);
@ -601,6 +635,7 @@ void MainWindowViewer::createToolBars()
viewer->addAction(showMagnifyingGlassAction); viewer->addAction(showMagnifyingGlassAction);
viewer->addAction(increasePageZoomAction); viewer->addAction(increasePageZoomAction);
viewer->addAction(decreasePageZoomAction); viewer->addAction(decreasePageZoomAction);
viewer->addAction(resetZoomAction);
YACReader::addSperator(viewer); YACReader::addSperator(viewer);
viewer->addAction(setBookmarkAction); viewer->addAction(setBookmarkAction);
@ -848,6 +883,7 @@ void MainWindowViewer::enableActions()
showZoomSliderlAction->setDisabled(false); showZoomSliderlAction->setDisabled(false);
increasePageZoomAction->setDisabled(false); increasePageZoomAction->setDisabled(false);
decreasePageZoomAction->setDisabled(false); decreasePageZoomAction->setDisabled(false);
resetZoomAction->setDisabled(false);
//setBookmark->setDisabled(false); //setBookmark->setDisabled(false);
showBookmarksAction->setDisabled(false); showBookmarksAction->setDisabled(false);
showInfoAction->setDisabled(false); //TODO enable goTo and showInfo (or update) when numPages emited showInfoAction->setDisabled(false); //TODO enable goTo and showInfo (or update) when numPages emited
@ -871,6 +907,9 @@ void MainWindowViewer::disableActions()
adjustToFullSizeAction->setDisabled(true); adjustToFullSizeAction->setDisabled(true);
fitToPageAction->setDisabled(true); fitToPageAction->setDisabled(true);
showZoomSliderlAction->setDisabled(true); showZoomSliderlAction->setDisabled(true);
increasePageZoomAction->setDisabled(true);
decreasePageZoomAction->setDisabled(true);
resetZoomAction->setDisabled(true);
setBookmarkAction->setDisabled(true); setBookmarkAction->setDisabled(true);
showBookmarksAction->setDisabled(true); showBookmarksAction->setDisabled(true);
showInfoAction->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited showInfoAction->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited
@ -1112,10 +1151,11 @@ void MainWindowViewer::setUpShortcutsManagement()
<< leftRotationAction << leftRotationAction
<< rightRotationAction << rightRotationAction
<< doublePageAction << doublePageAction
<< doubleMangaPageAction << doubleMangaPageAction
<< adjustToFullSizeAction << adjustToFullSizeAction
<< increasePageZoomAction << increasePageZoomAction
<< decreasePageZoomAction); << decreasePageZoomAction
<< resetZoomAction);
allActions << tmpList; allActions << tmpList;
@ -1411,6 +1451,12 @@ void MainWindowViewer::fitToPageSwitch()
viewer->updatePage(); viewer->updatePage();
} }
void MainWindowViewer::resetZoomLevel()
{
viewer->setZoomFactor(1);
viewer->updatePage();
}
void MainWindowViewer::increasePageZoomLevel() void MainWindowViewer::increasePageZoomLevel()
{ {
viewer->increaseZoomFactor(); viewer->increaseZoomFactor();

View File

@ -55,6 +55,7 @@ class EditShortcutsDialog;
void alwaysOnTopSwitch(); void alwaysOnTopSwitch();
void adjustToFullSizeSwitch(); void adjustToFullSizeSwitch();
void fitToPageSwitch(); void fitToPageSwitch();
void resetZoomLevel();
void increasePageZoomLevel(); void increasePageZoomLevel();
void decreasePageZoomLevel(); void decreasePageZoomLevel();
void reloadOptions(); void reloadOptions();
@ -127,6 +128,7 @@ class EditShortcutsDialog;
QAction *alwaysOnTopAction; QAction *alwaysOnTopAction;
QAction *adjustToFullSizeAction; QAction *adjustToFullSizeAction;
QAction *fitToPageAction; QAction *fitToPageAction;
QAction *resetZoomAction;
QAction *showZoomSliderlAction; QAction *showZoomSliderlAction;
QAction *increasePageZoomAction; QAction *increasePageZoomAction;
QAction *decreasePageZoomAction; QAction *decreasePageZoomAction;

View File

@ -121,6 +121,7 @@ public:
#define CHANGE_FIT_ACTION_Y "CHANGE_FIT_ACTION_Y" #define CHANGE_FIT_ACTION_Y "CHANGE_FIT_ACTION_Y"
#define ZOOM_PLUS_ACTION_Y "ZOOM_PLUS_ACTION_Y" #define ZOOM_PLUS_ACTION_Y "ZOOM_PLUS_ACTION_Y"
#define ZOOM_MINUS_ACTION_Y "ZOOM_MINUS_ACTION_Y" #define ZOOM_MINUS_ACTION_Y "ZOOM_MINUS_ACTION_Y"
#define RESET_ZOOM_ACTION_Y "RESET_ZOOM_ACTION_Y"
//viewer //viewer
#define AUTO_SCROLL_FORWARD_ACTION_Y "AUTO_SCROLL_FORWARD_ACTION_Y" #define AUTO_SCROLL_FORWARD_ACTION_Y "AUTO_SCROLL_FORWARD_ACTION_Y"
#define AUTO_SCROLL_BACKWARD_ACTION_Y "AUTO_SCROLL_BACKWARD_ACTION_Y" #define AUTO_SCROLL_BACKWARD_ACTION_Y "AUTO_SCROLL_BACKWARD_ACTION_Y"