summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-08-26 10:13:55 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2022-03-07 17:40:20 +0100
commit94f96d9ba1eae886f7a92c72384c24bf60fa7175 (patch)
tree5869fa82414b28496e298c0ff33f94d393db56f7 /tests
parent85f82185ef5102a2dbe3b2e437b9723e1652ce57 (diff)
PDF viewer and manual test: support password-protected documents
The multipage example was OK already; this adds the same password-prompt dialog to the single-page-at-a-time pdfviewer example and to the withdoc.qml manual test. Also, the dialogs seem to size themselves better if we explicitly set the contentItem properties. And an error dialog should not have an OK button but a Close button: the error is not OK, but the example does not provide a way to try to fix it either. Fixes: QTBUG-83988 Fixes: QTBUG-96574 Change-Id: I9d8c3cbe1f955cea4319982869ec9180d7c8666c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/quick/pdf/withdoc.qml21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/manual/quick/pdf/withdoc.qml b/tests/manual/quick/pdf/withdoc.qml
index 2d82a6abf..66b17994f 100644
--- a/tests/manual/quick/pdf/withdoc.qml
+++ b/tests/manual/quick/pdf/withdoc.qml
@@ -64,6 +64,7 @@ Window {
PdfDocument {
id: doc
source: "test.pdf"
+ onPasswordRequired: function() { passwordDialog.open() }
}
Platform.FileDialog {
@@ -73,6 +74,26 @@ Window {
onAccepted: doc.source = file
}
+ Dialog {
+ id: passwordDialog
+ title: "Password"
+ standardButtons: Dialog.Ok | Dialog.Cancel
+ modal: true
+ closePolicy: Popup.CloseOnEscape
+ anchors.centerIn: parent
+ width: 300
+
+ contentItem: TextField {
+ id: passwordField
+ placeholderText: qsTr("Please provide the password")
+ echoMode: TextInput.Password
+ width: parent.width
+ onAccepted: passwordDialog.accept()
+ }
+ onOpened: function() { passwordField.forceActiveFocus() }
+ onAccepted: doc.password = passwordField.text
+ }
+
PdfSelection {
id: selection
document: doc