summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-01-14 18:29:18 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2022-01-26 21:12:31 +0100
commitd32563a3365fd9432993590e6ac9817fe6f6bd41 (patch)
tree931c886b2354436098f546c64e1f030e1de97328
parent9bf3cce203cc673880b0429c5c98bb8cc9be204f (diff)
downloadqtwebengine-d32563a3365fd9432993590e6ac9817fe6f6bd41.tar.gz
QtPdf: Use QML_NAMED_ELEMENT and auto-generated plugin
So we need to move the qmlmodule doc block to a qdoc file, now that there's no plugin.cpp. Change-Id: I2426ad12647ed65acc9f2e0c252b3b1af715d931 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/pdfquick/CMakeLists.txt15
-rw-r--r--src/pdfquick/doc/src/qtquickpdf-module.qdoc42
-rw-r--r--src/pdfquick/plugin.cpp100
-rw-r--r--src/pdfquick/qquickpdfdocument_p.h16
-rw-r--r--src/pdfquick/qquickpdflinkmodel_p.h7
-rw-r--r--src/pdfquick/qquickpdfnavigationstack_p.h6
-rw-r--r--src/pdfquick/qquickpdfsearchmodel_p.h7
-rw-r--r--src/pdfquick/qquickpdfselection_p.h13
8 files changed, 74 insertions, 132 deletions
diff --git a/src/pdfquick/CMakeLists.txt b/src/pdfquick/CMakeLists.txt
index e19199abc..18b43dbbf 100644
--- a/src/pdfquick/CMakeLists.txt
+++ b/src/pdfquick/CMakeLists.txt
@@ -13,11 +13,10 @@ set(qml_files
qt_internal_add_qml_module(PdfQuick
URI "QtQuick.Pdf"
VERSION "${PROJECT_VERSION}"
- CLASS_NAME QtQuick2PdfPlugin
- NO_GENERATE_PLUGIN_SOURCE
+ CLASS_NAME QtQuickPdfPlugin
NO_PLUGIN_OPTIONAL
- NO_GENERATE_QMLTYPES
PLUGIN_TARGET qtpdfquickplugin
+ PAST_MAJOR_VERSIONS 5
QML_FILES ${qml_files}
DEPENDENCIES QtQuickControls2
SOURCES
@@ -37,13 +36,3 @@ qt_internal_add_qml_module(PdfQuick
Qt::Qml
)
-qt_internal_extend_target(qtpdfquickplugin
- SOURCES
- plugin.cpp
- LIBRARIES
- Qt::CorePrivate
- Qt::PdfQuickPrivate
-)
-
-
-
diff --git a/src/pdfquick/doc/src/qtquickpdf-module.qdoc b/src/pdfquick/doc/src/qtquickpdf-module.qdoc
new file mode 100644
index 000000000..6f3db396b
--- /dev/null
+++ b/src/pdfquick/doc/src/qtquickpdf-module.qdoc
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmlmodule QtQuick.Pdf
+ \title Qt Quick PDF QML Types
+ \ingroup qmlmodules
+ \brief Provides QML types for handling PDF documents.
+ \since 5.14
+
+ This QML module contains types for handling PDF documents.
+
+ To use the types in this module, import the module with the following line:
+
+ \code
+ import QtQuick.Pdf
+ \endcode
+*/
diff --git a/src/pdfquick/plugin.cpp b/src/pdfquick/plugin.cpp
deleted file mode 100644
index 9ec5528f6..000000000
--- a/src/pdfquick/plugin.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPDF 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$
-**
-****************************************************************************/
-
-#include <QtQml/qqml.h>
-#include <QtQml/qqmlcomponent.h>
-#include <QtQml/qqmlengine.h>
-#include <QtQml/qqmlextensionplugin.h>
-#include "qquickpdfdocument_p.h"
-#include "qquickpdflinkmodel_p.h"
-#include "qquickpdfnavigationstack_p.h"
-#include "qquickpdfsearchmodel_p.h"
-#include "qquickpdfselection_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlmodule QtQuick.Pdf
- \title Qt Quick PDF QML Types
- \ingroup qmlmodules
- \brief Provides QML types for handling PDF documents.
-
- This QML module contains types for handling PDF documents.
-
- To use the types in this module, import the module with the following line:
-
- \code
- import QtQuick.Pdf
- \endcode
-*/
-
-class QtQuick2PdfPlugin : public QQmlExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
-
-public:
- QtQuick2PdfPlugin() : QQmlExtensionPlugin() { }
-
- void initializeEngine(QQmlEngine *engine, const char *uri) override {
- Q_UNUSED(uri);
-#ifdef QT_STATIC
- Q_UNUSED(engine);
-#else
- engine->addImportPath(QStringLiteral("qrc:/"));
-#endif
- }
-
- void registerTypes(const char *uri) override {
- Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Pdf"));
-
- // Register the latest version, even if there are no new types or new revisions for existing types yet.
- qmlRegisterModule(uri, 2, QT_VERSION_MINOR);
-
- qmlRegisterType<QQuickPdfDocument>(uri, 5, 15, "PdfDocument");
- qmlRegisterType<QQuickPdfLinkModel>(uri, 5, 15, "PdfLinkModel");
- qmlRegisterType<QQuickPdfNavigationStack>(uri, 5, 15, "PdfNavigationStack");
- qmlRegisterType<QQuickPdfSearchModel>(uri, 5, 15, "PdfSearchModel");
- qmlRegisterType<QQuickPdfSelection>(uri, 5, 15, "PdfSelection");
- }
-};
-
-QT_END_NAMESPACE
-
-#include "plugin.moc"
diff --git a/src/pdfquick/qquickpdfdocument_p.h b/src/pdfquick/qquickpdfdocument_p.h
index 29877d0d7..140832236 100644
--- a/src/pdfquick/qquickpdfdocument_p.h
+++ b/src/pdfquick/qquickpdfdocument_p.h
@@ -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.
@@ -53,17 +53,19 @@
#include <QtPdfQuick/private/qtpdfquickglobal_p.h>
#include <QtPdf/QPdfDocument>
-#include <QDateTime>
-#include <QJSValue>
-#include <QQmlParserStatus>
-#include <QUrl>
-#include <QVariant>
+
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlParserStatus>
+#include <QtCore/QDateTime>
+#include <QtCore/QUrl>
QT_BEGIN_NAMESPACE
class Q_PDFQUICK_EXPORT QQuickPdfDocument : public QObject, public QQmlParserStatus
{
Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(int pageCount READ pageCount NOTIFY pageCountChanged FINAL)
Q_PROPERTY(qreal maxPageWidth READ maxPageWidth NOTIFY metaDataChanged)
@@ -80,6 +82,8 @@ class Q_PDFQUICK_EXPORT QQuickPdfDocument : public QObject, public QQmlParserSta
Q_PROPERTY(QString creator READ creator NOTIFY metaDataChanged)
Q_PROPERTY(QDateTime creationDate READ creationDate NOTIFY metaDataChanged)
Q_PROPERTY(QDateTime modificationDate READ modificationDate NOTIFY metaDataChanged)
+ QML_NAMED_ELEMENT(PdfDocument)
+ QML_ADDED_IN_VERSION(5, 15)
public:
explicit QQuickPdfDocument(QObject *parent = nullptr);
diff --git a/src/pdfquick/qquickpdflinkmodel_p.h b/src/pdfquick/qquickpdflinkmodel_p.h
index e7dcc6a3e..156444828 100644
--- a/src/pdfquick/qquickpdflinkmodel_p.h
+++ b/src/pdfquick/qquickpdflinkmodel_p.h
@@ -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.
@@ -55,8 +55,7 @@
#include <QtPdfQuick/private/qquickpdfdocument_p.h>
#include <QtPdf/private/qpdflinkmodel_p.h>
-#include <QVariant>
-#include <QtQml/qqml.h>
+#include <QtQml/QQmlEngine>
QT_BEGIN_NAMESPACE
@@ -64,6 +63,8 @@ class Q_PDFQUICK_EXPORT QQuickPdfLinkModel : public QPdfLinkModel
{
Q_OBJECT
Q_PROPERTY(QQuickPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged)
+ QML_NAMED_ELEMENT(PdfLinkModel)
+ QML_ADDED_IN_VERSION(5, 15)
public:
explicit QQuickPdfLinkModel(QObject *parent = nullptr);
diff --git a/src/pdfquick/qquickpdfnavigationstack_p.h b/src/pdfquick/qquickpdfnavigationstack_p.h
index 44ccb787a..7c69c3c66 100644
--- a/src/pdfquick/qquickpdfnavigationstack_p.h
+++ b/src/pdfquick/qquickpdfnavigationstack_p.h
@@ -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.
@@ -55,7 +55,7 @@
#include <QtPdfQuick/private/qquickpdfdocument_p.h>
#include <QtPdf/private/qpdfdestination_p.h>
-#include <QtQml/qqml.h>
+#include <QQmlEngine>
QT_BEGIN_NAMESPACE
@@ -67,6 +67,8 @@ class Q_PDFQUICK_EXPORT QQuickPdfNavigationStack : public QObject
Q_PROPERTY(qreal currentZoom READ currentZoom NOTIFY currentZoomChanged)
Q_PROPERTY(bool backAvailable READ backAvailable NOTIFY backAvailableChanged)
Q_PROPERTY(bool forwardAvailable READ forwardAvailable NOTIFY forwardAvailableChanged)
+ QML_NAMED_ELEMENT(PdfNavigationStack)
+ QML_ADDED_IN_VERSION(5, 15)
public:
explicit QQuickPdfNavigationStack(QObject *parent = nullptr);
diff --git a/src/pdfquick/qquickpdfsearchmodel_p.h b/src/pdfquick/qquickpdfsearchmodel_p.h
index de1d86f42..1ddd1d833 100644
--- a/src/pdfquick/qquickpdfsearchmodel_p.h
+++ b/src/pdfquick/qquickpdfsearchmodel_p.h
@@ -53,10 +53,9 @@
#include <QtPdfQuick/private/qtpdfquickglobal_p.h>
#include <QtPdfQuick/private/qquickpdfdocument_p.h>
-#include <QtPdf/qpdfsearchmodel.h>
-#include <QtCore/qvariant.h>
-#include <QtQml/qqml.h>
+#include <QtPdf/qpdfsearchmodel.h>
+#include <QtQml/QQmlEngine>
QT_BEGIN_NAMESPACE
@@ -69,6 +68,8 @@ class Q_PDFQUICK_EXPORT QQuickPdfSearchModel : public QPdfSearchModel
Q_PROPERTY(QList<QPolygonF> currentPageBoundingPolygons READ currentPageBoundingPolygons NOTIFY currentPageBoundingPolygonsChanged)
Q_PROPERTY(QList<QPolygonF> currentResultBoundingPolygons READ currentResultBoundingPolygons NOTIFY currentResultBoundingPolygonsChanged)
Q_PROPERTY(QRectF currentResultBoundingRect READ currentResultBoundingRect NOTIFY currentResultBoundingRectChanged)
+ QML_NAMED_ELEMENT(PdfSearchModel)
+ QML_ADDED_IN_VERSION(5, 15)
public:
explicit QQuickPdfSearchModel(QObject *parent = nullptr);
diff --git a/src/pdfquick/qquickpdfselection_p.h b/src/pdfquick/qquickpdfselection_p.h
index 997f95643..5ba4c2f43 100644
--- a/src/pdfquick/qquickpdfselection_p.h
+++ b/src/pdfquick/qquickpdfselection_p.h
@@ -53,11 +53,12 @@
#include <QtPdfQuick/private/qtpdfquickglobal_p.h>
#include <QtPdfQuick/private/qquickpdfdocument_p.h>
-#include <QPointF>
-#include <QPolygonF>
-#include <QVariant>
-#include <QtQml/qqml.h>
-#include <QtQuick/qquickitem.h>
+
+#include <QtCore/QPointF>
+#include <QtCore/QVariant>
+#include <QtGui/QPolygonF>
+#include <QtQml/QQmlEngine>
+#include <QtQuick/QQuickItem>
QT_BEGIN_NAMESPACE
class QPdfSelection;
@@ -74,6 +75,8 @@ class Q_PDFQUICK_EXPORT QQuickPdfSelection : public QQuickItem
Q_PROPERTY(QString text READ text NOTIFY textChanged)
Q_PROPERTY(QList<QPolygonF> geometry READ geometry NOTIFY selectedAreaChanged)
+ QML_NAMED_ELEMENT(PdfSelection)
+ QML_ADDED_IN_VERSION(5, 15)
public:
explicit QQuickPdfSelection(QQuickItem *parent = nullptr);