diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2024-01-17 15:37:29 -0700 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2024-01-22 21:21:09 -0700 |
commit | 3093ddfa8fb22db9295bc76a07207e6da0a3e995 (patch) | |
tree | ac45932c312e1f1e8025fcf093279c0322d57d88 /src | |
parent | a8325ce5cbd90d1eb5077b69b34820a19c5a5e87 (diff) |
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 <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/pdfquick/PdfScrollablePageView.qml | 7 |
1 files changed, 4 insertions, 3 deletions
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 |