From 3093ddfa8fb22db9295bc76a07207e6da0a3e995 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 17 Jan 2024 15:37:29 -0700 Subject: Fix high-dpi scaling in PdfScrollablePageView Amends 85f82185ef5102a2dbe3b2e437b9723e1652ce57 In PdfScrollablePageView.qml, a property like property size pagePointSize: document.pagePointSize(pageNavigator.currentPage) would get evaluated too early (QPdfDocument::pagePointSize() returns a default-constructed QSize if d->doc is still null). We need to call pagePointSize() directly in bindings that need it, so that the function will be called again each time some other binding dependency changes, to get the size of the current page in the current document. Perhaps a binding to the result of a function call does not get invalidated when the function argument changes; or perhaps behavior changed now that the QML files tend to be compiled rather than runtime-interpreted resources. We also need PdfPageImage's width and height to be bound (as they are in PdfMultiPageView.qml), to avoid automatically scaling up to sourceSize. So now we get high-dpi page images again in the single-page example. Task-number: QTBUG-86948 Pick-to: 6.5 6.6 6.7 Change-Id: I44e8df15c18bd0b752dccc899028e7e7900f6ffb Reviewed-by: Fabian Kosmale --- src/pdfquick/PdfScrollablePageView.qml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pdfquick/PdfScrollablePageView.qml b/src/pdfquick/PdfScrollablePageView.qml index 5295db7f8..afebdd080 100644 --- a/src/pdfquick/PdfScrollablePageView.qml +++ b/src/pdfquick/PdfScrollablePageView.qml @@ -302,9 +302,6 @@ Flickable { } onRenderScaleChanged: { - image.sourceSize.width = document.pagePointSize(pageNavigator.currentPage).width * - renderScale * Screen.devicePixelRatio - image.sourceSize.height = 0 paper.scale = 1 const currentLocation = Qt.point((root.contentX + root.width / 2) / root.renderScale, (root.contentY + root.height / 2) / root.renderScale) @@ -365,6 +362,10 @@ Flickable { rotation: root.pageRotation anchors.centerIn: parent property real pageScale: image.paintedWidth / document.pagePointSize(pageNavigator.currentPage).width + width: document.pagePointSize(pageNavigator.currentPage).width * root.renderScale + height: document.pagePointSize(pageNavigator.currentPage).height * root.renderScale + sourceSize.width: width * Screen.devicePixelRatio + sourceSize.height: 0 Shape { anchors.fill: parent -- cgit v1.2.3