diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-03-28 12:31:13 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-04-12 19:06:19 +0200 |
commit | 217958ac3df79f668f3fa943e76b1dbf09981457 (patch) | |
tree | 5370df86508b7edea1c40353458ea43ed96ef53a /src/pdfquick | |
parent | 034f5b6bb740eb11db21a974330b59bd049a5b16 (diff) | |
download | qtwebengine-217958ac3df79f668f3fa943e76b1dbf09981457.tar.gz |
PdfQuick: deal with loading a different document
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>
Diffstat (limited to 'src/pdfquick')
-rw-r--r-- | src/pdfquick/PdfMultiPageView.qml | 8 | ||||
-rw-r--r-- | src/pdfquick/PdfPageView.qml | 6 | ||||
-rw-r--r-- | src/pdfquick/PdfScrollablePageView.qml | 8 | ||||
-rw-r--r-- | src/pdfquick/qquickpdfdocument.cpp | 4 |
4 files changed, 25 insertions, 1 deletions
diff --git a/src/pdfquick/PdfMultiPageView.qml b/src/pdfquick/PdfMultiPageView.qml index 3182fb924..a26bca700 100644 --- a/src/pdfquick/PdfMultiPageView.qml +++ b/src/pdfquick/PdfMultiPageView.qml @@ -639,6 +639,14 @@ Item { previousPage = page } onCurrentPageChanged: searchModel.currentPage = currentPage + + property url documentSource: root.document.source + onDocumentSourceChanged: { + navigationStack.clear() + root.resetScale() + tableView.contentX = 0 + tableView.contentY = 0 + } } PdfSearchModel { id: searchModel diff --git a/src/pdfquick/PdfPageView.qml b/src/pdfquick/PdfPageView.qml index 08e743fb5..aa6b59a14 100644 --- a/src/pdfquick/PdfPageView.qml +++ b/src/pdfquick/PdfPageView.qml @@ -144,6 +144,12 @@ Rectangle { // TODO onCurrentLocationChanged: position currentLocation.x and .y in middle // currentPageChanged() MUST occur first! onCurrentZoomChanged: root.renderScale = currentZoom // TODO deal with horizontal location (need WheelHandler or Flickable probably) + + property url documentSource: root.document.source + onDocumentSourceChanged: { + navigationStack.clear() + root.goToPage(0) + } } PdfPageImage { diff --git a/src/pdfquick/PdfScrollablePageView.qml b/src/pdfquick/PdfScrollablePageView.qml index 5111968e5..1d17a1c10 100644 --- a/src/pdfquick/PdfScrollablePageView.qml +++ b/src/pdfquick/PdfScrollablePageView.qml @@ -156,6 +156,14 @@ Flickable { "on page", page, "ended up @", root.contentX + ", " + root.contentY) } onCurrentPageChanged: searchModel.currentPage = currentPage + + property url documentSource: root.document.source + onDocumentSourceChanged: { + navigationStack.clear() + root.resetScale() + root.contentX = 0 + root.contentY = 0 + } } LoggingCategory { diff --git a/src/pdfquick/qquickpdfdocument.cpp b/src/pdfquick/qquickpdfdocument.cpp index f7c6df75f..cda72b2c8 100644 --- a/src/pdfquick/qquickpdfdocument.cpp +++ b/src/pdfquick/qquickpdfdocument.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -104,6 +104,8 @@ void QQuickPdfDocument::setSource(QUrl source) m_source = source; m_maxPageWidthHeight = QSizeF(); + m_carrierFile->deleteLater(); + m_carrierFile = nullptr; emit sourceChanged(); const QQmlContext *context = qmlContext(this); m_resolvedSource = context ? context->resolvedUrl(source) : source; |