From c9500b6eff3dc8fbcc6e9fc569b2e246541a2a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 27 Aug 2015 12:26:33 +0200 Subject: Macro for QML extension boilerplate defines which gives type sub-classes which adds desired functionality for extensions in QML Change-Id: I3973e07e0daf0c27813b3405b9188281092f4375 --- src/compositor/global/qwaylandquickextension.h | 110 +++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/compositor/global/qwaylandquickextension.h (limited to 'src/compositor/global/qwaylandquickextension.h') diff --git a/src/compositor/global/qwaylandquickextension.h b/src/compositor/global/qwaylandquickextension.h new file mode 100644 index 000000000..183d4c23c --- /dev/null +++ b/src/compositor/global/qwaylandquickextension.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDQUICKEXTENSION_H +#define QWAYLANDQUICKEXTENSION_H + +#include + +QT_BEGIN_NAMESPACE + +#define Q_COMPOSITOR_DECLARE_QUICK_DATA_CLASS(className) \ + class Q_COMPOSITOR_EXPORT className##QuickData : public className \ + { \ +/* qmake ignore Q_OBJECT */ \ + Q_OBJECT \ + Q_PROPERTY(QQmlListProperty data READ data DESIGNABLE false) \ + Q_CLASSINFO("DefaultProperty", "data") \ + public: \ + QQmlListProperty data() \ + { \ + return QQmlListProperty(this, m_objects); \ + } \ + private: \ + QList m_objects; \ + }; + +#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(className) \ + class Q_COMPOSITOR_EXPORT className##QuickExtension : public className \ + { \ +/* qmake ignore Q_OBJECT */ \ + Q_OBJECT \ + Q_PROPERTY(QQmlListProperty extensions READ extensions) \ + Q_PROPERTY(QQmlListProperty data READ data DESIGNABLE false) \ + Q_CLASSINFO("DefaultProperty", "data") \ + public: \ + QQmlListProperty data() \ + { \ + return QQmlListProperty(this, m_objects); \ + } \ + QQmlListProperty extensions() \ + { \ + return QQmlListProperty(this, this, \ + &className##QuickExtension::append_extension, \ + &className##QuickExtension::countFunction, \ + &className##QuickExtension::atFunction, \ + &className##QuickExtension::clearFunction); \ + } \ + static int countFunction(QQmlListProperty *list) \ + { \ + return static_cast(list->data)->extension_vector.size(); \ + } \ + static QWaylandExtension *atFunction(QQmlListProperty *list, int index) \ + { \ + return static_cast(list->data)->extension_vector.at(index); \ + } \ + static void append_extension(QQmlListProperty *list, QWaylandExtension *extension) \ + { \ + className##QuickExtension *compositor = static_cast(list->data); \ + extension->setExtensionContainer(compositor); \ + } \ + static void clearFunction(QQmlListProperty *list) \ + { \ + static_cast(list->data)->extension_vector.clear(); \ + } \ + protected: \ + void componentComplete() Q_DECL_OVERRIDE \ + { \ + create(); \ + QWaylandQuickCompositor::componentComplete(); \ + }\ + private: \ + QList m_objects; \ + }; + +QT_END_NAMESPACE + +#endif /*QWAYLANDQUICKEXTENSION_H*/ -- cgit v1.2.3 From c5d77c7f720b826cd52f1f6f598ea16e662933cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 3 Sep 2015 16:51:14 +0200 Subject: Cleanup QWaylandQuickCompositorExtension file Change-Id: I3f0e5a41f0bb15311bd48775be10d81548caf1e3 --- src/compositor/global/qwaylandquickextension.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/compositor/global/qwaylandquickextension.h') diff --git a/src/compositor/global/qwaylandquickextension.h b/src/compositor/global/qwaylandquickextension.h index 183d4c23c..10023aec2 100644 --- a/src/compositor/global/qwaylandquickextension.h +++ b/src/compositor/global/qwaylandquickextension.h @@ -88,19 +88,13 @@ QT_BEGIN_NAMESPACE } \ static void append_extension(QQmlListProperty *list, QWaylandExtension *extension) \ { \ - className##QuickExtension *compositor = static_cast(list->data); \ - extension->setExtensionContainer(compositor); \ + className##QuickExtension *quickExtObj = static_cast(list->data); \ + extension->setExtensionContainer(quickExtObj); \ } \ static void clearFunction(QQmlListProperty *list) \ { \ static_cast(list->data)->extension_vector.clear(); \ } \ - protected: \ - void componentComplete() Q_DECL_OVERRIDE \ - { \ - create(); \ - QWaylandQuickCompositor::componentComplete(); \ - }\ private: \ QList m_objects; \ }; -- cgit v1.2.3 From 00fba62ce3e5bd00ba5e8ab6f5b7a71bdb93c6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 7 Sep 2015 14:04:17 +0200 Subject: Rename QtCompositor to QtWaylandCompositor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit enable building QtWaylandCompositor by default Change-Id: I7cf34052b304ca9fef55b7e30ef6a6367b5d75f1 Reviewed-by: Jørgen Lind --- src/compositor/global/qwaylandquickextension.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/compositor/global/qwaylandquickextension.h') diff --git a/src/compositor/global/qwaylandquickextension.h b/src/compositor/global/qwaylandquickextension.h index 10023aec2..6b5bed9c1 100644 --- a/src/compositor/global/qwaylandquickextension.h +++ b/src/compositor/global/qwaylandquickextension.h @@ -37,7 +37,7 @@ #ifndef QWAYLANDQUICKEXTENSION_H #define QWAYLANDQUICKEXTENSION_H -#include +#include QT_BEGIN_NAMESPACE -- cgit v1.2.3