summaryrefslogtreecommitdiffstats
path: root/src/pdfquick/qquickpdfpageimage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pdfquick/qquickpdfpageimage.cpp')
-rw-r--r--src/pdfquick/qquickpdfpageimage.cpp72
1 files changed, 26 insertions, 46 deletions
diff --git a/src/pdfquick/qquickpdfpageimage.cpp b/src/pdfquick/qquickpdfpageimage.cpp
index 0d90297a2..9ff0337a5 100644
--- a/src/pdfquick/qquickpdfpageimage.cpp
+++ b/src/pdfquick/qquickpdfpageimage.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2022 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qquickpdfpageimage_p.h"
#include "qquickpdfdocument_p.h"
@@ -49,7 +13,7 @@ Q_LOGGING_CATEGORY(qLcImg, "qt.pdf.image")
/*!
\qmltype PdfPageImage
//! \instantiates QQuickPdfPageImage
- \inqmlmodule QtPdf
+ \inqmlmodule QtQuick.Pdf
\ingroup pdf
\inherits Image
\brief Displays one page from a PDF document.
@@ -78,7 +42,7 @@ QQuickPdfPageImage::~QQuickPdfPageImage()
{
Q_D(QQuickPdfPageImage);
// cancel any async rendering job that is running on my behalf
- d->pix.clear();
+ d->pendingPix->clear();
}
/*!
@@ -112,6 +76,18 @@ QQuickPdfDocument *QQuickPdfPageImage::document() const
void QQuickPdfPageImage::load()
{
Q_D(QQuickPdfPageImage);
+ QUrl url = source();
+ if (!d->doc || !d->doc->carrierFile()) {
+ if (!url.isEmpty()) {
+ qmlWarning(this) << "document property not set: falling back to inefficient loading of " << url;
+ QQuickImageBase::load();
+ }
+ return;
+ }
+ if (url != d->doc->resolvedSource()) {
+ url = d->doc->resolvedSource();
+ qmlWarning(this) << "document and source properties in conflict: preferring document source " << url;
+ }
auto carrierFile = d->doc->carrierFile();
static int thisRequestProgress = -1;
static int thisRequestFinished = -1;
@@ -121,21 +97,23 @@ void QQuickPdfPageImage::load()
thisRequestFinished =
QQuickImageBase::staticMetaObject.indexOfSlot("requestFinished()");
}
+ static QMetaMethod requestFinishedSlot = staticMetaObject.method(thisRequestFinished);
- d->pix.loadImageFromDevice(qmlEngine(this), carrierFile, d->url,
+ d->pendingPix->loadImageFromDevice(qmlEngine(this), carrierFile, url,
d->sourceClipRect.toRect(), d->sourcesize * d->devicePixelRatio,
QQuickImageProviderOptions(), d->currentFrame, d->frameCount);
qCDebug(qLcImg) << "loading page" << d->currentFrame << "of" << d->frameCount
- << "from" << carrierFile->fileName() << "status" << d->pix.status();
+ << "from" << carrierFile->fileName() << "status" << d->pendingPix->status();
- switch (d->pix.status()) {
+ switch (d->pendingPix->status()) {
case QQuickPixmap::Ready:
+ requestFinishedSlot.invoke(this);
pixmapChange();
break;
case QQuickPixmap::Loading:
- d->pix.connectFinished(this, thisRequestFinished);
- d->pix.connectDownloadProgress(this, thisRequestProgress);
+ d->pendingPix->connectFinished(this, thisRequestFinished);
+ d->pendingPix->connectDownloadProgress(this, thisRequestProgress);
if (d->progress != 0.0) {
d->progress = 0.0;
emit progressChanged(d->progress);
@@ -146,7 +124,7 @@ void QQuickPdfPageImage::load()
}
break;
default:
- qCDebug(qLcImg) << "unexpected status" << d->pix.status();
+ qCDebug(qLcImg) << "unexpected status" << d->pendingPix->status();
break;
}
}
@@ -161,3 +139,5 @@ void QQuickPdfPageImage::documentStatusChanged()
}
QT_END_NAMESPACE
+
+#include "moc_qquickpdfpageimage_p.cpp"