summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-03-08 12:43:30 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2022-03-10 10:08:46 +0100
commit621968652a00d6bfd7d0e4cdee02911cdb699579 (patch)
tree1bd1bcd7daf092994fb5943def6a746939d9fe8f /examples
parentec9fcaac50e971d8e2aa7964c4cb4a834262f204 (diff)
downloadqtwebengine-621968652a00d6bfd7d0e4cdee02911cdb699579.tar.gz
multipage PDF viewer example: simplify, and fix more qmllint warnings
- no need for the document.onStatusChanged handler - no need for empty-argument function() { ... } in onSignal handlers - unqualified access and so on - scale the search field margins and erase-button a bit better Change-Id: Ice8a41e4cc1fb0385046aa1867fdb4b1400234b6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/pdf/multipage/viewer.qml28
1 files changed, 13 insertions, 15 deletions
diff --git a/examples/pdf/multipage/viewer.qml b/examples/pdf/multipage/viewer.qml
index 527ed9eb4..7b085ee91 100644
--- a/examples/pdf/multipage/viewer.qml
+++ b/examples/pdf/multipage/viewer.qml
@@ -206,7 +206,7 @@ ApplicationWindow {
width: parent.width
onAccepted: passwordDialog.accept()
}
- onOpened: function() { passwordField.forceActiveFocus() }
+ onOpened: passwordField.forceActiveFocus()
onAccepted: document.password = passwordField.text
}
@@ -229,10 +229,7 @@ ApplicationWindow {
PdfDocument {
id: document
source: Qt.resolvedUrl(root.source)
- onStatusChanged: {
- view.document = (status === PdfDocument.Ready ? document : null)
- }
- onPasswordRequired: function() { passwordDialog.open() }
+ onPasswordRequired: passwordDialog.open()
}
PdfMultiPageView {
@@ -260,6 +257,7 @@ ApplicationWindow {
model: view.searchModel
ScrollBar.vertical: ScrollBar { }
delegate: ItemDelegate {
+ id: resultDelegate
required property int index
required property int page
required property int indexOnPage
@@ -271,10 +269,10 @@ ApplicationWindow {
anchors.fill: parent
spacing: 0
Label {
- text: "Page " + (page + 1) + ": "
+ text: "Page " + (resultDelegate.page + 1) + ": "
}
Label {
- text: contextBefore
+ text: resultDelegate.contextBefore
elide: Text.ElideLeft
horizontalAlignment: Text.AlignRight
Layout.fillWidth: true
@@ -286,7 +284,7 @@ ApplicationWindow {
width: implicitWidth
}
Label {
- text: contextAfter
+ text: resultDelegate.contextAfter
elide: Text.ElideRight
Layout.fillWidth: true
Layout.preferredWidth: parent.width / 2
@@ -294,16 +292,16 @@ ApplicationWindow {
}
highlighted: ListView.isCurrentItem
onClicked: {
- searchResultsList.currentIndex = index
- view.goToLocation(page, location, 0)
- view.searchModel.currentResult = indexOnPage
+ searchResultsList.currentIndex = resultDelegate.index
+ view.goToLocation(resultDelegate.page, resultDelegate.location, 0)
+ view.searchModel.currentResult = resultDelegate.indexOnPage
}
}
}
}
footer: ToolBar {
- height: footerRow.implicitHeight
+ height: footerRow.implicitHeight + 6
RowLayout {
id: footerRow
anchors.fill: parent
@@ -322,16 +320,16 @@ ApplicationWindow {
placeholderText: "search"
Layout.minimumWidth: 150
Layout.fillWidth: true
+ Layout.bottomMargin: 3
onAccepted: searchDrawer.open()
Image {
visible: searchField.text !== ""
source: "qrc:/pdfviewer/resources/edit-clear.svg"
+ sourceSize.height: searchField.height - 6
anchors {
right: parent.right
- top: parent.top
- bottom: parent.bottom
+ verticalCenter: parent.verticalCenter
margins: 3
- rightMargin: 5
}
TapHandler {
onTapped: searchField.clear()