diff options
-rw-r--r-- | examples/pdf/multipage/viewer.qml | 12 | ||||
-rw-r--r-- | examples/pdf/pdfviewer/viewer.qml | 25 | ||||
-rw-r--r-- | tests/manual/quick/pdf/withdoc.qml | 21 |
3 files changed, 49 insertions, 9 deletions
diff --git a/examples/pdf/multipage/viewer.qml b/examples/pdf/multipage/viewer.qml index f0eb4a432..51b648378 100644 --- a/examples/pdf/multipage/viewer.qml +++ b/examples/pdf/multipage/viewer.qml @@ -199,26 +199,27 @@ ApplicationWindow { anchors.centerIn: parent width: 300 - TextField { + contentItem: TextField { id: passwordField placeholderText: qsTr("Please provide the password") echoMode: TextInput.Password width: parent.width onAccepted: passwordDialog.accept() } + onOpened: function() { passwordField.forceActiveFocus() } onAccepted: document.password = passwordField.text } Dialog { id: errorDialog title: "Error loading " + document.source - standardButtons: Dialog.Ok + standardButtons: Dialog.Close modal: true closePolicy: Popup.CloseOnEscape anchors.centerIn: parent width: 300 - Label { + contentItem: Label { id: errorField text: document.error } @@ -231,10 +232,7 @@ ApplicationWindow { if (status === PdfDocument.Error) errorDialog.open() view.document = (status === PdfDocument.Ready ? document : null) } - onPasswordRequired: { - passwordDialog.open() - passwordField.forceActiveFocus() - } + onPasswordRequired: function() { passwordDialog.open() } } PdfMultiPageView { diff --git a/examples/pdf/pdfviewer/viewer.qml b/examples/pdf/pdfviewer/viewer.qml index c174a79ed..0454d533f 100644 --- a/examples/pdf/pdfviewer/viewer.qml +++ b/examples/pdf/pdfviewer/viewer.qml @@ -193,15 +193,35 @@ ApplicationWindow { } 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: document.password = passwordField.text + } + + Dialog { id: errorDialog title: "Error loading " + document.source - standardButtons: Dialog.Ok + standardButtons: Dialog.Close modal: true closePolicy: Popup.CloseOnEscape anchors.centerIn: parent width: 300 - Label { + contentItem: Label { id: errorField text: document.error } @@ -215,6 +235,7 @@ ApplicationWindow { id: document source: Qt.resolvedUrl(root.source) onStatusChanged: if (status === PdfDocument.Error) errorDialog.open() + onPasswordRequired: passwordDialog.open() } searchString: searchField.text } 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 |