summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-02-20 14:09:27 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-02-20 15:55:18 +0100
commitff13e6532975b5372280c02061cb1b7227cf6699 (patch)
tree52839b494927fee50db7d5d4da94529bd5c4d77f /examples
parentf467edc97e66727be7fa3747913e4e01672d4b71 (diff)
Add PdfScrollablePageView, use it in the pdfviewer example
PdfPageView might be useful in some cases, but we need to get feature parity with PdfMultiPageView as much as possible, including scrollbars. Including them in the view is convenient, but also less flexible. Change-Id: Ibbe6a090a5f5b1d340124986fe49672d682ddedb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/pdf/pdfviewer/viewer.qml75
1 files changed, 30 insertions, 45 deletions
diff --git a/examples/pdf/pdfviewer/viewer.qml b/examples/pdf/pdfviewer/viewer.qml
index a2bccab44..777a9660b 100644
--- a/examples/pdf/pdfviewer/viewer.qml
+++ b/examples/pdf/pdfviewer/viewer.qml
@@ -80,57 +80,57 @@ ApplicationWindow {
ToolButton {
action: Action {
shortcut: StandardKey.ZoomIn
- enabled: pageView.sourceSize.width < 10000
+ enabled: view.sourceSize.width < 10000
icon.source: "resources/zoom-in.svg"
- onTriggered: pageView.renderScale *= root.scaleStep
+ onTriggered: view.renderScale *= root.scaleStep
}
}
ToolButton {
action: Action {
shortcut: StandardKey.ZoomOut
- enabled: pageView.sourceSize.width > 50
+ enabled: view.sourceSize.width > 50
icon.source: "resources/zoom-out.svg"
- onTriggered: pageView.renderScale /= root.scaleStep
+ onTriggered: view.renderScale /= root.scaleStep
}
}
ToolButton {
action: Action {
icon.source: "resources/zoom-fit-width.svg"
- onTriggered: pageView.scaleToWidth(root.contentItem.width, root.contentItem.height)
+ onTriggered: view.scaleToWidth(root.contentItem.width, root.contentItem.height)
}
}
ToolButton {
action: Action {
icon.source: "resources/zoom-fit-best.svg"
- onTriggered: pageView.scaleToPage(root.contentItem.width, root.contentItem.height)
+ onTriggered: view.scaleToPage(root.contentItem.width, root.contentItem.height)
}
}
ToolButton {
action: Action {
shortcut: "Ctrl+0"
icon.source: "resources/zoom-original.svg"
- onTriggered: pageView.resetScale()
+ onTriggered: view.resetScale()
}
}
ToolButton {
action: Action {
shortcut: "Ctrl+L"
icon.source: "resources/rotate-left.svg"
- onTriggered: pageView.rotation -= 90
+ onTriggered: view.pageRotation -= 90
}
}
ToolButton {
action: Action {
shortcut: "Ctrl+R"
icon.source: "resources/rotate-right.svg"
- onTriggered: pageView.rotation += 90
+ onTriggered: view.pageRotation += 90
}
}
ToolButton {
action: Action {
icon.source: "resources/go-previous-view-page.svg"
- enabled: pageView.backEnabled
- onTriggered: pageView.back()
+ enabled: view.backEnabled
+ onTriggered: view.back()
}
ToolTip.visible: enabled && hovered
ToolTip.delay: 2000
@@ -141,22 +141,22 @@ ApplicationWindow {
from: 1
to: document.pageCount
editable: true
- value: pageView.currentPage + 1
- onValueModified: pageView.goToPage(value - 1)
+ value: view.currentPage + 1
+ onValueModified: view.goToPage(value - 1)
Shortcut {
sequence: StandardKey.MoveToPreviousPage
- onActivated: pageView.goToPage(currentPageSB.value - 2)
+ onActivated: view.goToPage(currentPageSB.value - 2)
}
Shortcut {
sequence: StandardKey.MoveToNextPage
- onActivated: pageView.goToPage(currentPageSB.value)
+ onActivated: view.goToPage(currentPageSB.value)
}
}
ToolButton {
action: Action {
icon.source: "resources/go-next-view-page.svg"
- enabled: pageView.forwardEnabled
- onTriggered: pageView.forward()
+ enabled: view.forwardEnabled
+ onTriggered: view.forward()
}
ToolTip.visible: enabled && hovered
ToolTip.delay: 2000
@@ -166,8 +166,8 @@ ApplicationWindow {
action: Action {
shortcut: StandardKey.Copy
icon.source: "resources/edit-copy.svg"
- enabled: pageView.selectedText !== ""
- onTriggered: pageView.copySelectionToClipboard()
+ enabled: view.selectedText !== ""
+ onTriggered: view.copySelectionToClipboard()
}
}
Shortcut {
@@ -199,9 +199,9 @@ ApplicationWindow {
}
}
- PdfPageView {
- id: pageView
- x: searchDrawer.position * searchDrawer.width // TODO binding gets broken during centering
+ PdfScrollablePageView {
+ id: view
+ anchors.fill: parent
document: PdfDocument {
id: document
source: Qt.resolvedUrl(root.source)
@@ -210,21 +210,6 @@ ApplicationWindow {
searchString: searchField.text
}
- WheelHandler {
- rotationScale: 15
- target: pageView
- property: "x"
- orientation: Qt.Horizontal
- acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
- }
- WheelHandler {
- rotationScale: 15
- target: pageView
- property: "y"
- orientation: Qt.Vertical
- acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
- }
-
Drawer {
id: searchDrawer
edge: Qt.LeftEdge
@@ -249,7 +234,7 @@ ApplicationWindow {
action: Action {
icon.source: "resources/go-up-search.svg"
shortcut: StandardKey.FindPrevious
- onTriggered: pageView.searchBack()
+ onTriggered: view.searchBack()
}
ToolTip.visible: enabled && hovered
ToolTip.delay: 2000
@@ -279,7 +264,7 @@ ApplicationWindow {
action: Action {
icon.source: "resources/go-down-search.svg"
shortcut: StandardKey.FindNext
- onTriggered: pageView.searchForward()
+ onTriggered: view.searchForward()
}
ToolTip.visible: enabled && hovered
ToolTip.delay: 2000
@@ -291,7 +276,7 @@ ApplicationWindow {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
- model: pageView.searchModel
+ model: view.searchModel
ScrollBar.vertical: ScrollBar { }
delegate: ItemDelegate {
width: parent ? parent.width : 0
@@ -299,8 +284,8 @@ ApplicationWindow {
highlighted: ListView.isCurrentItem
onClicked: {
searchResultsList.currentIndex = index
- pageView.goToLocation(page, location, 0)
- pageView.searchModel.currentResult = indexOnPage
+ view.goToLocation(page, location, 0)
+ view.searchModel.currentResult = indexOnPage
}
}
}
@@ -308,9 +293,9 @@ ApplicationWindow {
}
footer: Label {
- property size implicitPointSize: document.pagePointSize(pageView.currentPage)
- text: "page " + (pageView.currentPage + 1) + " of " + document.pageCount +
- " scale " + pageView.renderScale.toFixed(2) +
+ property size implicitPointSize: document.pagePointSize(view.currentPage)
+ text: "page " + (view.currentPage + 1) + " of " + document.pageCount +
+ " scale " + view.renderScale.toFixed(2) +
" original " + implicitPointSize.width.toFixed(1) + "x" + implicitPointSize.height.toFixed(1) + "pts"
visible: document.status === PdfDocument.Ready
}