summaryrefslogtreecommitdiffstats
path: root/examples/pdfwidgets/pdfviewer/mainwindow.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix static logging category deprecation warningsKaloyan Chehlarski2024-08-271-0/+4
| | | | | | | | | | | | | | | | | | | | | This is a second attempt at getting rid of the deprecation warnings caused by the new logging category macros in 6.9. These cause build failures on warnings-as-errors configurations, and need to be fixed properly without affecting backwards compatibility. The change introduces a new Q_WEBENGINE_LOGGING_CATEGORY macro, intended to be used across the WebEngine sources. The macro is not exported to users, so the QtPdf example that declares its own logging category uses an #ifdef instead. The new macro is placed in its own header inside src/core/, and is intended to be removed whenever the next LTS release allows us to break compatibility with 6.8, and just directly use Q_STATIC_LOGGING_CATEGORY everywhere. Fixes: QTBUG-127975 Change-Id: I9174dab21bd597c862e569e170161782cc108ece Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Revert "Use static logging categories everywhere"Kaloyan Chehlarski2024-07-251-1/+1
| | | | | | | | | | | | This reverts commit bd6e209152d042a08fc226a9e92ee1c04cf1954a. The change broke backwards compatibility with 6.8, because the relevant macros were introduced after the feature freeze, and are thus not part of the 6.8 release. This revert fixes the impeding backwards incompatibility whenever WebEngine 6.9 is released. Change-Id: I4626c4fe2647a5eb2a0729696cb80db6a47569a7 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix compiler warnings in tests and examplesPeter Varga2024-07-181-2/+5
| | | | | | Pick-to: 6.8 Change-Id: If371441d9b0d93fbd7a3e3e37e4f3780ddb52eb0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Use static logging categories everywhereKaloyan Chehlarski2024-07-021-1/+1
| | | | | | | | | | | | Following fa4bd30caa079a3b1e5eac1bb4f17365f456b8f9 all usage of the Q_LOGGING_CATEGORY macro triggers a deprecation warning, and may even block certain build configurations. This change replaces all usages of the macro with Q_STATIC_LOGGING_CATEGORY instead, since none of the logging categories in WebEngine are meant to be exported to users. Change-Id: Icdebb7a3a8c987db3f34945cd0311aee52667a88 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
* QPdfPageSelector: port from is-a to has-a QSpinBoxMarc Mutz2023-08-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Yes, the class needs to inherit from QSpinBox in order to override the protected virtuals, but that doesn't mean a QPdfPageSelector should model is-a QSpinBox. E.g. the range of the QPdfPageSelector is taken from the QPdfDocument, and no good can come from a user changing it through the use of QSpinBox API, esp. if one thinks about the class being displayed as a native widget in QtDesigner. In a similar vein, the inheritance from QSpinBox leaves users wondering (and the docs didn't do anything to enlighten them) what properties are pertinent to the task at hand. setValue() to set the page index is ... meh, but still somewhat discoverable. But that text() is only QPdfDocument::pageLabel() if no affixes are set takes quite some digging. Part of this could be fixed by providing domain-specific properties like currentPage for value, but that would just increase the confusion, because those two properties would must needs exist on the same object. Instead, fix by moving the old QPdfPageSelector as QPdfPageSelectorSpinBox into qpdfpageselector_p.h, removing its pimpl and having QPdfPageSelector inherit QWidget instead, aggregating a QPdfPageSelectorSpinBox. This involves a few more objects (the widget, the layout), but gives QPdfPageSelector full control over its interface. Add a few salient properties (more can be added if needed, by copying them from QSpinBox or QAbstractSpinBox). Note how well the new API rhymes with QPdfPageNavigator in the connect() in pdfviewer example's MainWindow. Since we still store everything in QPdfPageSelectorSpinBox, but don't pimpl it anymore, QPdfPageSelectorPrivate can lose the q_ptr now, and merely contains the pointer to its QPdfPageSelectorSpinBox. This could be optimized further, by making QPdfPageSelectorSpinBox and QPdfPageSelectorPrivate the same class, but that's neither BC- nor SC-relevant anymore, and can be done later (or never, seeing as this widget is unlikely to be used more than a few times per application). Found in API-review. As a drive-by, port to the std-compatible subset of the QPointer API. Pick-to: 6.6 Change-Id: I0d82d098d38d5f2fcf7f1c8c9aed6e792a8deb2d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Rename QPdfView::currentSearchResult() -> currentSearchResultIndex()Shawn Rutledge2023-08-021-1/+1
| | | | | | | | | | | | I don't think it was very confusing, but just in case we could want a currentSearchResult() returning the actual result object at some point. It was a suggestion from header review. Amends 288e9be6ba2be40761333036f3397298df5e1018 Pick-to: 6.6 Change-Id: Ie3eb500e3a79b80b8abafbe19c48b57c7e9d71be Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add search feature to PDF widget exampleShawn Rutledge2023-03-171-0/+51
| | | | | | | | | Task-number: QTBUG-16211 Task-number: QTBUG-77507 Fixes: QTBUG-92973 Change-Id: I650bed9392e5e098e46368c60fb7c5dbebde666f Reviewed-by: <irfan.omair@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Support DecorationRole for icons in QPdfDocument::pageModelShawn Rutledge2023-02-161-1/+7
| | | | | | | | ...and begin rendering thumbnails in the widget-based example by adding a QListView in IconMode. Change-Id: Ia0f446e48ce868e27cd7d64a3712a7db1b1e618b Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Add QPdfPageSelectorShawn Rutledge2023-02-161-7/+10
| | | | | | | | | | | | | | | | | | This is a QSpinBox subclass that shows PDF page "labels" rather than a 1-based or 0-based page index. If a book starts with Roman numerals in the preface, and then page 1 is the first page of Chapter 1, the spinbox should be in sync with the page numbers as printed on the pages, and with the labels that will eventually be shown under the thumbnails on the Pages sidebar tab. On the other hand, the user probably needs to see the 1-based page index somewhere, at least to be able to make sense of the print dialog, because there the range of pages to print will be 1-based. So we put the page index into the title bar: title, page label, index, count. Task-number: QTBUG-102271 Change-Id: Ic461094ba4caae3067409f7f436bd4e7504a4bdb Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Polish the PdfWidgets/PdfViewer exampleFriedemann Kleint2022-09-071-6/+17
| | | | | | | | | | - Use QCommandLineParser - Fix up QFileDialog handling - Small fixes Pick-to: 6.4 6.3 Change-Id: I0cbe30a0fb5c856805956970407aa526d1d93fa4 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-221-49/+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 QPdfNavigationStack to QPdfPageNavigator; QML type tooShawn Rutledge2022-05-271-11/+11
| | | | | | | | | | | | | | | | | This might reduce some confusion about the fact that the back/forward "stack" isn't strictly a stack in the data structure sense: it's more like QUndoStack. It causes a QML source incompatibility relative to Qt 5, but keeps the C++ class name the same as it has been in QtPdf for a long time. Amends 3ad445f9f24a9d3f259ed1781460a63346a728e4 [ChangeLog][QtPDF] The PdfNavigationStack QML type has been renamed to PdfPageNavigator, matching the C++ type QPdfPageNavigator. These remember navigation history within a document, and are helpful to implement back/forward buttons similar to those on a web browser in both Qt Quick and widget-based viewer applications. Change-Id: Id8dc17aa416bb7064b1f0f300a47c07c83b7f47e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QPdfView: replace enums with enum classesShawn Rutledge2022-05-241-1/+3
| | | | | | | [ChangeLog][QtPDF] All enums are replaced with enum classes. Change-Id: I41063de084a23db657a24805ceaf22881f25c990 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QPdfDocument: use enum classesShawn Rutledge2022-05-241-1/+1
| | | | | Change-Id: Iad3f8da130abe86a464d63323920a2a39d6fa955 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Turn QPdfBookmarkModel::Role into an enum classShawn Rutledge2022-04-221-2/+2
| | | | | | | | | - link, search and bookmark models have similar role names now - being an enum class allows the role name to be shorter - the Role enum name is the same as the name in roleNames(), lowercased Change-Id: I2e710d7acb8479995d82ef2d324807b6cd4e10e5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Move QQuickPdfNavStack core into QPdfNavigationStack; use in QPdfViewShawn Rutledge2022-04-081-10/+33
| | | | | | | | | | | | | | | QQuickPdfNavigationStack was implemented independently until now, but users will need the same functionality in widget-based PDF viewers. QPdfPageNavigation on the other hand may have eventually had the same aspiration, but was just a glorified up/down counter thus far, with questionable API; so we get rid of it, and make the API for page navigation as much the same as possible between Quick and Widgets. We rename push() to jump() along with removing the emitJumped argument. Now jump() always emits (so we have to be more careful when to call it). Change-Id: Icb07158a351e29b81e58ec037cd323bc0f54a1a1 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Use up-to date LGPL license headerKai Köhne2021-12-021-18/+32
| | | | | | | | 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>
* Port pdfviewer example to QPdfView widgetTobias Koenig2019-11-251-58/+30
| | | | | Change-Id: Id651a2c179628506f0955751abda57cbae569ee9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add bookmarks view to pdfviewer exampleTobias Koenig2019-11-251-0/+18
| | | | | | | | Add a treeview to the pdfviewer example to show the usage of QPdfBookmarkModel Change-Id: Ia93d868655a74ea6c41bb28945fe16d0cc740410 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Improve the PDF viewer example aestheticsJake Petroules2019-11-251-0/+2
| | | | | | | | | | | Sets the window title as the title of the PDF document, enlarges the default window size, uses unified toolbars on macOS, extends the viewer area to the edges of the containing window, and removes the Windows 95 style shrunken frame around the PDF viewer. Change-Id: I38753a2b5492ac0cc0d2a11ae62011ac595a0e70 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
* install the pdfviewer example; provide examples subdirs .pro filesShawn Rutledge2019-11-251-0/+170
Actually moving the files is unfortunately necessary because of a rule about having the source directory structure match the intended installation directory structure. It was intended to differentiate widget examples from future QtQuick examples, but now that distiction is being unfortunately lost in order to keep the directory structure as shallow as it can still be, after having to comply with the first rule. Change-Id: I831227d2be3c8f5cab55a98a531e16bcb3aa0303 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>