summaryrefslogtreecommitdiffstats
path: root/src/pdfquick/qquickpdfdocument.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Warn when PdfDocument.source can't be opened; add note to docsShawn Rutledge2025-02-181-1/+10
| | | | | | | | | | | | | | | | When PdfDocument is instantiated in some QML file that comes from application resources, it can be surprising when giving a plain file path to the source property that it tries to resolve it as a resource URL instead of a filesystem URL. But this behavior is consistent with how we handle URLs in other components, such as Image; and Image also generates a QML warning if the file cannot be found. Followup to 3159ac9ff7edf0eea93fa8331ea6cb8abc201ca2 Pick-to: 6.8 6.9 Fixes: QTBUG-131841 Change-Id: I8fb66b321406e14c88ff1eb253d46742c0c99b5a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QPdfFile: allow Qt Quick to change thread affinity to its own rendererShawn Rutledge2024-12-051-2/+7
| | | | | | | | | | | | | The thread that calls QQuickPixmapReader::processJob() pulls out the QPdfFile pointer, passes it to readImage() and expects that it will not become a dangling pointer while readImage() is busy. So it needs to call moveToThread() to "pull" the affinity to itself; and that's only possible if it is set to null in the same thread that initially has affinity. Task-number: QTBUG-128875 Change-Id: Id54803783f353631f97c7676c90d5b0fbe09f4eb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Doc: Replace \instantiates with \nativetypePaul Wicking2024-08-201-1/+1
| | | | | | | | | | | Since the implementation of the `\nativetype`-command in QDoc, the `\instantiates`-command is deprecated. Replace the use of the deprecated command in favor of its replacement. Pick-to: 6.8 Task-number: QTBUG-128216 Change-Id: I10cad9942e34301ded99c7014c1c70375e0698e1 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Fix for crash in tst_multipageviewAnu Aliyas2023-12-191-1/+2
| | | | | | Fixes: QTBUG-120245 Change-Id: If79f4bef1d6b42e2df3537482613d977c86d90dd Reviewed-by: Michael Brüning <michael.bruning@qt.io>
* QtPdf: Fix memory leaksShawn Rutledge2023-08-291-1/+4
| | | | | | | | | | | | | | | | | | In QPdfBookmarkModelPrivate::appendChildNode it was not necessary to call FPDF_LoadPage() just to be able to call FPDF_GetPageHeight(): the BookmarkModel has the QPdfDocument which can do that for it, using FPDF_GetPageSizeByIndex() instead. 7b8832ca2b84d549c9d374550c3c46b3d4d42a38 added QQuickPdfDocument::carrierFile() returning a pointer that QQuickPdfDocument continues to own. QQuickPdfDocument::setSource() took care of deleting the existing one if we open a different document, but the destructor did not delete it. Pick-to: 6.2 6.5 6.6 Task-number: QTBUG-114953 Change-Id: Ie8d9cea456cb91d9541deb575dac17db0d367ead Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QtPdf: Support more schemas when loading documents with qmlMichal Klocek2023-03-201-4/+2
| | | | | | | | | | This is follow up after efbb12954cf6e58, use same handling as for reloading on password change. Pick-to: 6.5 Fixes: QTBUG-87275 Change-Id: I1046f57f61346a2cbc03f50ca453209a855ea561 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix not working password test for QPdfQuickMichal Klocek2023-03-021-3/+4
| | | | | | | | | | | | | In qml url can have different schemas like 'qrc' 'file' 'assets'. Make correct conversion so file can be loaded. Note check isLocalFile() is not true for qrc scheme. Fixes: QTBUG-106072 Pick-to: 6.5.0 6.5 6.4 Change-Id: I4dcc969e4c6d9b3f58ea5d81d20d8e81b55edfde Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-221-38/+2
| | | | | | | | | | | 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>
* Rename QPdfDocument::pageSize() to QPdfDocument::pagePointSize()Shawn Rutledge2022-05-311-5/+1
| | | | | | | | It is in fact the size in points (1/72 of an inch), so we might as well be consistent about the naming between QML and C++ APIs. Change-Id: I8f8b05eeecc635a4d105558959834ae0e15add81 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Include moc filesAllan Sandfeld Jensen2022-05-311-0/+2
| | | | | | | | Faster to build and gives smaller binaries Fixes: QTBUG-103291 Change-Id: Iab52995e03c13a4c5b185750028c449a19d98d93 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QPdfDocument: use enum classesShawn Rutledge2022-05-241-9/+9
| | | | | Change-Id: Iad3f8da130abe86a464d63323920a2a39d6fa955 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* PdfQuick: deal with loading a different documentShawn Rutledge2022-04-121-1/+3
| | | | | | | | | When loading a new document, clear the navigation stack, reset the view to the upper-left corner, and clear the special device in PdfPageImage. Task-number: QTBUG-102294 Change-Id: I275b46f8958d4e8abe3814c1f358df5969c36d4d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Use QML_EXTENDED to "inherit" QPdfDocument props, enums and signalsShawn Rutledge2022-04-061-28/+29
| | | | | | | | | | | | | | | | | | | | | In QML we want to treat the status values like Error and Ready as if the enum were declared in QQuickPdfDocument, even though it's really from the non-QML type QPdfDocument. This is needed because QQuickPdfDocument doesn't inherit QPdfDocument (9968e2578f96081d2a242340620fcb2b96d9a1d3 could've done direct inheritance, but we sometimes value separation of QML API from C++ API). So we now de-duplicate other properties and signals too. It's as if from QML's perspective, PdfDocument inherits everything from QPdfDocument (including the properties pageCount, password and status), although in C++ it's not like that. Make all properties FINAL because we don't expect anybody to subclass QQuickPdfDocument. Fixes: QTBUG-100839 Change-Id: Idbb0d620443020d7168cba8f090d1f344a9b3296 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* doc: PdfDocument qmlproperty type correctionsShawn Rutledge2022-03-161-3/+3
| | | | | | Pick-to: 6.3 Change-Id: Id2c880a73f9524749fa256a15cc3e05a6b26ee39 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove PdfDocument::heightSumBeforePageShawn Rutledge2022-03-161-26/+0
| | | | | | | | | It was a workaround for missing features in Qt 5's TableView, but it's no longer needed now. Pick-to: 6.3 Change-Id: I7318c0be83a2189bd594066e36b66a5dc09a0f20 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Add QQuickPdfPageImage and use in the PDF viewer componentsShawn Rutledge2022-03-031-0/+13
| | | | | | | | | | | | | | | | | | | | | | | Image works fine, except that if QPdfIOHandler is not given an already-allocated QPdfDocument instance, it needs to construct its own. So we now have QPdfFile: a subclass of QFile acting as a wrapper, to carry the document instance (that the user has most likely declared) down into QPdfIOHandler::load(QIODevice *). Thus, in nontrivial PDF-viewing use cases, there is now usually only one multi-purpose document instance. And this takes care of viewing password-protected PDFs in the multipage example, because we already prompt for it and set the document.password property. In trivial use cases, it's OK to continue using Image, and QPdfIOHandler will still construct its own QPdfDocument instance if the QIODevice cannot be cast to a QPdfFile. Task-number: QTBUG-77506 Task-number: QTBUG-83988 Task-number: QTBUG-96574 Change-Id: I3adfa54c30b0baa5dedebcf3bc759758f136b757 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* PdfDocument: resolve the source URLShawn Rutledge2022-02-101-7/+10
| | | | | | | | | | | | | Similar to qtdeclarative 0a1e4cc7ec7548f6273befff9cdddb0bc7a58961 except here, setting the source calls QPdfDocument::load() immediately, so we need to resolve the URL right before doing that. The results are visible in most of the manual tests: they again load test.pdf immediately, as in Qt 5. Pick-to: 6.3 Change-Id: I8c67a9e1c72ac390c24d72d5e229ff0ef9f4aa0d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Make dtors out-of-lineMarc Mutz2021-12-071-0/+5
| | | | | | | | | | | Pins vtable to a single TU, instead of duplicating it across all TUs that use the class, possibly causing invalid dynamic_cast<>s and other bugs. Fixes: QTBUG-98880 Task-number: QTBUG-45582 Change-Id: Ic296f4583097181ac4d824fac6dab4671ae14a50 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use up-to date LGPL license headerKai Köhne2021-12-021-11/+14
| | | | | | | | Remove usages of outdated LGPL3 header that references LICENSES.LGPLv3 instead of LICENSES.LGPL3. For the examples, use BSD. Change-Id: I1fae49110160c1183327ec54c9dc447c69588a65 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QQuickPdfDocument: fix -Werror=deprecatedMarc Mutz2021-11-221-1/+1
| | | | | | | | | C++20 deprecates [=]'s implicit capture of this, but [this] is sufficient, anyway. Pick-to: 6.2 Change-Id: I0e962d62b672883495da05abce12d7ea2f2b1020 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Doc: Fix qdoc warnings and enable zero warning limitVenugopal Shivashankar2021-11-151-2/+2
| | | | | Change-Id: Ifa2914e7bca9c224670a1891785d0ba8262cd61b Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Add QtPdf to cmake buildMichal Klocek2021-08-171-0/+305
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>