summaryrefslogtreecommitdiffstats
path: root/src/pdfwidgets/qpdfview.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Do not add magic header web_engine_logging.hMichal Klocek2024-10-311-4/+2
| | | | | | | | | | | | | | | | | | | | | | | Importing headers with relative paths going out of source component is evil. Remove web_engine_logging.h header as it is referred from the code base, but build system has no clue about it as it is specified as include with relative path. Moreover, it introduces weird implicit dependency of components like qtpdf on qtwebenginecore. Add required macro to private globals. Note for qtpdf it is unnecessary as we do not support compiling qtpdf against latest lts, however our release infra requires it. This commit amends d11709f18d692f4a3431999e90dddf0d7cdf15df. Task-number: QTBUG-127975 Change-Id: I89163a29db4e601cfb607928f796343ba522037b Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
* Fix static logging category deprecation warningsKaloyan Chehlarski2024-08-271-1/+3
| | | | | | | | | | | | | | | | | | | | | 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>
* 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>
* Change qt.pdf.links log category to qt.pdf.wigets.links in pdfwidgetsShawn Rutledge2024-05-091-3/+3
| | | | | | | | | | | | | We use the qt.pdf.links logging category in the PDF library. If we redefine qLcLink in PdfWidgets, we get a static link error; if we redeclare it, we get a dynamic link error. So it seems that we cannot reuse logging categories across modules. Fixes: QTBUG-124506 Pick-to: 6.5 6.7 Change-Id: I591f2e3af2162274c8092397cadf74ddbf687e9d Reviewed-by: Moss Heim <moss.heim@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QPdfView: use per-page scale factors to render search result rectanglesShawn Rutledge2024-01-311-26/+42
| | | | | | | | | | | | | | | | In FitToWidth and FitInView zoomModes, each page could potentially be a different size; so QPdfViewPrivate::calculateDocumentLayout() loops over all pages, calculating each pageSize and offset on the fly. m_zoomFactor doesn't get updated; but QPdfViewPrivate::updateDocumentLayout() stores the per-page zoom factors in m_documentLayout.pageGeometryAndScale. screenScaleTransform() takes the page index as an argument, looks up the per-page scale factor in those zoom modes, and QPdfView::paintEvent() uses the per-page transform to paint the rectangles. Pick-to: 6.5 6.6 6.7 Task-number: QTBUG-120764 Change-Id: I86308c8963ffadd2fdb6f36cf9f4696f75f550ed Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Rename QPdfView::currentSearchResult() -> currentSearchResultIndex()Shawn Rutledge2023-08-021-10/+10
| | | | | | | | | | | | 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>
* Don't use QScroller in QPdfViewShawn Rutledge2023-06-161-2/+0
| | | | | | | | | | | | This should be up to applications if desired, not a built-in feature. For example, qtdoc/examples/demos/documentviewer installs its own QScroller. Perhaps QScroller should only handle touch gestures, to avoid interfering with built-in QAbstractScrollArea behavior. Fixes: QTBUG-113981 Pick-to: 6.5 6.6 Change-Id: I5fdeb362d16e00f1ae656f7529450d5f5f6ffe83 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Teach QPdfView to render search result highlightsShawn Rutledge2023-03-171-1/+84
| | | | | | | | | | | | | | | | | | The bounding boxes of all visible search results are filled with a translucent color on top of the page image, because we don't know whether the image is opaque or not. currentSearchResult is further highlighted by drawing bounding box borders. The colors are the same as PdfStyle.pageSearchResultsColor and PdfStyle.currentSearchResultStrokeColor, respectively. Perhaps they could be configurable somehow in the future, but it's not clear yet what API that ought to have, since we do not have suitable QPalette roles (except QPalette::Highlight, which is not translucent). Task-number: QTBUG-77507 Task-number: QTBUG-92973 Change-Id: I3df634229811e72d2d438a39997e0b4887d6bf11 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Make QPdfLinkModel public and use in QPdfViewShawn Rutledge2023-03-171-1/+79
| | | | | | | | | Now you can click links on pages in PDF documents in QPdfView. Task-number: QTBUG-77511 Fixes: QTBUG-102760 Change-Id: I348dcfd906be088aa3fcbe53aec4628b521cc2f3 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Port from container::count() and length() to size() - V4Marc Mutz2022-10-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'. Change-Id: I3e6fef8eca212da0c4f0b464545ba96183b4476f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-221-39/+3
| | | | | | | | | | | 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-3/+3
| | | | | | | | 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>
* 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-11/+11
| | | | | | | [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>
* doc: Add docs for QPdfViewShawn Rutledge2022-04-231-8/+91
| | | | | | | | Wrap some long lines in qpdfview.cpp, as a drive-by. Task-number: QTBUG-81560 Change-Id: Ia9865c42e48c81ac2c99b5cbe9d5a10beff40847 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Move QQuickPdfNavStack core into QPdfNavigationStack; use in QPdfViewShawn Rutledge2022-04-081-7/+7
| | | | | | | | | | | | | | | 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>
* QPdfView: scale page rendering according to devicePixelRatioShawn Rutledge2022-03-181-2/+2
| | | | | | | | | On high-dpi screens we want the rendered pixels to match device pixels. Fixes: QTBUG-86948 Pick-to: 6.2 6.3 5.15 Change-Id: I4879adc0aeb001750d42abc1e7d50ca3f11a5fe8 Reviewed-by: Morten Johan Sørvig <morten.sorvig@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>
* Adapt to newer dependenciesAllan Sandfeld Jensen2020-07-061-11/+6
| | | | | | Change-Id: I495880f56fbc10d8f332f26101f8a25c2a1c5631 Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io> Reviewed-by: Michal Klocek <michal.klocek@qt.io>
* Add ; to Q_UNUSEDLars Schmertmann2020-06-271-2/+2
| | | | | | | | This is required to remove the ; from the macro with Qt 6. Task-number: QTBUG-82978 Change-Id: Id948c173695923a1ea83a2098bafc10cfd4dc22b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Enum class QPdfPageRenderer::RenderModev5.15.0-beta2Allan Sandfeld Jensen2020-03-161-1/+1
| | | | | | | Avoid having the enum name in the enum values. Change-Id: Ida5b3405e6922eb1a2a37edc6fb650019254f4d4 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Allow compile with gcc-4.8.5Martin Koller2019-11-251-1/+1
| | | | | | Change-Id: Ia3953e0318a97eabfd917dbefef3bbac65828287 Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com> Reviewed-by: Sérgio Martins <sergio.martins@kdab.com>
* Add initial version of QPdfView classTobias Koenig2019-11-251-0/+493
Change-Id: I9185320d8a4e725fdbbfe1fde205a2be3bc2113c Task-number: QTBUG-28886 Reviewed-by: Sérgio Martins <sergio.martins@kdab.com>