summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-02-07 14:54:31 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-02-11 08:30:06 +0100
commite5a33355798d3277c631b0024f389cdca2f2c683 (patch)
treebf4ee5e91241a9cafd8dfe185a1174fb27f3114f /examples
parent7afe95f14d7d048a73baa12b3bd5f6a9bcea2ccb (diff)
PDF multipage viewer: iterate search results
This version still has separate PdfSearchModel instances on each page, but now there are buttons to iterate and highlight the search results in order. When you come to the last result on one page, hitting the "Find Next" button will jump to the next page, and keep jumping forward from there until another result is found. Unfortunately this jumping takes time if it skips over a lot of pages because of empty search results. That seems to be another reason to make PdfSearchModel into a whole-document search model and use one instance. Also reorganize PdfMultiPageView.qml's public API into sections according to functionality rather than by type. Change-Id: I677a764fcbf231b2656aff8abe7240a27582a696 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/pdf/multipage/resources/go-down-search.svg13
-rw-r--r--examples/pdf/multipage/resources/go-up-search.svg8
-rw-r--r--examples/pdf/multipage/viewer.qml81
-rw-r--r--examples/pdf/multipage/viewer.qrc2
4 files changed, 80 insertions, 24 deletions
diff --git a/examples/pdf/multipage/resources/go-down-search.svg b/examples/pdf/multipage/resources/go-down-search.svg
new file mode 100644
index 000000000..ae17ab93b
--- /dev/null
+++ b/examples/pdf/multipage/resources/go-down-search.svg
@@ -0,0 +1,13 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
+ <defs id="defs3051">
+ <style type="text/css" id="current-color-scheme">
+ .ColorScheme-Text {
+ color:#232629;
+ }
+ </style>
+ </defs>
+ <path style="fill:currentColor;fill-opacity:1;stroke:none"
+ d="M 4.7070312 8 L 4 8.7070312 L 10.125 14.832031 L 12 16.707031 L 13.875 14.832031 L 20 8.7070312 L 19.292969 8 L 13.167969 14.125 L 12 15.292969 L 10.832031 14.125 L 4.7070312 8 z "
+ class="ColorScheme-Text"
+ />
+</svg>
diff --git a/examples/pdf/multipage/resources/go-up-search.svg b/examples/pdf/multipage/resources/go-up-search.svg
new file mode 100644
index 000000000..5cc155873
--- /dev/null
+++ b/examples/pdf/multipage/resources/go-up-search.svg
@@ -0,0 +1,8 @@
+<svg height="24" width="24" xmlns="http://www.w3.org/2000/svg">
+ <style type="text/css" id="current-color-scheme">
+ .ColorScheme-Text {
+ color:#232629;
+ }
+ </style>
+ <path d="M4.707 16L4 15.293l8-8 8 8-.707.707L12 8.707" class="ColorScheme-Text" fill="currentColor"/>
+</svg>
diff --git a/examples/pdf/multipage/viewer.qml b/examples/pdf/multipage/viewer.qml
index bbc28cd8d..3d9cd371a 100644
--- a/examples/pdf/multipage/viewer.qml
+++ b/examples/pdf/multipage/viewer.qml
@@ -167,30 +167,6 @@ ApplicationWindow {
onTriggered: view.copySelectionToClipboard()
}
}
- TextField {
- id: searchField
- placeholderText: "search"
- Layout.minimumWidth: 200
- Layout.fillWidth: true
- Image {
- visible: searchField.text !== ""
- source: "resources/edit-clear.svg"
- anchors {
- right: parent.right
- top: parent.top
- bottom: parent.bottom
- margins: 3
- rightMargin: 5
- }
- TapHandler {
- onTapped: searchField.clear()
- }
- }
- }
- Shortcut {
- sequence: StandardKey.Find
- onActivated: searchField.forceActiveFocus()
- }
Shortcut {
sequence: StandardKey.Quit
onActivated: Qt.quit()
@@ -259,6 +235,63 @@ ApplicationWindow {
onCurrentPageChanged: currentPageSB.value = view.currentPage + 1
}
+ Drawer {
+ id: searchDrawer
+ edge: Qt.BottomEdge
+ x: 20
+ width: searchLayout.implicitWidth
+ height: searchLayout.implicitHeight
+ dim: false
+ Shortcut {
+ sequence: StandardKey.Find
+ onActivated: {
+ searchDrawer.open()
+ searchField.forceActiveFocus()
+ }
+ }
+ RowLayout {
+ id: searchLayout
+ ToolButton {
+ action: Action {
+ icon.source: "resources/go-up-search.svg"
+ onTriggered: view.searchBack()
+ }
+ ToolTip.visible: enabled && hovered
+ ToolTip.delay: 2000
+ ToolTip.text: "find previous"
+ }
+ TextField {
+ id: searchField
+ placeholderText: "search"
+ Layout.minimumWidth: 200
+ Layout.fillWidth: true
+ Image {
+ visible: searchField.text !== ""
+ source: "resources/edit-clear.svg"
+ anchors {
+ right: parent.right
+ top: parent.top
+ bottom: parent.bottom
+ margins: 3
+ rightMargin: 5
+ }
+ TapHandler {
+ onTapped: searchField.clear()
+ }
+ }
+ }
+ ToolButton {
+ action: Action {
+ icon.source: "resources/go-down-search.svg"
+ onTriggered: view.searchForward()
+ }
+ ToolTip.visible: enabled && hovered
+ ToolTip.delay: 2000
+ ToolTip.text: "find next"
+ }
+ }
+ }
+
footer: ToolBar {
height: statusLabel.implicitHeight * 1.5
Label {
diff --git a/examples/pdf/multipage/viewer.qrc b/examples/pdf/multipage/viewer.qrc
index fa3561caf..9698a2689 100644
--- a/examples/pdf/multipage/viewer.qrc
+++ b/examples/pdf/multipage/viewer.qrc
@@ -3,8 +3,10 @@
<file>viewer.qml</file>
<file>resources/edit-clear.svg</file>
<file>resources/edit-copy.svg</file>
+ <file>resources/go-down-search.svg</file>
<file>resources/go-next-view-page.svg</file>
<file>resources/go-previous-view-page.svg</file>
+ <file>resources/go-up-search.svg</file>
<file>resources/rotate-left.svg</file>
<file>resources/rotate-right.svg</file>
<file>resources/zoom-in.svg</file>