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

Method zoomFitContentWidth

modules/QtPDF/src/PDFDocumentView.cpp:692–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

690}
691
692void PDFDocumentView::zoomFitContentWidth()
693{
694 if (!_pdf_scene)
695 return;
696
697 PDFPageGraphicsItem *currentPage = dynamic_cast<PDFPageGraphicsItem*>(_pdf_scene->pageAt(_currentPage));
698 if (!currentPage)
699 return;
700
701 QSharedPointer<Backend::Page> page = currentPage->page().toStrongRef();
702 if (!page)
703 return;
704
705 QRectF rect(page->getContentBoundingBox());
706 rect = currentPage->mapRectToScene(QRectF(currentPage->mapFromPage(rect.topLeft()), currentPage->mapFromPage(rect.bottomRight())));
707
708 // Store current y position so we can center on it later.
709 qreal ypos = mapToScene(viewport()->rect()).boundingRect().center().y();
710
711 // Squash the rect to minimal height so its width will be limitting the zoom
712 // factor
713 rect.setTop(ypos - 1e-5);
714 rect.setBottom(ypos + 1e-5);
715
716 zoomToRect(rect);
717}
718
719
720void PDFDocumentView::zoom100()

Callers 1

setDefaultScaleMethod · 0.80

Calls 6

pageAtMethod · 0.80
getContentBoundingBoxMethod · 0.80
boundingRectMethod · 0.80
pageMethod · 0.45
mapFromPageMethod · 0.45
rectMethod · 0.45

Tested by

no test coverage detected