summaryrefslogtreecommitdiffstats
path: root/src/pdf/quick/qml
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-01-22 00:56:16 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-02-03 23:44:03 +0100
commit7cf69cb52d434f5e74619b0577104d05688b0c22 (patch)
treed0d60f971c59087b7f353123df5233a3e2343b3b /src/pdf/quick/qml
parenta8e4ad7726f1aa52624a0367558650cd4d899c79 (diff)
Add PdfNavigationStack for forward/back navigation
Works well enough to use, but needs autotests and at least one fix. Change-Id: I2114b9fb3b5ddf7cfe2106d4a4fbc7d74852c61d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/pdf/quick/qml')
-rw-r--r--src/pdf/quick/qml/PdfPageView.qml27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/pdf/quick/qml/PdfPageView.qml b/src/pdf/quick/qml/PdfPageView.qml
index e20ebd1b4..041054e59 100644
--- a/src/pdf/quick/qml/PdfPageView.qml
+++ b/src/pdf/quick/qml/PdfPageView.qml
@@ -48,13 +48,18 @@ Rectangle {
property var document: null
property real renderScale: 1
property alias sourceSize: image.sourceSize
- property alias currentPage: image.currentFrame
+ property alias currentPage: navigationStack.currentPage
property alias pageCount: image.frameCount
property alias searchString: searchModel.searchString
property alias selectedText: selection.text
property alias status: image.status
+ property alias backEnabled: navigationStack.backAvailable
+ property alias forwardEnabled: navigationStack.forwardAvailable
+ function back() { navigationStack.back() }
+ function forward() { navigationStack.forward() }
+ signal currentPageReallyChanged(page: int)
- property real __pageScale: image.paintedWidth / document.pagePointSize(image.currentFrame).width
+ property real __pageScale: image.paintedWidth / document.pagePointSize(navigationStack.currentPage).width
function resetScale() {
image.sourceSize.width = 0
@@ -78,7 +83,7 @@ Rectangle {
function scaleToPage(width, height) {
var windowAspect = width / height
var halfRotation = Math.abs(paper.rotation % 180)
- var pagePointSize = document.pagePointSize(image.currentFrame)
+ var pagePointSize = document.pagePointSize(navigationStack.currentPage)
if (halfRotation > 45 && halfRotation < 135) {
// rotated 90 or 270ยบ
var pageAspect = pagePointSize.height / pagePointSize.width
@@ -104,7 +109,7 @@ Rectangle {
PdfSelection {
id: selection
document: paper.document
- page: image.currentFrame
+ page: navigationStack.currentPage
fromPoint: Qt.point(textSelectionDrag.centroid.pressPosition.x / paper.__pageScale, textSelectionDrag.centroid.pressPosition.y / paper.__pageScale)
toPoint: Qt.point(textSelectionDrag.centroid.position.x / paper.__pageScale, textSelectionDrag.centroid.position.y / paper.__pageScale)
hold: !textSelectionDrag.active && !tapHandler.pressed
@@ -116,11 +121,17 @@ Rectangle {
PdfSearchModel {
id: searchModel
document: paper.document
- page: image.currentFrame
+ page: navigationStack.currentPage
+ }
+
+ PdfNavigationStack {
+ id: navigationStack
+ onCurrentPageChanged: paper.currentPageReallyChanged(navigationStack.currentPage)
}
Image {
id: image
+ currentFrame: navigationStack.currentPage
source: document.status === PdfDocument.Ready ? document.source : ""
asynchronous: true
fillMode: Image.PreserveAspectFit
@@ -145,7 +156,7 @@ Rectangle {
}
}
onRenderScaleChanged: {
- image.sourceSize.width = document.pagePointSize(image.currentFrame).width * renderScale
+ image.sourceSize.width = document.pagePointSize(navigationStack.currentPage).width * renderScale
image.sourceSize.height = 0
paper.scale = 1
}
@@ -178,7 +189,7 @@ Rectangle {
model: PdfLinkModel {
id: linkModel
document: paper.document
- page: image.currentFrame
+ page: navigationStack.currentPage
}
delegate: Rectangle {
color: "transparent"
@@ -191,7 +202,7 @@ Rectangle {
TapHandler {
onTapped: {
if (page >= 0)
- image.currentFrame = page
+ navigationStack.currentPage = page
else
Qt.openUrlExternally(url)
}