summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-09-01 08:30:48 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-09-06 19:17:47 +0000
commite525aa1b27e1226c8ee631bee775bcaff709c8c7 (patch)
tree913ac24c94e95378d837c48c017fb5ecfe28262e /src
parente23c5ec67003e231963eec808174d40401d861f9 (diff)
Pdf[Multi|Scrollable]PageView: enforce zoom limits, don't get stuck
Handlers must not get disabled because the zoom range is beyond limits: rather, let PinchHandler's minimumScale and maximumScale enforce them. So far, PdfMultiPageView and PdfScrollablePageView do not have other ways of zooming (like a WheelHandler for control-mouse-wheel), so we don't need BoundaryRule. But the limits applied by PinchHandler are "hard" limits: you bump up against them instantly, with no easing curve. Fixes: QTBUG-104769 Change-Id: I4eb785e572816d1b80ea9c8f4f5b9c925594afac Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit d3bd8891b578c37fa3a88e0b93c314f25f789c75) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/pdfquick/PdfMultiPageView.qml7
-rw-r--r--src/pdfquick/PdfScrollablePageView.qml7
2 files changed, 8 insertions, 6 deletions
diff --git a/src/pdfquick/PdfMultiPageView.qml b/src/pdfquick/PdfMultiPageView.qml
index 6b9cf329d..0f62a229d 100644
--- a/src/pdfquick/PdfMultiPageView.qml
+++ b/src/pdfquick/PdfMultiPageView.qml
@@ -293,6 +293,8 @@ Item {
TableView {
id: tableView
property bool debug: false
+ property real minScale: 0.1
+ property real maxScale: 10
property point jumpLocationMargin: Qt.point(10, 10) // px away from viewport edges
anchors.fill: parent
anchors.leftMargin: 2
@@ -399,11 +401,10 @@ Item {
}
PinchHandler {
id: pinch
- minimumScale: 0.1
- maximumScale: root.renderScale < 4 ? 2 : 1
+ minimumScale: tableView.minScale / root.renderScale
+ maximumScale: Math.max(1, tableView.maxScale / root.renderScale)
minimumRotation: root.pageRotation
maximumRotation: root.pageRotation
- enabled: image.sourceSize.width < 5000
onActiveChanged:
if (active) {
paper.z = 10
diff --git a/src/pdfquick/PdfScrollablePageView.qml b/src/pdfquick/PdfScrollablePageView.qml
index 7d3a411a8..5295db7f8 100644
--- a/src/pdfquick/PdfScrollablePageView.qml
+++ b/src/pdfquick/PdfScrollablePageView.qml
@@ -353,6 +353,8 @@ Flickable {
height: rot90 ? image.width : image.height
property real rotationModulus: Math.abs(root.pageRotation % 180)
property bool rot90: rotationModulus > 45 && rotationModulus < 135
+ property real minScale: 0.1
+ property real maxScale: 10
PdfPageImage {
id: image
@@ -447,11 +449,10 @@ Flickable {
PinchHandler {
id: pinch
- minimumScale: 0.1
- maximumScale: root.renderScale < 4 ? 2 : 1
+ minimumScale: paper.minScale / root.renderScale
+ maximumScale: Math.max(1, paper.maxScale / root.renderScale)
minimumRotation: 0
maximumRotation: 0
- enabled: image.sourceSize.width < 5000
onActiveChanged:
if (!active) {
const centroidInPoints = Qt.point(pinch.centroid.position.x / root.renderScale,