Merged luisangelsm/yacreader into default

This commit is contained in:
Felix Kauselmann
2015-02-24 19:08:19 +01:00
8 changed files with 161 additions and 26 deletions

View File

@ -321,14 +321,28 @@ void Viewer::updateContentSize()
//there is an image to resize
if(currentPage !=0 && !currentPage->isNull())
{
if(Configuration::getConfiguration().getAdjustToFullSize())
if(!Configuration::getConfiguration().getFitMode().isNull())
{
content->resize(currentPage->width(),currentPage->height());
}
else
{
float aspectRatio = (float)currentPage->width()/currentPage->height();
if(Configuration::getConfiguration().getFitMode()=="full_size")
{
content->resize(currentPage->size());
}
else if(Configuration::getConfiguration().getFitMode()=="full_page")
{
QSize pagefit=currentPage->size();
pagefit.scale(size(), Qt::KeepAspectRatio);
content->resize(pagefit);
}
//float aspectRatio = (float)currentPage->width()/currentPage->height();
//Fit to width
else if(Configuration::getConfiguration().getFitMode()=="to_width")
{
QSize pagefit=currentPage->size();
pagefit.scale(width(), 0, Qt::KeepAspectRatioByExpanding);
content->resize(pagefit);
}
/*
if(Configuration::getConfiguration().getAdjustToWidth())
{
adjustToWidthRatio = Configuration::getConfiguration().getFitToWidthRatio();
@ -340,6 +354,7 @@ void Viewer::updateContentSize()
else
content->resize(width()*adjustToWidthRatio,static_cast<int>(width()*adjustToWidthRatio/aspectRatio));
}
//Fit to height or fullsize/custom size
else
{
@ -347,9 +362,31 @@ void Viewer::updateContentSize()
content->resize(width(),static_cast<int>(width()/aspectRatio));
else
content->resize(static_cast<int>(height()*aspectRatio),height());
}*/
else if(Configuration::getConfiguration().getFitMode()=="to_height")
{
QSize pagefit=currentPage->size();
pagefit.scale(0, height(), Qt::KeepAspectRatioByExpanding);
content->resize(pagefit);
}
else //if everything else fails use full_page
{
Configuration::getConfiguration().setFitMode("full_page");
QSize pagefit=currentPage->size();
pagefit.scale(size(), Qt::KeepAspectRatio);
content->resize(pagefit);
}
}
if(Configuration::getConfiguration().getPageZoomLevel())
{
QSize pagesize=content->size();
pagesize.scale(content->width()*Configuration::getConfiguration().getPageZoomLevel(), 0, Qt::KeepAspectRatioByExpanding);
content->resize(pagesize);
}
if(devicePixelRatio()>1)//only in retina display
{
QPixmap page = currentPage->scaled(content->width()*devicePixelRatio(), content->height()*devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
@ -883,7 +920,8 @@ void Viewer::mouseReleaseEvent ( QMouseEvent * event )
void Viewer::updateFitToWidthRatio(float ratio)
{
Configuration::getConfiguration().setAdjustToWidth(true);
//Configuration::getConfiguration().setAdjustToWidth(true);
Configuration::getConfiguration().setFitMode("to_width");
adjustToWidthRatio = ratio;
updateContentSize();
}