summaryrefslogtreecommitdiffstats
path: root/examples/pdf
Commit message (Collapse)AuthorAgeFilesLines
* Correct license for examples filesLucie Gérard2024-04-093-3/+3
| | | | | | | | | | | | | Example takes precedence over build system file type. According to QUIP-18 [1], all examples file should be LicenseRef-Qt-Commercial OR BSD-3-Clause [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I558c6f409a480835d335101577ae633194b0559d Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* PDF multipage example: don't assume http by defaultShawn Rutledge2024-03-211-1/+3
| | | | | | | | | | | | | | | | Avoid doing network operations unless a network-specific scheme is given. In fact, network loading is not supported anyway, so QUrl::fromLocalFile() would be just as good for now. But perhaps we could support network loading eventually; and this approach is not harmful in the example in the meantime. You just get a "file not found" error if you give an http(s) URL on the command line. Pick-to: 6.5 6.7 Fixes: QTBUG-123548 Change-Id: I2364fd99396d4d65df92106e45818166ef2abf2f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* doc: Add docs for the pdfviewer exampleShawn Rutledge2024-01-1929-43/+107
| | | | | | | | | | | This example exists to show a simpler viewer using PdfScrollablePageView rather than PdfMultiPageView. Most users will probably prefer the latter, so we don't highlight this one. Pick-to: 6.7 Task-number: QTBUG-81560 Change-Id: Ia601b8c8ec0cb9002aa118917720a37b4f8095a5 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* PDF Quick examples: select text in search field when pressing Ctrl-FShawn Rutledge2024-01-062-2/+8
| | | | | | | | | | | | It's better for usability in case the user is doing repeated searches: press control-F and start typing to search for different text, rather than needing to do something else to select or delete the existing text in the search field. Fixes: QTBUG-120447 Pick-to: 6.2 6.5 6.6 6.7 Change-Id: I8d5a519a631c406dff91198b23a022856609fa4c Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Add PdfSearchModel.count; disable search up/down buttons if emptyShawn Rutledge2023-12-302-0/+4
| | | | | | | | | | | | | | | A crash was possible if there are no search results and the user presses the up/down buttons alongside the search field on the toolbar. That was easily fixed (in a previous patch); but actually those buttons should be disabled if there are no results to navigate. To do that, we need a notifying property rather than depending on the invokable QAIM::rowCount(). Follow the usual pattern for a one-dimensional model: add a `count` property in the subclass (as in XmlListModel, FolderListModel, CalendarModel, and a few others). Task-number: QTBUG-119776 Change-Id: I51c75b58f3a440c1c470794518a572b384376ea7 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Doc: Move PDF examples to UI Components categoryKai Köhne2023-09-271-1/+1
| | | | | | Pick-to: 6.5 6.6 6.6.0 Change-Id: Id3279026fcc791a9bd5e3e51a7ba7dd3c4a6930c Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Doc: Update example category namesKai Köhne2023-08-101-0/+1
| | | | | | | | | | | | | | | | WebEngine examples are generally added to the new 'Web Technologies' category - only Nano Browser remains also in the 'Application Examples' category. The 2 Qt PDF examples are placed in the 'Graphics & Multimedia' category. This is not ideal, but from the existing categories the arguably best matching one. Pick-to: 6.5 6.6 Task-number: QTBUG-115174 Change-Id: I3824272f62a4940f91041c8694fd2a06929863ed Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QtPDF multipage example: open the search results tab during searchShawn Rutledge2023-03-161-1/+1
| | | | | | | | | | It's unfortunate that we need to use a numeric index; but it will be ok as long as we don't rearrange tabs any more. Pick-to: 6.2 6.5 Fixes: QTBUG-106359 Change-Id: I036c45a6de7690e9ed122c74448a89da343f10d5 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QtPdf multipage example: add macOS icon; support QFileOpenEventShawn Rutledge2022-09-227-6/+88
| | | | | | | | | | | The icon uses some parts from https://openclipart.org/detail/171857/icon-pdf-a%C2%8Dcone Pick-to: 6.4 Task-number: QTBUG-106460 Change-Id: I94ecc81d83f96fdced3dce630b94b9037d3e90f9 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QtPdf multipage example: open files via DnDShawn Rutledge2022-09-211-0/+13
| | | | | | | | | Drop a different file onto the window to replace its contents with a different PDF. Pick-to: 6.4 Change-Id: I824d9f0caee69382352ab8d943b9977984db4fc9 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Polish the QML/PdfViewer exampleFriedemann Kleint2022-09-082-8/+21
| | | | | | | | | | | - Use QCommandLineParser - Use QmlEngine::setInitialProperties() instead of context properties and make "source" a required property of type url - Use startup documents from resource Pick-to: 6.4 Change-Id: Idaad82be4d7cf862de96240af031ed317a401266 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-263-3/+3
| | | | | | Task-number: QTBUG-105718 Change-Id: I2ad190e5536cdbdc8d2656e61892545d66911a02 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-073-0/+9
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I118bd63694cfe2c9a413af4a38828a31727f8e86 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Doc: Set correct install path for Qt PDF examplesTopi Reinio2022-06-301-0/+1
| | | | | | | | | | | | | These examples do not share a common root directory, so use the \meta command to set the install path in \example documentation. This fixes the 'projectPath' attributes in examples-manifest.xml and makes the examples appear in Qt Creator. Pick-to: 6.4 Task-number: QTBUG-103221 Change-Id: I141882137eabc253ba355188a1f2672ef7c402a0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-225-222/+10
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I869ffda1080e283f231eb0dc4477b260f2054d99 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Redefine PdfSearchModel.currentResult as document-based; use PdfLinkShawn Rutledge2022-06-042-15/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PdfSearchModel.currentResult is now the index within the whole list of search results, rather than starting over from 0 on each page. This simplifies some code. The way that PdfMultiPageView uses PdfSearchModel, the currentPage property is read-only: it tells the page of currentResult (which we need in the view, because each page has the ability to show a current-search-result highlight shape, but only one page actually needs to show it). The controls in a viewer to iterate search results (up and down arrows in the footer) simply increment and derement currentResult; the currentPage property gets updated to tell the view which page currently holds currentResult; and the ListView highlight follows along in the sidebar too, because ListView.currentIndex is now bound to searchModel.currentResult. But in PdfScrollablePageView, we still need to bind the currentPage property, to get the currentPageBoundingPolygons property updated when we switch pages. Since that viewer only sees one page at a time, it's much more declarative to do it that way, rather than calling the invokable boundingPolygonsOnPage(int) function. Bindings get updated on their own; whereas in PdfMultiPageView it's a bit inelegant that we need to call boundingPolygonsOnPage() repeatedly, at the right times so that the highlights are never shown in the wrong places at the wrong time. It could be avoided if we had a separate per-page model object to filter the results from the main PdfSearchModel; but that would add significant API complexity, and perhaps be too confusing for anyone who tries to re-implement a QML-based viewer component. The current search result highlight now stays on the page where the user left it: scrolling manually to another page will no longer choose a current result on the new page, as it did before. This is more consistent with typical applications. A currentResultLink property is added, to make it easy to call PdfPageNavigator.jump(link), thus passing along the QPdfLink.rectangles. The same link object gets re-emitted in the PdfPageNavigator.jumped signal to tell the view to scroll in such a way as to get those rectangles visible in the viewport, via TableView.positionViewAtCell(). There are a couple of drive-by fixes: QQuickPdfSearchModel::documentChanged() doesn't need to be declared, because we are using the signal inherited from QPdfSearchModel. And const-correctness is improved in the implementation of boundingPolygonsOnPage(). [ChangeLog][QtPDF] PdfSearchModel.currentResult is now the result index within the whole set of search results rather than on currentPage; and changing currentPage no longer makes currentResult change. In the views, this means the current highlighted search result stays on the same page even when the user views a different page. Change-Id: I96957f50e703f62101b3d3c708ff5f27b162cd8d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Give QPdfPageNavigator::jump() a default value for zoomShawn Rutledge2022-06-041-1/+1
| | | | | | | | If the caller doesn't want to change it, it's easier to omit it rather than remembering that 0 is a special value. Change-Id: I851f678941e5144a9dea306fddba59fd15ed9939 Reviewed-by: Doris Verria <doris.verria@qt.io>
* Add QPdfDocument::pageLabel(int) and pageModel propertyShawn Rutledge2022-06-041-6/+7
| | | | | | | | | | | This API is available for both C++ and QML. The pageModel makes it easier to populate item-views with per-page information, such as thumbnails labeled with page labels. Fixes: QTBUG-102271 Change-Id: I70df481b378efed0327e7bb89a63c7669daecc70 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Renumber pages in test.pdfShawn Rutledge2022-05-312-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | Give them unique labels. This was done with pdftk: $ pdftk resources/test.pdf update_info_utf8 update output test.pdf where the file "update" contains PageLabelBegin PageLabelNewIndex: 1 PageLabelStart: 1 PageLabelPrefix: Qt PageLabelNumStyle: NoNumber PageLabelBegin PageLabelNewIndex: 2 PageLabelStart: 1 PageLabelNumStyle: DecimalArabicNumerals PageLabelBegin PageLabelNewIndex: 3 PageLabelStart: 1 PageLabelNumStyle: LowercaseRomanNumerals The instructions to do this came from https://emacs.stackexchange.com/questions/58315/edit-pdf-page-labels-in-pdf-tools Task-number: QTBUG-102271 Change-Id: I97df7ca538690baf3329fcbef371dcd92c4d8966 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Remove PdfPageView.currentPage propertyShawn Rutledge2022-05-311-1/+1
| | | | | | | It was just an alias for currentFrame. Change-Id: Ib16f579b1905cf5fe43496553ebde054d474a7c7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* PDF multipage example: add footer button to hide/show the sidebarShawn Rutledge2022-04-305-0/+42
| | | | | | | | | | | | | When the sidebar only held search results, it was enough to show it when pressing enter on the search field; but now it holds two other views that the user will want to easily look at. It's a Drawer, and those are tricky to open and close by mouse-dragging. The button is more obvious, like the one at the bottom of Creator. Its checked state shows whether the sidebar is open, and clicking it opens the sidebar if it wasn't already open. Clicking outside the sidebar closes it. Change-Id: Ib4e403aa6f06d5e4dbad08a80c99496ab6c5fa0f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* PDF multipage example: add sidebar metadata paneShawn Rutledge2022-04-301-1/+30
| | | | | Change-Id: I33a365a1591565bc2a95c6ae62382c71c7e1850b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* PDF example and manual test: add GridView for thumbnailsShawn Rutledge2022-04-291-13/+61
| | | | | | | | | Change the PdfDocument's id to doc, because in the GridView delegate, PdfPageImage { document: document } causes trouble (even though the same sort of binding was ok elsewhere). Change-Id: I9eafd818c25a31bef50b0b7fba36449c1dcf884a Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* PDF MultiPageView example: add bookmarks tree to sidebarShawn Rutledge2022-04-241-44/+85
| | | | | | | | | | | | | | | The Drawer is now not only for search results, but has a sideways TabBar just like the widget example has; and now it can show search results and bookmarks (table of contents) on different tabs. (Perhaps TabBar was not meant to be rotated, but it seems to work in the styles I've tried so far.) Clicking a bookmark takes you to that page, location and zoom. Followup to 303c25e79ab12d5d48523aa890f2091e98d3b560 which added this feature to a manual test. Task-number: QTBUG-77510 Change-Id: I235ff14c9f6597eb8282ef1d73112b023a61ef8a Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* doc: Add Qt Quick details to the Qt PDF module page; clarify examplesShawn Rutledge2022-04-171-1/+1
| | | | | | | | | The module is more about Qt Quick than about widgets nowadays. Also clarify on the Qt PDF Examples page that one example uses widgets and the other uses Qt Quick. Change-Id: I38a77a4290f9489ef17bf66fe3a0f69be9bd0e88 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* doc: begin adding docs for MultiPageView component and exampleShawn Rutledge2022-04-072-1/+80
| | | | | | | Pick-to: 6.3 Task-number: QTBUG-81560 Change-Id: I062e022a97c146e9a746b6d6358868bfe0c0a7d7 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* multipage PDF viewer example: simplify, and fix more qmllint warningsShawn Rutledge2022-03-101-15/+13
| | | | | | | | | | - 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>
* QtQuick.Pdf: automatically close the error dialog if the error disappearsShawn Rutledge2022-03-082-2/+2
| | | | | | | | | | | When the user has not yet entered a password, document.status == Error; but we pop up the password prompt dialog on top of the error dialog. After the user has entered it, either it's correct and the error goes away, or we need to tell the user that it's incorrect, so the dialog should stay open. Change-Id: Ib3332f543b23fdf50ccd0df0c7e79cdc95f2e8da Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* PDF viewer and manual test: support password-protected documentsShawn Rutledge2022-03-072-9/+28
| | | | | | | | | | | | | | | 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>
* Improve examples CMakeLists.txtKai Köhne2022-02-252-14/+8
| | | | | | | | | | | | | | | | | - Remove "# generated from xyz.pro" comment from pro2cmake - Remove automatic use of CMAKE_AUTORCC - Only opt into CMAKE_AUTOUIC if .ui files are involved - Remove explicit setting of CMAKE_INCLUDE_CURRENT_DIR - Combine multiple find_package(Qt6 ... calls) - use REQUIRED COMPONENTS - sort components alphabetically - Fix wrong indentations - Use (only) one empty line after multi-line commands Pick-to: 6.3 Change-Id: I09083474432ce171e8ee1e28120b062f2ef3c052 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtPdf: fix qml issuesShawn Rutledge2022-02-222-11/+10
| | | | | | | | | | | | | - required properties - unused imports - nullish coalescing - issues found by qmllint (despite all the noise) Reverts 99db09404787901647213abceda74befc7efa8f1 Task-number: QTBUG-82873 Change-Id: I0042d2eaeacba58adcf280c37b9668f8d76d0f93 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* PDF viewer examples: use QtQuick.Dialogs FileDialogShawn Rutledge2022-01-112-6/+6
| | | | | | | | | Qt.labs.platform is becoming obsolete, and creates a widgets dependency. QtQuick.Dialogs uses platform dialogs when available. Pick-to: 6.2 6.3 Change-Id: I9b608e28cc7b9a99d0aaeec2aa24fee9d569dfe8 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Switch examples to build as isolated sub-buildsAlexandru Croitor2021-12-151-2/+2
| | | | | | | Pick-to: 6.2 6.3 Task-number: QTBUG-90820 Change-Id: I8539fee3ea7311acf9ee4e736fb19e6ff595fcae Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Minor. Cleanup qt6_add_resources usageMichal Klocek2021-10-282-2/+2
| | | | | | | | We should not use qt6 prefixed functions in examples. Pick-to: 6.2 Change-Id: Ibf2618ef4f64b560decb219527d619aad680f216 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Add QtPdf to cmake buildMichal Klocek2021-08-175-47/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Port QtPdf to Qt6: * QtPdf,QtPdfWidgets,QtPdfQuick libs * QtPdfQuickPlugin, QtPdfPlugin (imageformat) plugins * widget and quick examples * qtpdf tests To fit gn cmake integration and new repo layout code is a bit reshuffled. Compared to qmke build following features are not ported yet: * ios fat libs * qtbase 3rdparty static dependencies WebEngine build can be skipped with setting QT_FEATURE_qtwebengine_build=OFF Note this patch needs follow up for 6.2 branch to disable qtpdf builds by default, since this should not part of qt 6.2 release. Pick-to: 6.2 Task-number: QTBUG-95353 Change-Id: I4dd9f3934bdd478fb6d2fa686074a24d91f09953 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix some compiler warningsPeter Varga2021-06-102-2/+0
| | | | | | | | | | | | | - Remove deprecated Qt::AA_EnableHighDpiScaling and Qt::AA_UseHighDpiPixmaps from examples. High-DPI scaling is always enabled. - Reorder initialization of members of QWebEngineDownloadRequestPrivate. Also remove m_ prefix from public members' name. - Remove unused parameters from methods of DummyDelegate. - Add missing overrides in auto tests. Pick-to: 6.2 Change-Id: I18d6973b8bee574b37b73fbaaa8d57002ac8ba2d Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Compile pdf examplesMichal Klocek2020-10-065-7/+7
| | | | | | | | Fix typo in examples.pro and update related pro files. Drop dependency on widgets in qml examples. Change-Id: I571069e5b42cc0d0d94d54ce157a6e8636275cae Reviewed-by: Michael Brüning <michael.bruning@qt.io>
* Support text selection handles in PDF viewsShawn Rutledge2020-04-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Testing only on iOS so far; QtPdf doesn't work on Android because of QTBUG-83459, so we can only hope that this might perhaps be cross-platform, if only text selection handles actually existed on all platforms. As usual, text selection begins with a long-press; the iOS platform plugin intercepts that, and we get QInputMethodEvent::Cursor. There is no cursor, but we use the opportunity to do hit-testing, because the Cursor event is the only way that we receive the pixel location where the user is interacting. Then a popover menu appears, which contains Select and Select All, and either Copy or Paste depending on the qt_im_readonly property workaround. You don't get handles until you choose Select, which will select a word. That makes the popover menu disappear. You can use the toolbar button to copy to the clipboard. After that, you can drag either handle. inputMethodQuery(query, argument) is only ever called with ImCursorPosition regardless which handle is being dragged, so it doesn't make sense to change the selection there, even though that would be easy if we were given that information. Instead, the iOS platform figures out the character range for itself and sends a QInputMethodEvent::Selection event to tell us which text to select. And yet it still doesn't move the handles without being told: QGuiApplication::inputMethod()->update(Qt::ImCursorRectangle | Qt::ImAnchorRectangle) makes that happen. Then the popover menu will appear again, and now you can use the Copy function on it as an alternative way to copy text to the clipboard. By default, when the user does the initial long-press to start selecting text, the popover menu has Select, Select All, and Paste. In editable controls there is a second possible menu that normally has Cut, Copy, Paste and Delete. We are not able to enter that mode. So as a workaround, to substitute Copy instead of Paste, we set the qt_im_readonly property so that QIOSTextResponder::canPerformAction() can detect it and make the substition. Of course that won't work without the patch to 5.15; so you still get a useless Paste action on earlier Qt versions. Selecting a word via the Select popover menu item happens because iOS sends QKeySequence::MoveToPreviousWord and then QKeySequence::SelectNextWord. We spend time calling getSelectionAtIndex() twice because of that. With an actual keyboard, it should be possible to use keystrokes to extend the selection, but it doesn't seem to work yet with shift-arrows on a physical bluetooth keyboard on iOS. Select All on the popover menu works via inputMethodEvent() with attr QInputMethodEvent::Selection. Copy sends the standard copy key sequence, so keyReleaseEvent() handles it. We must rename the geometryChanged signal to selectedAreaChanged now that we're inheriting from QQuickItem, to avoid shadowing QQuickItem::geometryChanged. For this kind of text selection to work even when the rendering is scaled, it became necessary to inform PdfSelection of the rendering scale; so a renderScale property is added. Thus it is sensible (and a nice simplification in QML code) to use it for the fromPoint and toPoint properties, such that those are now expressed in pixels rather than points. Fixes: QTBUG-82441 Task-number: QTBUG-83811 Change-Id: I16ecd2db55c6a834be6139ce4f3aae23446fed54 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix PgUp/PgDown navigation in the PDF multi-page exampleShawn Rutledge2020-04-161-2/+2
| | | | | | | | | SpinBox.valueModified is emitted only when the user interactively modifies the value; so SpinBox.value++ doesn't trigger view.goToPage(). Therefore we should call it explicitly when handling those key shortcuts. Change-Id: I9648d1d143812d34d77218fd9ed7559415d13f63 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Workaround for failing import QtQml in PDF views on iOSShawn Rutledge2020-03-162-0/+2
| | | | | | | | | The QtQml import isn't working in any QML dependencies unless it's detected because of having been included in the main QML file. Task-number: QTBUG-82873 Change-Id: I2ed2ca439651c40089d667255effb1155af58a01 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* PdfSelection: add selectAll() function; use in examplesShawn Rutledge2020-03-116-0/+42
| | | | | | | | The usual shortcut (control-A) now selects all text on the current page, it is highlighted, and it can be copied to the clipboard. Change-Id: I5e6d9cae675862808f8b9027cb47024ca65cf2fd Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PDF single-page example: shift content right as the search drawer opensShawn Rutledge2020-02-261-0/+1
| | | | | | | | This was done in 0b6a4d94945a975390b2574e6aff2568ebb7f061 for the multipage example. Change-Id: Ia5b51b9239521ab4d65e41aaebe52d178e75932d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PdfSearchModel: provide ContextBefore and ContextAfterShawn Rutledge2020-02-262-2/+50
| | | | | | | | | | | | | | ...as separate roles, to make alignment easier, and to avoid hard-coding HTML tags in the Context role as it was before. But the strings in these context roles are not always adjacent to the search results in geometric coordinates sometimes, in some PDF files, despite having adjacent character indices. I.e. the "next" character after the search string, or the "previous" character before it, could be anywhere on the page. Change-Id: Ief0a490b64fdb3c3ca98506926650648b609ece1 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PDF single-page example: move search field to the footerShawn Rutledge2020-02-201-71/+71
| | | | | | | | As with a2be3a7a79dc4fabe8675ea80a6ba550e0e4deec, this makes the search feature more discoverable and touch-friendly. Change-Id: I47e37273c583121d60985cc27c22f56e6d655ab0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add PdfScrollablePageView, use it in the pdfviewer exampleShawn Rutledge2020-02-201-45/+30
| | | | | | | | | PdfPageView might be useful in some cases, but we need to get feature parity with PdfMultiPageView as much as possible, including scrollbars. Including them in the view is convenient, but also less flexible. Change-Id: Ibbe6a090a5f5b1d340124986fe49672d682ddedb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PdfMultiPageView: use TableView; horz. scroll; control page positionShawn Rutledge2020-02-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | TableView is missing some features compared to ListView; so finding out where we currently are (which row) and programmatic positioning on a specific y coordinate of a specific row require some workarounds for now, including helpers in PdfDocument. TableView also assumes (and sporadically enforces) that all cells in a column have the same width. So we need a placeholder Item for each page. This also helps with rotation: the placeholder is now as wide as the window or the image, whichever is wider, and the "paper" is centered within; thus there's always room to rotate it. There's still some problem with setting contentY in goToPage() after the page has been zoomed to a size larger than the window: the values look correct, but it scrolls too far. But on the plus side, horizontal scrolling works. So now we attempt to control the horizontal position too: NavigationStack tracks it, and can go back to a previous position; and links can in theory jump to specific positions and zoom levels, scrolling horizontally such that a specific x coordinate is visible. Includes minor UI tweaks to make it look better on iOS. Change-Id: I643d8ef48ef815aeb49cae77dcb84c3682563d56 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QtPdf examples: use test.pdf from resources if no file givenShawn Rutledge2020-02-1910-6/+15
| | | | | | | | | | | | | | | | | | On iOS, the native FileDialog doesn't work, sharing doesn't work, and packaging files along with the application requires manual effort; so a PDF file in resources seems to be the easiest alternative to make the examples demo-able. QPdfDocument wants a file path, because it uses QFile; but we like to use URLs in Qt Quick. So it's a bit of an impedance mismatch, there are several choices about when and where to do the conversion, and it's hard to say which way is more correct. This way happens to work for now. Also do the rest of the things necessary to get this working on iOS. Change-Id: Icb8614d5eed2510f101aefba534ef80cf890518f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PDF multipage example: move search field to the footerShawn Rutledge2020-02-191-76/+69
| | | | | | | | | | | | | | | | Hiding the search feature in a closed Drawer might not have been sufficiently touch-friendly and discoverable, for example on iOS where the user is not going to press control-F to start searching. But the top toolbar is too full to put the search field back up there. It's familiar from Firefox to have the search field at the bottom, and we have enough space for it there. So now you can search and jump around the search results without opening the drawer; but pressing Enter in the search field opens the drawer. Hopefully swiping to open the drawer is also convenient enough on touch platforms; otherwise we could add another button for that, perhaps at the left of the footer. Change-Id: Iaec63bc22b03e29156fee817d197daae5b0cf9d5 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Enable mouse wheel scrolling in single-page PdfPageViewShawn Rutledge2020-02-171-0/+16
| | | | | Change-Id: I20512187dcc872b2e0429968e9ad2a9899aee6c2 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Rearrange PdfPageView.qmlShawn Rutledge2020-02-172-8/+7
| | | | | | | | | | | | Now it looks more similar to PdfMultiPageView.qml: public properties and functions are grouped by functionality, implementation details are "below the fold", and properties and functions that we don't want to expose as API are nested inside inner items. Also fixed ColumnLayout attached properties. Change-Id: Iafe6f983a34ca6bac9b0d4f3a26aba5a426e0232 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>