summaryrefslogtreecommitdiffstats
path: root/examples/pdf/pdfviewer
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-02-20 14:53:32 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-02-20 15:55:34 +0100
commit23e2fd1e2b13f4a6587152d8e26bb5de5d75a231 (patch)
tree32d03da3d0bda49f718f676ca33bd2d26ff01d88 /examples/pdf/pdfviewer
parentff13e6532975b5372280c02061cb1b7227cf6699 (diff)
PDF single-page example: move search field to the footer
As with a2be3a7a79dc4fabe8675ea80a6ba550e0e4deec, this makes the search feature more discoverable and touch-friendly. Change-Id: I47e37273c583121d60985cc27c22f56e6d655ab0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples/pdf/pdfviewer')
-rw-r--r--examples/pdf/pdfviewer/viewer.qml142
1 files changed, 71 insertions, 71 deletions
diff --git a/examples/pdf/pdfviewer/viewer.qml b/examples/pdf/pdfviewer/viewer.qml
index 777a9660b..e3bb4b474 100644
--- a/examples/pdf/pdfviewer/viewer.qml
+++ b/examples/pdf/pdfviewer/viewer.qml
@@ -171,6 +171,10 @@ ApplicationWindow {
}
}
Shortcut {
+ sequence: StandardKey.Find
+ onActivated: searchField.forceActiveFocus()
+ }
+ Shortcut {
sequence: StandardKey.Quit
onActivated: Qt.quit()
}
@@ -214,89 +218,85 @@ ApplicationWindow {
id: searchDrawer
edge: Qt.LeftEdge
modal: false
- width: searchLayout.implicitWidth
+ width: 300
y: root.header.height
- height: root.contentItem.height
+ height: view.height
dim: false
- Shortcut {
- sequence: StandardKey.Find
- onActivated: {
- searchDrawer.open()
- searchField.forceActiveFocus()
+ clip: true
+ ListView {
+ id: searchResultsList
+ anchors.fill: parent
+ anchors.margins: 2
+ model: view.searchModel
+ ScrollBar.vertical: ScrollBar { }
+ delegate: ItemDelegate {
+ width: parent ? parent.width : 0
+ text: "page " + (page + 1) + ": " + context
+ highlighted: ListView.isCurrentItem
+ onClicked: {
+ searchResultsList.currentIndex = index
+ view.goToLocation(page, location, 0)
+ view.searchModel.currentResult = indexOnPage
+ }
}
}
- ColumnLayout {
- id: searchLayout
+ }
+
+ footer: ToolBar {
+ height: footerRow.implicitHeight
+ RowLayout {
+ id: footerRow
anchors.fill: parent
- anchors.margins: 2
- RowLayout {
- ToolButton {
- action: Action {
- icon.source: "resources/go-up-search.svg"
- shortcut: StandardKey.FindPrevious
- onTriggered: view.searchBack()
- }
- ToolTip.visible: enabled && hovered
- ToolTip.delay: 2000
- ToolTip.text: "find previous"
+ ToolButton {
+ action: Action {
+ icon.source: "resources/go-up-search.svg"
+ shortcut: StandardKey.FindPrevious
+ onTriggered: view.searchBack()
}
- 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()
- }
+ ToolTip.visible: enabled && hovered
+ ToolTip.delay: 2000
+ ToolTip.text: "find previous"
+ }
+ TextField {
+ id: searchField
+ placeholderText: "search"
+ Layout.minimumWidth: 150
+ Layout.maximumWidth: 300
+ Layout.fillWidth: true
+ onAccepted: searchDrawer.open()
+ Image {
+ visible: searchField.text !== ""
+ source: "resources/edit-clear.svg"
+ anchors {
+ right: parent.right
+ top: parent.top
+ bottom: parent.bottom
+ margins: 3
+ rightMargin: 5
}
- }
- ToolButton {
- action: Action {
- icon.source: "resources/go-down-search.svg"
- shortcut: StandardKey.FindNext
- onTriggered: view.searchForward()
+ TapHandler {
+ onTapped: searchField.clear()
}
- ToolTip.visible: enabled && hovered
- ToolTip.delay: 2000
- ToolTip.text: "find next"
}
}
- ListView {
- id: searchResultsList
- Layout.fillWidth: true
- Layout.fillHeight: true
- clip: true
- model: view.searchModel
- ScrollBar.vertical: ScrollBar { }
- delegate: ItemDelegate {
- width: parent ? parent.width : 0
- text: "page " + (page + 1) + ": " + context
- highlighted: ListView.isCurrentItem
- onClicked: {
- searchResultsList.currentIndex = index
- view.goToLocation(page, location, 0)
- view.searchModel.currentResult = indexOnPage
- }
+ ToolButton {
+ action: Action {
+ icon.source: "resources/go-down-search.svg"
+ shortcut: StandardKey.FindNext
+ onTriggered: view.searchForward()
}
+ ToolTip.visible: enabled && hovered
+ ToolTip.delay: 2000
+ ToolTip.text: "find next"
+ }
+ Label {
+ Layout.fillWidth: true
+ 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
}
}
}
-
- footer: Label {
- 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
- }
}