diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-01-19 11:30:00 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-01-19 15:21:22 +0000 |
commit | da6a67b131879d0157b9774017c857bdfeff78c2 (patch) | |
tree | c4394f1ded58a0b48dff5556f86e4032cfe46cd7 /src | |
parent | 199c2754d5b44f62f15ca5add6d5c3c1e5009d79 (diff) |
Add EventSourceHelperSetter
Change-Id: I91b76f1206fa0b6c398f0913586757c6419936b4
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/input/backend/backend.pri | 6 | ||||
-rw-r--r-- | src/input/backend/eventsourcesetterhelper.cpp | 75 | ||||
-rw-r--r-- | src/input/backend/eventsourcesetterhelper_p.h | 90 |
3 files changed, 169 insertions, 2 deletions
diff --git a/src/input/backend/backend.pri b/src/input/backend/backend.pri index bb1806cae..b57dc2a28 100644 --- a/src/input/backend/backend.pri +++ b/src/input/backend/backend.pri @@ -29,7 +29,8 @@ HEADERS += \ $$PWD/genericdevicebackendnode_p.h \ $$PWD/inputchord_p.h \ $$PWD/inputsequence_p.h \ - $$PWD/inputsettings_p.h + $$PWD/inputsettings_p.h \ + $$PWD/eventsourcesetterhelper_p.h SOURCES += \ $$PWD/keyboardcontroller.cpp \ @@ -57,6 +58,7 @@ SOURCES += \ $$PWD/genericdevicebackendnode.cpp \ $$PWD/inputchord.cpp \ $$PWD/inputsequence.cpp \ - $$PWD/inputsettings.cpp + $$PWD/inputsettings.cpp \ + $$PWD/eventsourcesetterhelper.cpp INCLUDEPATH += $$PWD diff --git a/src/input/backend/eventsourcesetterhelper.cpp b/src/input/backend/eventsourcesetterhelper.cpp new file mode 100644 index 000000000..1dc85a24b --- /dev/null +++ b/src/input/backend/eventsourcesetterhelper.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D 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$ +** +****************************************************************************/ + +#include "eventsourcesetterhelper_p.h" +#include "inputhandler_p.h" +#include <Qt3DCore/private/qeventfilterservice_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +namespace Input { + +EventSourceSetterHelper::EventSourceSetterHelper(Qt3DCore::QEventFilterService *service, + InputHandler *inputHandler) + : QObject() + , m_service(service) + , m_inputHandler(inputHandler) +{ +} + +// Any thread +void EventSourceSetterHelper::setEventSource(QObject *eventSource) +{ + QMetaObject::invokeMethod(this, + "setEventSourceHelper", + Qt::BlockingQueuedConnection, + Q_ARG(QObject *, eventSource)); +} + +// Main Thread +void EventSourceSetterHelper::setEventSourceHelper(QObject *eventSource) +{ + m_service->initialize(eventSource); + m_inputHandler->registerEventFilters(m_service); +} + +} // Input + +} // Qt3DInput + +QT_END_NAMESPACE diff --git a/src/input/backend/eventsourcesetterhelper_p.h b/src/input/backend/eventsourcesetterhelper_p.h new file mode 100644 index 000000000..4a948be6a --- /dev/null +++ b/src/input/backend/eventsourcesetterhelper_p.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D 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 EVENTSOURCESETTERHELPER_H +#define EVENTSOURCESETTERHELPER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QObject> + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { +class QEventFilterService; +} + +namespace Qt3DInput { + +namespace Input { + +class InputHandler; + +class EventSourceSetterHelper : public QObject +{ + Q_OBJECT +public: + explicit EventSourceSetterHelper(Qt3DCore::QEventFilterService *service, + InputHandler *m_inputHandler); + + // Called from any thread + void setEventSource(QObject *eventSource); + +private Q_SLOTS: + // Called in main thread + void setEventSourceHelper(QObject *); + +private: + Qt3DCore::QEventFilterService *m_service; + InputHandler *m_inputHandler; +}; + +} // Input + +} // Qt3DInput + +QT_END_NAMESPACE + +#endif // EVENTSOURCESETTERHELPER_H |