diff options
author | Robert Brock <robert.brock@kdab.com> | 2016-04-29 08:18:06 +0200 |
---|---|---|
committer | Kevin Ottens <kevin.ottens@kdab.com> | 2016-05-02 10:26:25 +0000 |
commit | f63397953d052dc2a35bcc0ec32eaff0ebd80f05 (patch) | |
tree | 869d1bd567a7a8a6d399a2ecb4e6d9e561c6b557 /src/input/frontend | |
parent | 617e4c768616868a3e306668630efdfca69604d7 (diff) |
Splitting of QAxisInput
Placed buttons and scale into a new class
named QButtonAxisInput
Change-Id: I0e8407dc361d9d6eda38973a8950f77b17119467
Task-number: QTBUG-51474
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input/frontend')
-rw-r--r-- | src/input/frontend/frontend.pri | 3 | ||||
-rw-r--r-- | src/input/frontend/qaxisinput.cpp | 37 | ||||
-rw-r--r-- | src/input/frontend/qaxisinput.h | 11 | ||||
-rw-r--r-- | src/input/frontend/qaxisinput_p.h | 5 | ||||
-rw-r--r-- | src/input/frontend/qbuttonaxisinput.cpp | 115 | ||||
-rw-r--r-- | src/input/frontend/qbuttonaxisinput.h | 81 | ||||
-rw-r--r-- | src/input/frontend/qbuttonaxisinput_p.h | 83 | ||||
-rw-r--r-- | src/input/frontend/qinputaspect.cpp | 3 |
8 files changed, 293 insertions, 45 deletions
diff --git a/src/input/frontend/frontend.pri b/src/input/frontend/frontend.pri index ba237b420..8cf3d5fa9 100644 --- a/src/input/frontend/frontend.pri +++ b/src/input/frontend/frontend.pri @@ -16,6 +16,7 @@ HEADERS += \ $$PWD/qaction.h \ $$PWD/qaxisinput.h \ $$PWD/qaxis.h \ + $$PWD/qbuttonaxisinput.h \ $$PWD/qlogicaldevice.h \ $$PWD/qinputdeviceintegration.h \ $$PWD/qinputdeviceintegration_p.h \ @@ -33,6 +34,7 @@ HEADERS += \ $$PWD/qactioninput_p.h \ $$PWD/qaxis_p.h \ $$PWD/qaxisinput_p.h \ + $$PWD/qbuttonaxisinput_p.h \ $$PWD/qlogicaldevice_p.h \ $$PWD/qaxissetting_p.h \ $$PWD/qinputsequence_p.h \ @@ -54,6 +56,7 @@ SOURCES += \ $$PWD/qaction.cpp \ $$PWD/qaxisinput.cpp \ $$PWD/qaxis.cpp \ + $$PWD/qbuttonaxisinput.cpp \ $$PWD/qlogicaldevice.cpp \ $$PWD/qinputdeviceintegration.cpp \ $$PWD/qabstractphysicaldevice.cpp \ diff --git a/src/input/frontend/qaxisinput.cpp b/src/input/frontend/qaxisinput.cpp index e5cb0c054..9c2f30d43 100644 --- a/src/input/frontend/qaxisinput.cpp +++ b/src/input/frontend/qaxisinput.cpp @@ -67,6 +67,11 @@ QAxisInput::QAxisInput(Qt3DCore::QNode *parent) { } +QAxisInput::QAxisInput(QAxisInputPrivate &dd, Qt3DCore::QNode *parent) + : QNode(dd, parent) +{ +} + void QAxisInput::setSourceDevice(QAbstractPhysicalDevice *sourceDevice) { Q_D(QAxisInput); @@ -86,21 +91,6 @@ QAbstractPhysicalDevice *QAxisInput::sourceDevice() const return d->m_sourceDevice; } -void QAxisInput::setScale(float scale) -{ - Q_D(QAxisInput); - if (d->m_scale != scale) { - d->m_scale = scale; - emit scaleChanged(scale); - } -} - -float QAxisInput::scale() const -{ - Q_D(const QAxisInput); - return d->m_scale; -} - void QAxisInput::setAxis(int axis) { Q_D(QAxisInput); @@ -116,21 +106,6 @@ int QAxisInput::axis() const return d->m_axis; } -void QAxisInput::setButtons(const QVariantList &buttons) -{ - Q_D(QAxisInput); - if (buttons != d->m_buttons) { - d->m_buttons = buttons; - emit buttonsChanged(buttons); - } -} - -QVariantList QAxisInput::buttons() const -{ - Q_D(const QAxisInput); - return d->m_buttons; -} - Qt3DCore::QNodeCreatedChangeBasePtr QAxisInput::createNodeCreationChange() const { auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QAxisInputData>::create(this); @@ -139,8 +114,6 @@ Qt3DCore::QNodeCreatedChangeBasePtr QAxisInput::createNodeCreationChange() const Q_D(const QAxisInput); data.sourceDeviceId = qIdForNode(d->m_sourceDevice); data.axis = d->m_axis; - data.buttons = d->m_buttons; - data.scale = d->m_scale; return creationChange; } diff --git a/src/input/frontend/qaxisinput.h b/src/input/frontend/qaxisinput.h index 1156011e3..da840f25a 100644 --- a/src/input/frontend/qaxisinput.h +++ b/src/input/frontend/qaxisinput.h @@ -55,29 +55,24 @@ class QT3DINPUTSHARED_EXPORT QAxisInput : public Qt3DCore::QNode { Q_OBJECT Q_PROPERTY(Qt3DInput::QAbstractPhysicalDevice *sourceDevice READ sourceDevice WRITE setSourceDevice NOTIFY sourceDeviceChanged) - Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(int axis READ axis WRITE setAxis NOTIFY axisChanged) - Q_PROPERTY(QVariantList buttons READ buttons WRITE setButtons NOTIFY buttonsChanged) public: explicit QAxisInput(Qt3DCore::QNode *parent = nullptr); QAbstractPhysicalDevice *sourceDevice() const; - float scale() const; int axis() const; - QVariantList buttons() const; public Q_SLOTS: void setSourceDevice(QAbstractPhysicalDevice *sourceDevice); - void setScale(float scale); void setAxis(int axis); - void setButtons(const QVariantList &buttons); Q_SIGNALS: void sourceDeviceChanged(QAbstractPhysicalDevice *sourceDevice); - void scaleChanged(float scale); void axisChanged(int axis); - void buttonsChanged(const QVariantList &buttons); + +protected: + QAxisInput(QAxisInputPrivate &dd, QNode *parent = nullptr); private: Q_DECLARE_PRIVATE(QAxisInput) diff --git a/src/input/frontend/qaxisinput_p.h b/src/input/frontend/qaxisinput_p.h index 36087564d..cb025ff50 100644 --- a/src/input/frontend/qaxisinput_p.h +++ b/src/input/frontend/qaxisinput_p.h @@ -67,22 +67,17 @@ public: QAxisInputPrivate() : Qt3DCore::QNodePrivate() , m_sourceDevice(nullptr) - , m_scale(0.0f) , m_axis(-1) {} - QVariantList m_buttons; QAbstractPhysicalDevice *m_sourceDevice; - float m_scale; int m_axis; }; struct QAxisInputData { Qt3DCore::QNodeId sourceDeviceId; - QVariantList buttons; // TODO: Replace with QVector<int> int axis; - float scale; }; } // Qt3DInput diff --git a/src/input/frontend/qbuttonaxisinput.cpp b/src/input/frontend/qbuttonaxisinput.cpp new file mode 100644 index 000000000..cd74cc8da --- /dev/null +++ b/src/input/frontend/qbuttonaxisinput.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbuttonaxisinput.h" +#include "qbuttonaxisinput_p.h" +#include <Qt3DInput/qabstractphysicaldevice.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +/*! + * \qmltype ButtonAxisInput + * \instantiates Qt3DInput::QButtonAxisInput + * \inqmlmodule Qt3D.Input + * \since 5.7 + * \TODO + * + */ + +/*! + * \class Qt3DInput::QButtonAxisInput + * \inmodule Qt3DInput + * \since 5.7 + * \TODO + * + */ +QButtonAxisInput::QButtonAxisInput(Qt3DCore::QNode *parent) + : QAxisInput(*new QButtonAxisInputPrivate, parent) +{ +} + +void QButtonAxisInput::setScale(float scale) +{ + Q_D(QButtonAxisInput); + if (d->m_scale != scale) { + d->m_scale = scale; + emit scaleChanged(scale); + } +} + +float QButtonAxisInput::scale() const +{ + Q_D(const QButtonAxisInput); + return d->m_scale; +} + +void QButtonAxisInput::setButtons(const QVariantList &buttons) +{ + Q_D(QButtonAxisInput); + if (buttons != d->m_buttons) { + d->m_buttons = buttons; + emit buttonsChanged(buttons); + } +} + +QVariantList QButtonAxisInput::buttons() const +{ + Q_D(const QButtonAxisInput); + return d->m_buttons; +} + +Qt3DCore::QNodeCreatedChangeBasePtr QButtonAxisInput::createNodeCreationChange() const +{ + auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QButtonAxisInputData>::create(this); + auto &data = creationChange->data; + + Q_D(const QButtonAxisInput); + data.sourceDeviceId = qIdForNode(d->m_sourceDevice); + data.axis = d->m_axis; + data.buttons = d->m_buttons; + data.scale = d->m_scale; + + return creationChange; +} + +} // Qt3DInput + +QT_END_NAMESPACE diff --git a/src/input/frontend/qbuttonaxisinput.h b/src/input/frontend/qbuttonaxisinput.h new file mode 100644 index 000000000..9dda97a78 --- /dev/null +++ b/src/input/frontend/qbuttonaxisinput.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DINPUT_QBUTTONAXISINPUT_H +#define QT3DINPUT_QBUTTONAXISINPUT_H + +#include <Qt3DInput/qt3dinput_global.h> +#include <Qt3DInput/QAxisInput> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +class QButtonAxisInputPrivate; + +class QT3DINPUTSHARED_EXPORT QButtonAxisInput : public QAxisInput +{ + Q_OBJECT + Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged) + Q_PROPERTY(QVariantList buttons READ buttons WRITE setButtons NOTIFY buttonsChanged) + +public: + explicit QButtonAxisInput(Qt3DCore::QNode *parent = nullptr); + + float scale() const; + QVariantList buttons() const; + +public Q_SLOTS: + void setScale(float scale); + void setButtons(const QVariantList &buttons); + +Q_SIGNALS: + void scaleChanged(float scale); + void buttonsChanged(const QVariantList &buttons); + +private: + Q_DECLARE_PRIVATE(QButtonAxisInput) + Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const Q_DECL_OVERRIDE; +}; + +} // Qt3DInput + +QT_END_NAMESPACE + +#endif // QT3DINPUT_QBUTTONAXISINPUT_H diff --git a/src/input/frontend/qbuttonaxisinput_p.h b/src/input/frontend/qbuttonaxisinput_p.h new file mode 100644 index 000000000..53f2df698 --- /dev/null +++ b/src/input/frontend/qbuttonaxisinput_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DINPUT_QBUTTONAXISINPUT_P_H +#define QT3DINPUT_QBUTTONAXISINPUT_P_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 <Qt3DInput/private/qaxisinput_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +class QButtonAxisInputPrivate : public QAxisInputPrivate +{ +public: + QButtonAxisInputPrivate() + : QAxisInputPrivate() + , m_scale(0.0f) + {} + + QVariantList m_buttons; + float m_scale; +}; + +struct QButtonAxisInputData : public QAxisInputData +{ + QVariantList buttons; // TODO: Replace with QVector<int> + float scale; +}; + +} // Qt3DInput + +QT_END_NAMESPACE + +#endif // QT3DINPUT_QBUTTONAXISINPUT_P_H + diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp index e78b65057..0169be233 100644 --- a/src/input/frontend/qinputaspect.cpp +++ b/src/input/frontend/qinputaspect.cpp @@ -40,6 +40,7 @@ #include "qinputaspect.h" #include "qinputaspect_p.h" #include "inputhandler_p.h" +#include "buttonaxisinput_p.h" #include "keyboarddevice_p.h" #include "keyboardhandler_p.h" #include "mousedevice_p.h" @@ -64,6 +65,7 @@ #include <Qt3DInput/qaxisinput.h> #include <Qt3DInput/qaxissetting.h> #include <Qt3DInput/qactioninput.h> +#include <Qt3DInput/qbuttonaxisinput.h> #include <Qt3DInput/qinputchord.h> #include <Qt3DInput/qinputsequence.h> #include <Qt3DInput/qlogicaldevice.h> @@ -117,6 +119,7 @@ QInputAspect::QInputAspect(QObject *parent) registerBackendType<QMouseHandler>(QBackendNodeMapperPtr(new Input::MouseHandlerFunctor(d_func()->m_inputHandler.data()))); registerBackendType<QAxis>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::Axis, Input::AxisManager>(d_func()->m_inputHandler->axisManager()))); registerBackendType<QAxisInput>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::AxisInput, Input::AxisInputManager>(d_func()->m_inputHandler->axisInputManager()))); + registerBackendType<QButtonAxisInput>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::ButtonAxisInput, Input::ButtonAxisInputManager>(d_func()->m_inputHandler->buttonAxisInputManager()))); registerBackendType<QAxisSetting>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::AxisSetting, Input::AxisSettingManager>(d_func()->m_inputHandler->axisSettingManager()))); registerBackendType<Qt3DInput::QAction>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::Action, Input::ActionManager>(d_func()->m_inputHandler->actionManager()))); registerBackendType<QActionInput>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::ActionInput, Input::ActionInputManager>(d_func()->m_inputHandler->actionInputManager()))); |