1 | // Copyright (C) 2020 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H |
5 | #define QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtQml/qqml.h> |
19 | #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> |
20 | #include <QtWaylandCompositor/qwaylandquickextension.h> |
21 | |
22 | #include <QtWaylandCompositor/qwaylandcompositor.h> |
23 | #include <QtWaylandCompositor/qwaylandquickcompositor.h> |
24 | #include <QtWaylandCompositor/qwaylandqtwindowmanager.h> |
25 | #include <QtWaylandCompositor/qwaylandtextinputmanager.h> |
26 | #include <QtCore/private/qglobal_p.h> |
27 | #include <QtWaylandCompositor/qwaylandtextinputmanagerv3.h> |
28 | #include <QtWaylandCompositor/qwaylandqttextinputmethodmanager.h> |
29 | #include <QtWaylandCompositor/qwaylandidleinhibitv1.h> |
30 | |
31 | QT_BEGIN_NAMESPACE |
32 | |
33 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickCompositorQuickExtensionContainer : public QWaylandQuickCompositor |
34 | { |
35 | Q_OBJECT |
36 | Q_PROPERTY(QQmlListProperty<QWaylandCompositorExtension> extensions READ extensions) |
37 | Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) |
38 | Q_CLASSINFO("DefaultProperty" , "data" ) |
39 | QML_NAMED_ELEMENT(WaylandCompositor) |
40 | QML_ADDED_IN_VERSION(1, 0) |
41 | public: |
42 | QQmlListProperty<QObject> data() |
43 | { |
44 | return QQmlListProperty<QObject>(this, &m_objects); |
45 | } |
46 | |
47 | QQmlListProperty<QWaylandCompositorExtension> extensions() |
48 | { |
49 | return QQmlListProperty<QWaylandCompositorExtension>(this, this, |
50 | &append_extension, |
51 | &countFunction, |
52 | &atFunction, |
53 | &clearFunction); |
54 | } |
55 | |
56 | static qsizetype countFunction(QQmlListProperty<QWaylandCompositorExtension> *list) |
57 | { |
58 | return static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.size(); |
59 | } |
60 | |
61 | static QWaylandCompositorExtension *atFunction(QQmlListProperty<QWaylandCompositorExtension> *list, qsizetype index) |
62 | { |
63 | return static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.at(i: index); |
64 | } |
65 | |
66 | static void append_extension(QQmlListProperty<QWaylandCompositorExtension> *list, QWaylandCompositorExtension *extension) |
67 | { |
68 | QWaylandQuickCompositorQuickExtensionContainer *quickExtObj = static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data); |
69 | extension->setExtensionContainer(quickExtObj); |
70 | } |
71 | |
72 | static void clearFunction(QQmlListProperty<QWaylandCompositorExtension> *list) |
73 | { |
74 | static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.clear(); |
75 | } |
76 | |
77 | private: |
78 | QList<QObject *> m_objects; |
79 | }; |
80 | |
81 | |
82 | // Note: These have to be in a header with a Q_OBJECT macro, otherwise we won't run moc on it |
83 | Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandQtWindowManager, QtWindowManager, 1, 0) |
84 | Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandIdleInhibitManagerV1, |
85 | IdleInhibitManagerV1, 1, 0) |
86 | Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandTextInputManager, TextInputManager, 1, 0) |
87 | Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandTextInputManagerV3, TextInputManagerV3, |
88 | 1, 0) |
89 | Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandQtTextInputMethodManager, |
90 | QtTextInputMethodManager, 1, 0) |
91 | |
92 | QT_END_NAMESPACE |
93 | |
94 | #endif // QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H |
95 | |