diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-09-01 08:30:48 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-09-06 12:02:52 +0200 |
commit | d3bd8891b578c37fa3a88e0b93c314f25f789c75 (patch) | |
tree | 9c870f28ed96ccef9cfcfc62d2a079b01c77640a /src/pdfquick | |
parent | 84eaa29b881d25f1b7588187b5b74a9da133d430 (diff) | |
download | qtwebengine-d3bd8891b578c37fa3a88e0b93c314f25f789c75.tar.gz |
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.
Pick-to: 6.4
Fixes: QTBUG-104769
Change-Id: I4eb785e572816d1b80ea9c8f4f5b9c925594afac
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/pdfquick')
-rw-r--r-- | src/pdfquick/PdfMultiPageView.qml | 7 | ||||
-rw-r--r-- | src/pdfquick/PdfScrollablePageView.qml | 7 |
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, |