| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#ifndef QWAYLANDQUICKEXTENSION_H |
| 31 |
#define QWAYLANDQUICKEXTENSION_H |
| 32 |
|
| 33 |
#include <QtWaylandCompositor/QWaylandCompositorExtension> |
| 34 |
#include <QtQml/QQmlParserStatus> |
| 35 |
#include <QtQml/QQmlListProperty> |
| 36 |
|
| 37 |
QT_BEGIN_NAMESPACE |
| 38 |
|
| 39 |
#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(className) \ |
| 40 |
class Q_WAYLAND_COMPOSITOR_EXPORT className##QuickExtension : public className, public QQmlParserStatus \ |
| 41 |
{ \ |
| 42 |
\ |
| 43 |
Q_OBJECT \ |
| 44 |
Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) \ |
| 45 |
Q_CLASSINFO("DefaultProperty", "data") \ |
| 46 |
Q_INTERFACES(QQmlParserStatus) \ |
| 47 |
public: \ |
| 48 |
QQmlListProperty<QObject> data() \ |
| 49 |
{ \ |
| 50 |
return QQmlListProperty<QObject>(this, &m_objects); \ |
| 51 |
} \ |
| 52 |
void classBegin() override {} \ |
| 53 |
void componentComplete() override { if (!isInitialized()) initialize(); } \ |
| 54 |
private: \ |
| 55 |
QList<QObject *> m_objects; \ |
| 56 |
}; |
| 57 |
|
| 58 |
#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CONTAINER_CLASS(className) \ |
| 59 |
class Q_WAYLAND_COMPOSITOR_EXPORT className##QuickExtensionContainer : public className \ |
| 60 |
{ \ |
| 61 |
\ |
| 62 |
Q_OBJECT \ |
| 63 |
Q_PROPERTY(QQmlListProperty<QWaylandCompositorExtension> extensions READ extensions) \ |
| 64 |
Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) \ |
| 65 |
Q_CLASSINFO("DefaultProperty", "data") \ |
| 66 |
public: \ |
| 67 |
QQmlListProperty<QObject> data() \ |
| 68 |
{ \ |
| 69 |
return QQmlListProperty<QObject>(this, &m_objects); \ |
| 70 |
} \ |
| 71 |
QQmlListProperty<QWaylandCompositorExtension> extensions() \ |
| 72 |
{ \ |
| 73 |
return QQmlListProperty<QWaylandCompositorExtension>(this, this, \ |
| 74 |
&className##QuickExtensionContainer::append_extension, \ |
| 75 |
&className##QuickExtensionContainer::countFunction, \ |
| 76 |
&className##QuickExtensionContainer::atFunction, \ |
| 77 |
&className##QuickExtensionContainer::clearFunction); \ |
| 78 |
} \ |
| 79 |
static int countFunction(QQmlListProperty<QWaylandCompositorExtension> *list) \ |
| 80 |
{ \ |
| 81 |
return static_cast<className##QuickExtensionContainer *>(list->data)->extension_vector.size(); \ |
| 82 |
} \ |
| 83 |
static QWaylandCompositorExtension *atFunction(QQmlListProperty<QWaylandCompositorExtension> *list, int index) \ |
| 84 |
{ \ |
| 85 |
return static_cast<className##QuickExtensionContainer *>(list->data)->extension_vector.at(index); \ |
| 86 |
} \ |
| 87 |
static void append_extension(QQmlListProperty<QWaylandCompositorExtension> *list, QWaylandCompositorExtension *extension) \ |
| 88 |
{ \ |
| 89 |
className##QuickExtensionContainer *quickExtObj = static_cast<className##QuickExtensionContainer *>(list->data); \ |
| 90 |
extension->setExtensionContainer(quickExtObj); \ |
| 91 |
} \ |
| 92 |
static void clearFunction(QQmlListProperty<QWaylandCompositorExtension> *list) \ |
| 93 |
{ \ |
| 94 |
static_cast<className##QuickExtensionContainer *>(list->data)->extension_vector.clear(); \ |
| 95 |
} \ |
| 96 |
private: \ |
| 97 |
QList<QObject *> m_objects; \ |
| 98 |
}; |
| 99 |
|
| 100 |
QT_END_NAMESPACE |
| 101 |
|
| 102 |
#endif |