1// Copyright (C) 2016 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
4#ifndef QQMLEXTENSIONPLUGIN_H
5#define QQMLEXTENSIONPLUGIN_H
6
7#include <QtCore/qplugin.h>
8#include <QtCore/QUrl>
9#include <QtQml/qqmlextensioninterface.h>
10
11#if defined(Q_CC_GHS)
12# define Q_GHS_KEEP_REFERENCE(S) QT_DO_PRAGMA(ghs reference S ##__Fv)
13#else
14# define Q_GHS_KEEP_REFERENCE(S)
15#endif
16
17#define Q_IMPORT_QML_PLUGIN(PLUGIN) \
18 Q_IMPORT_PLUGIN(PLUGIN)
19
20QT_BEGIN_NAMESPACE
21
22class QQmlEngine;
23class QQmlExtensionPluginPrivate;
24
25class Q_QML_EXPORT QQmlExtensionPlugin
26 : public QObject
27 , public QQmlExtensionInterface
28{
29 Q_OBJECT
30 Q_DECLARE_PRIVATE(QQmlExtensionPlugin)
31 Q_INTERFACES(QQmlExtensionInterface)
32 Q_INTERFACES(QQmlTypesExtensionInterface)
33public:
34 explicit QQmlExtensionPlugin(QObject *parent = nullptr);
35 ~QQmlExtensionPlugin() override;
36
37#if QT_DEPRECATED_SINCE(6, 3)
38 QT_DEPRECATED_VERSION_X_6_3("Provide a qmldir file to remove the need for calling baseUrl")
39 QUrl baseUrl() const;
40#endif
41
42 void registerTypes(const char *uri) override = 0;
43 virtual void unregisterTypes();
44 void initializeEngine(QQmlEngine *engine, const char *uri) override;
45
46private:
47 Q_DISABLE_COPY(QQmlExtensionPlugin)
48};
49
50class Q_QML_EXPORT QQmlEngineExtensionPlugin
51 : public QObject
52 , public QQmlEngineExtensionInterface
53{
54 Q_OBJECT
55 Q_DISABLE_COPY_MOVE(QQmlEngineExtensionPlugin)
56 Q_INTERFACES(QQmlEngineExtensionInterface)
57public:
58 explicit QQmlEngineExtensionPlugin(QObject *parent = nullptr);
59 ~QQmlEngineExtensionPlugin() override;
60 void initializeEngine(QQmlEngine *engine, const char *uri) override;
61};
62
63QT_END_NAMESPACE
64
65#endif // QQMLEXTENSIONPLUGIN_H
66

source code of qtdeclarative/src/qml/qml/qqmlextensionplugin.h