diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 39d5e07d..c5959923 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -420,6 +420,22 @@ void MainWindowViewer::createActions() fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y); fitToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FIT_TO_PAGE_ACTION_Y)); connect(fitToPageAction,SIGNAL(triggered()),this,SLOT(fitToPageSwitch())); + + increasePageZoomAction = new QAction(tr("Zoom+"),this); + //fitToPageAction->setIcon(QIcon(":/images/viewer_toolbar/full.png")); + //fitToPageAction->setDisabled(true); + //fitToPageAction->setChecked(Configuration::getConfiguration().getFitToPage()); + //fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y); + increasePageZoomAction->setShortcut(QKeySequence::ZoomIn); + connect(increasePageZoomAction,SIGNAL(triggered()),this,SLOT(increasePageZoomLevel())); + + decreasePageZoomAction = new QAction(tr("Zoom-"),this); + //fitToPageAction->setIcon(QIcon(":/images/viewer_toolbar/full.png")); + //fitToPageAction->setDisabled(true); + //fitToPageAction->setChecked(Configuration::getConfiguration().getFitToPage()); + //fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y); + decreasePageZoomAction->setShortcut(QKeySequence::ZoomOut); + connect(decreasePageZoomAction,SIGNAL(triggered()),this,SLOT(decreasePageZoomLevel())); showFlowAction = new QAction(tr("Show go to flow"),this); showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png")); @@ -543,7 +559,8 @@ void MainWindowViewer::createToolBars() comicToolBar->addSeparator(); comicToolBar->addAction(showMagnifyingGlassAction); - + comicToolBar->addAction(increasePageZoomAction); + comicToolBar->addAction(decreasePageZoomAction); comicToolBar->addSeparator(); @@ -1396,6 +1413,19 @@ void MainWindowViewer::fitToPageSwitch() viewer->updatePage(); } +void MainWindowViewer::increasePageZoomLevel() +{ + qDebug() << "Increase page zoom level!"; + Configuration::getConfiguration().setPageZoomLevel(Configuration::getConfiguration().getPageZoomLevel() + 0.1); + viewer->updatePage(); +} + +void MainWindowViewer::decreasePageZoomLevel() +{ + Configuration::getConfiguration().setPageZoomLevel(Configuration::getConfiguration().getPageZoomLevel() - 0.1); + viewer->updatePage(); +} + void MainWindowViewer::sendComic() { YACReaderLocalClient * client = new YACReaderLocalClient; diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index 6277265d..3c991a24 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -54,6 +54,8 @@ class EditShortcutsDialog; void alwaysOnTopSwitch(); void adjustToFullSizeSwitch(); void fitToPageSwitch(); + void increasePageZoomLevel(); + void decreasePageZoomLevel(); void reloadOptions(); void fitToWidth(); void fitToHeight(); @@ -120,6 +122,8 @@ class EditShortcutsDialog; QAction *alwaysOnTopAction; QAction *adjustToFullSizeAction; QAction *fitToPageAction; + QAction *increasePageZoomAction; + QAction *decreasePageZoomAction; QAction *showFlowAction; QAction *showEditShortcutsAction; diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 97ff6d96..1594b9ea 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -326,9 +326,16 @@ void Viewer::updateContentSize() } else { - float aspectRatio = (float)currentPage->width()/currentPage->height(); + //float aspectRatio = (float)currentPage->width()/currentPage->height(); //Fit to width if(Configuration::getConfiguration().getAdjustToWidth()) + { + QSize pagefit=currentPage->size(); + pagefit.scale(width(), 0, Qt::KeepAspectRatioByExpanding); + content->resize(pagefit); + } + /* + if(Configuration::getConfiguration().getAdjustToWidth()) { adjustToWidthRatio = Configuration::getConfiguration().getFitToWidthRatio(); if(static_cast(width()*adjustToWidthRatio/aspectRatio)resize(width()*adjustToWidthRatio,static_cast(width()*adjustToWidthRatio/aspectRatio)); } + //Fit to height or fullsize/custom size else { @@ -346,18 +354,26 @@ void Viewer::updateContentSize() content->resize(width(),static_cast(width()/aspectRatio)); else content->resize(static_cast(height()*aspectRatio),height()); + }*/ + else + { + QSize pagefit=currentPage->size(); + pagefit.scale(0, height(), Qt::KeepAspectRatioByExpanding); + content->resize(pagefit); } + } if(Configuration::getConfiguration().getPageZoomLevel()) { QSize pagesize=content->size(); - pagesize.scale(content->width()*Configuration::getConfiguration().getPageZoomLevel(), content->height(), Qt::KeepAspectRatio); + pagesize.scale(content->width()*Configuration::getConfiguration().getPageZoomLevel(), 0, Qt::KeepAspectRatioByExpanding); content->resize(pagesize); } if(devicePixelRatio()>1)//only in retina display { + qDebug() << "Retina Display detected" << "devicePixelRatio:" << devicePixelRatio(); QPixmap page = currentPage->scaled(content->width()*devicePixelRatio(), content->height()*devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation); page.setDevicePixelRatio(devicePixelRatio()); content->setPixmap(page);