| 434 | } |
| 435 | |
| 436 | void Viewer::updateContentSize() |
| 437 | { |
| 438 | // there is an image to resize |
| 439 | if (currentPage != nullptr && !currentPage->isNull()) { |
| 440 | QSize pagefit = currentPage->size(); |
| 441 | bool stretchImages = Configuration::getConfiguration().getEnlargeImages(); |
| 442 | YACReader::FitMode fitmode = Configuration::getConfiguration().getFitMode(); |
| 443 | switch (fitmode) { |
| 444 | case YACReader::FitMode::FullRes: |
| 445 | break; |
| 446 | case YACReader::FitMode::ToWidth: |
| 447 | if (!stretchImages && width() > pagefit.width()) { |
| 448 | break; |
| 449 | } |
| 450 | pagefit.scale(width(), 0, Qt::KeepAspectRatioByExpanding); |
| 451 | break; |
| 452 | case YACReader::FitMode::ToHeight: |
| 453 | if (!stretchImages && height() > pagefit.height()) { |
| 454 | break; |
| 455 | } |
| 456 | pagefit.scale(0, height(), Qt::KeepAspectRatioByExpanding); |
| 457 | break; |
| 458 | // if everything fails showing the full page is a good idea |
| 459 | case YACReader::FitMode::FullPage: |
| 460 | default: |
| 461 | pagefit.scale(size(), Qt::KeepAspectRatio); |
| 462 | break; |
| 463 | } |
| 464 | |
| 465 | if (zoom != 100) { |
| 466 | pagefit.scale(floor(pagefit.width() * zoom / 100.0f), 0, Qt::KeepAspectRatioByExpanding); |
| 467 | } |
| 468 | // apply size to the container |
| 469 | content->resize(pagefit); |
| 470 | |
| 471 | // scale the pixmap to physical pixels for crisp rendering on all displays |
| 472 | auto dpr = devicePixelRatioF(); |
| 473 | QPixmap page = scalePixmap(*currentPage, |
| 474 | qRound(content->width() * dpr), |
| 475 | qRound(content->height() * dpr), |
| 476 | Configuration::getConfiguration().getScalingMethod()); |
| 477 | page.setDevicePixelRatio(dpr); |
| 478 | content->setPixmap(page); |
| 479 | |
| 480 | emit backgroundChanges(); |
| 481 | } |
| 482 | content->update(); // TODO, it shouldn't be neccesary |
| 483 | } |
| 484 | |
| 485 | void Viewer::increaseZoomFactor() |
| 486 | { |
nothing calls this directly
no test coverage detected