Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquickpdfpageimage.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6#include <private/qpdffile_p.h>
7#include <QtQuick/private/qquickimage_p_p.h>
8
10
11Q_LOGGING_CATEGORY(qLcImg, "qt.pdf.image")
12
13
16
26{
27public:
29
30 QQuickPdfDocument *doc = nullptr;
31};
32
35{
36}
37
42{
44 // cancel any async rendering job that is running on my behalf
45 d->pix.clear();
46}
47
54{
56 if (d->doc == document)
57 return;
58
59 if (d->doc)
61 d->doc = document;
62 if (document) {
64 if (document->document()->status() == QPdfDocument::Status::Ready)
65 setSource(document->resolvedSource()); // calls load()
66 }
68}
69
71{
72 Q_D(const QQuickPdfPageImage);
73 return d->doc;
74}
75
77{
79 auto carrierFile = d->doc->carrierFile();
80 static int thisRequestProgress = -1;
81 static int thisRequestFinished = -1;
82 if (thisRequestProgress == -1) {
83 thisRequestProgress =
84 QQuickImageBase::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)");
85 thisRequestFinished =
86 QQuickImageBase::staticMetaObject.indexOfSlot("requestFinished()");
87 }
88
89 d->pix.loadImageFromDevice(qmlEngine(this), carrierFile, d->url,
90 d->sourceClipRect.toRect(), d->sourcesize * d->devicePixelRatio,
91 QQuickImageProviderOptions(), d->currentFrame, d->frameCount);
92
93 qCDebug(qLcImg) << "loading page" << d->currentFrame << "of" << d->frameCount
94 << "from" << carrierFile->fileName() << "status" << d->pix.status();
95
96 switch (d->pix.status()) {
99 break;
101 d->pix.connectFinished(this, thisRequestFinished);
102 d->pix.connectDownloadProgress(this, thisRequestProgress);
103 if (d->progress != 0.0) {
104 d->progress = 0.0;
105 emit progressChanged(d->progress);
106 }
107 if (d->status != Loading) {
108 d->status = Loading;
109 emit statusChanged(d->status);
110 }
111 break;
112 default:
113 qCDebug(qLcImg) << "unexpected status" << d->pix.status();
114 break;
115 }
116}
117
119{
121 const auto status = d->doc->document()->status();
122 qCDebug(qLcImg) << "document status" << status;
124 setSource(d->doc->resolvedSource()); // calls load()
125}
126
128
129#include "moc_qquickpdfpageimage_p.cpp"
Status status
This property holds the current status of the document.
void statusChanged(QPdfDocument::Status status)
void statusChanged(QQuickImageBase::Status)
void progressChanged(qreal progress)
virtual void setSource(const QUrl &url)
The QQuickImageProviderOptions class provides options for QQuickImageProviderWithOptions image reques...
void pixmapChange() override
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:64
QUrl resolvedSource() const
Displays one page from a PDF document.
QQuickPdfDocument * document
void setDocument(QQuickPdfDocument *document)
\qmlproperty PdfDocument PdfPageImage::document
QQuickPdfPageImage(QQuickItem *parent=nullptr)
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
QQmlEngine * qmlEngine(const QObject *obj)
Definition qqml.cpp:76
#define emit
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent