MCPcopy Create free account
hub / github.com/TeXworks/texworks / zoomFitWidth

Method zoomFitWidth

modules/QtPDF/src/PDFDocumentView.cpp:664–690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

662
663
664void PDFDocumentView::zoomFitWidth()
665{
666 if (!_pdf_scene)
667 return;
668
669 QGraphicsItem *currentPage = _pdf_scene->pageAt(_currentPage);
670 if (!currentPage)
671 return;
672
673 QRectF rect(currentPage->sceneBoundingRect());
674
675 // Add a margin of half the inter-page spacing around the page rect so
676 // scrolling by one such rect will take us to exactly the same area on the
677 // next page
678 qreal dx = _pdf_scene->pageLayout().xSpacing();
679 rect.adjust(-dx / 2, 0, dx / 2, 0);
680
681 // Store current y position so we can center on it later.
682 qreal ypos = mapToScene(viewport()->rect()).boundingRect().center().y();
683
684 // Squash the rect to minimal height so its width will be limitting the zoom
685 // factor
686 rect.setTop(ypos - 1e-5);
687 rect.setBottom(ypos + 1e-5);
688
689 zoomToRect(rect);
690}
691
692void PDFDocumentView::zoomFitContentWidth()
693{

Callers 1

setDefaultScaleMethod · 0.80

Calls 4

pageAtMethod · 0.80
xSpacingMethod · 0.80
boundingRectMethod · 0.80
rectMethod · 0.45

Tested by

no test coverage detected