mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Scaling code refractoring, add fit to page mode and zoom levels
This commit is contained in:
parent
496a90daef
commit
bf98cf3343
@ -420,6 +420,22 @@ void MainWindowViewer::createActions()
|
|||||||
fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y);
|
fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y);
|
||||||
fitToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FIT_TO_PAGE_ACTION_Y));
|
fitToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FIT_TO_PAGE_ACTION_Y));
|
||||||
connect(fitToPageAction,SIGNAL(triggered()),this,SLOT(fitToPageSwitch()));
|
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 = new QAction(tr("Show go to flow"),this);
|
||||||
showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png"));
|
showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png"));
|
||||||
@ -543,7 +559,8 @@ void MainWindowViewer::createToolBars()
|
|||||||
comicToolBar->addSeparator();
|
comicToolBar->addSeparator();
|
||||||
|
|
||||||
comicToolBar->addAction(showMagnifyingGlassAction);
|
comicToolBar->addAction(showMagnifyingGlassAction);
|
||||||
|
comicToolBar->addAction(increasePageZoomAction);
|
||||||
|
comicToolBar->addAction(decreasePageZoomAction);
|
||||||
|
|
||||||
comicToolBar->addSeparator();
|
comicToolBar->addSeparator();
|
||||||
|
|
||||||
@ -1396,6 +1413,19 @@ void MainWindowViewer::fitToPageSwitch()
|
|||||||
viewer->updatePage();
|
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()
|
void MainWindowViewer::sendComic()
|
||||||
{
|
{
|
||||||
YACReaderLocalClient * client = new YACReaderLocalClient;
|
YACReaderLocalClient * client = new YACReaderLocalClient;
|
||||||
|
@ -54,6 +54,8 @@ class EditShortcutsDialog;
|
|||||||
void alwaysOnTopSwitch();
|
void alwaysOnTopSwitch();
|
||||||
void adjustToFullSizeSwitch();
|
void adjustToFullSizeSwitch();
|
||||||
void fitToPageSwitch();
|
void fitToPageSwitch();
|
||||||
|
void increasePageZoomLevel();
|
||||||
|
void decreasePageZoomLevel();
|
||||||
void reloadOptions();
|
void reloadOptions();
|
||||||
void fitToWidth();
|
void fitToWidth();
|
||||||
void fitToHeight();
|
void fitToHeight();
|
||||||
@ -120,6 +122,8 @@ class EditShortcutsDialog;
|
|||||||
QAction *alwaysOnTopAction;
|
QAction *alwaysOnTopAction;
|
||||||
QAction *adjustToFullSizeAction;
|
QAction *adjustToFullSizeAction;
|
||||||
QAction *fitToPageAction;
|
QAction *fitToPageAction;
|
||||||
|
QAction *increasePageZoomAction;
|
||||||
|
QAction *decreasePageZoomAction;
|
||||||
QAction *showFlowAction;
|
QAction *showFlowAction;
|
||||||
|
|
||||||
QAction *showEditShortcutsAction;
|
QAction *showEditShortcutsAction;
|
||||||
|
@ -326,9 +326,16 @@ void Viewer::updateContentSize()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float aspectRatio = (float)currentPage->width()/currentPage->height();
|
//float aspectRatio = (float)currentPage->width()/currentPage->height();
|
||||||
//Fit to width
|
//Fit to width
|
||||||
if(Configuration::getConfiguration().getAdjustToWidth())
|
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();
|
adjustToWidthRatio = Configuration::getConfiguration().getFitToWidthRatio();
|
||||||
if(static_cast<int>(width()*adjustToWidthRatio/aspectRatio)<height())
|
if(static_cast<int>(width()*adjustToWidthRatio/aspectRatio)<height())
|
||||||
@ -339,6 +346,7 @@ void Viewer::updateContentSize()
|
|||||||
else
|
else
|
||||||
content->resize(width()*adjustToWidthRatio,static_cast<int>(width()*adjustToWidthRatio/aspectRatio));
|
content->resize(width()*adjustToWidthRatio,static_cast<int>(width()*adjustToWidthRatio/aspectRatio));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fit to height or fullsize/custom size
|
//Fit to height or fullsize/custom size
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -346,18 +354,26 @@ void Viewer::updateContentSize()
|
|||||||
content->resize(width(),static_cast<int>(width()/aspectRatio));
|
content->resize(width(),static_cast<int>(width()/aspectRatio));
|
||||||
else
|
else
|
||||||
content->resize(static_cast<int>(height()*aspectRatio),height());
|
content->resize(static_cast<int>(height()*aspectRatio),height());
|
||||||
|
}*/
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QSize pagefit=currentPage->size();
|
||||||
|
pagefit.scale(0, height(), Qt::KeepAspectRatioByExpanding);
|
||||||
|
content->resize(pagefit);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Configuration::getConfiguration().getPageZoomLevel())
|
if(Configuration::getConfiguration().getPageZoomLevel())
|
||||||
{
|
{
|
||||||
QSize pagesize=content->size();
|
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);
|
content->resize(pagesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(devicePixelRatio()>1)//only in retina display
|
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);
|
QPixmap page = currentPage->scaled(content->width()*devicePixelRatio(), content->height()*devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
page.setDevicePixelRatio(devicePixelRatio());
|
page.setDevicePixelRatio(devicePixelRatio());
|
||||||
content->setPixmap(page);
|
content->setPixmap(page);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user