diff options
Diffstat (limited to 'src/sensors/gestures')
-rw-r--r-- | src/sensors/gestures/qsensorgesture.cpp | 252 | ||||
-rw-r--r-- | src/sensors/gestures/qsensorgesture.h | 94 | ||||
-rw-r--r-- | src/sensors/gestures/qsensorgesture_p.h | 85 | ||||
-rw-r--r-- | src/sensors/gestures/qsensorgesturemanager.cpp | 138 | ||||
-rw-r--r-- | src/sensors/gestures/qsensorgesturemanager.h | 77 | ||||
-rw-r--r-- | src/sensors/gestures/qsensorgesturemanagerprivate.cpp | 244 | ||||
-rw-r--r-- | src/sensors/gestures/qsensorgesturemanagerprivate_p.h | 111 | ||||
-rw-r--r-- | src/sensors/gestures/qsensorgestureplugininterface.cpp | 97 | ||||
-rw-r--r-- | src/sensors/gestures/qsensorgestureplugininterface.h | 67 | ||||
-rw-r--r-- | src/sensors/gestures/qsensorgesturerecognizer.cpp | 214 | ||||
-rw-r--r-- | src/sensors/gestures/qsensorgesturerecognizer.h | 83 | ||||
-rw-r--r-- | src/sensors/gestures/simulatorgesturescommon.cpp | 121 | ||||
-rw-r--r-- | src/sensors/gestures/simulatorgesturescommon_p.h | 92 |
13 files changed, 0 insertions, 1675 deletions
diff --git a/src/sensors/gestures/qsensorgesture.cpp b/src/sensors/gestures/qsensorgesture.cpp deleted file mode 100644 index b643998e..00000000 --- a/src/sensors/gestures/qsensorgesture.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 <QDir> -#include <QPluginLoader> -#include <QDebug> - -#include "qsensorgesture.h" -#include "qsensorgesture_p.h" -#include "qsensorgesturemanager.h" - -#include <private/qmetaobjectbuilder_p.h> - -/*! - \class QSensorGesture - \ingroup sensorgestures_main - \inmodule QtSensors - \since 5.1 - - \brief The QSensorGesture class represents one or more sensor gesture recognizers. - - In addition to the QSensorGesture::detected() signal, Sensor Gesture Recognizers can - have their own specific signals, and may be discovered through - QSensorGesture::gestureSignals(). - - \b {Note that QSensorGesture uses a custom meta-object in order to provide - recognizer-specific signals. This means it is not possible to sub-class - QSensorGesture and use Q_OBJECT. Also qobject_cast<QSensorGesture*>(ptr) will - not work.} - - \sa QSensorGestureRecognizer - - You may use QSensorGestureManager to obtain the systems known sensor gesture ids. - - \sa QSensorGestureManager - */ - -#ifdef Q_QDOC -/*! - \fn QSensorGesture::detected(QString gestureId) - Signals when the \a gestureId gesture has been recognized. - */ -#endif - -/*! - Constructs the sensor gesture, and initializes the \a ids list of recognizers, - with parent \a parent - */ -QSensorGesture::QSensorGesture(const QStringList &ids, QObject *parent) : - QObject(parent) -{ - d_ptr = new QSensorGesturePrivate(); - Q_FOREACH (const QString &id, ids) { - QSensorGestureRecognizer * rec = QSensorGestureManager::sensorGestureRecognizer(id); - if (rec != 0) { - d_ptr->m_sensorRecognizers.append(rec); - d_ptr->availableIds.append(id); - } else { - d_ptr->invalidIds.append(id); - //add to not available things - } - } - - d_ptr->meta = 0; - - QMetaObjectBuilder builder; - builder.setSuperClass(&QObject::staticMetaObject); - builder.setClassName("QSensorGesture"); - - Q_FOREACH (QSensorGestureRecognizer *recognizer, d_ptr->m_sensorRecognizers) { - Q_FOREACH (const QString &gesture, recognizer->gestureSignals()) { - QMetaMethodBuilder b = builder.addSignal(gesture.toLatin1()); - if (!d_ptr->localGestureSignals.contains(QLatin1String(b.signature()))) - d_ptr->localGestureSignals.append(QLatin1String(b.signature())); - } - recognizer->createBackend(); - } - d_ptr->meta = builder.toMetaObject(); - - if (d_ptr->m_sensorRecognizers.count() > 0) { - d_ptr->valid = true; - } -} - -/*! - Destroy the QSensorGesture - */ -QSensorGesture::~QSensorGesture() -{ - stopDetection(); - if (d_ptr->meta) - free(d_ptr->meta); - delete d_ptr; -} - -/*! - Returns the gesture recognizer ids that were found. - */ -QStringList QSensorGesture::validIds() const -{ - return d_ptr->availableIds; -} - -/*! - Returns the gesture recognizer ids that were not found. - */ -QStringList QSensorGesture::invalidIds() const -{ - return d_ptr->invalidIds; -} - -/*! - Starts the gesture detection routines in the recognizer. - */ -void QSensorGesture::startDetection() -{ - if (d_ptr->m_sensorRecognizers.count() < 1) - return; - if (d_ptr->isActive) - return; - - Q_FOREACH (QSensorGestureRecognizer *recognizer, d_ptr->m_sensorRecognizers) { - - Q_ASSERT(recognizer !=0); - - connect(recognizer,SIGNAL(detected(QString)), - this,SIGNAL(detected(QString)),Qt::UniqueConnection); - - //connect recognizer signals - Q_FOREACH (QString method, recognizer->gestureSignals()) { - method.prepend(QLatin1String("2")); - connect(recognizer, method.toLatin1(), - this, method.toLatin1(), Qt::UniqueConnection); - } - - recognizer->startBackend(); - } - d_ptr->isActive = true; -} - -/*! - Stops the gesture detection routines. - */ -void QSensorGesture::stopDetection() -{ - if (d_ptr->m_sensorRecognizers.count() < 1) - return; - - if (!d_ptr->isActive) - return; - - Q_FOREACH (QSensorGestureRecognizer *recognizer, d_ptr->m_sensorRecognizers) { - disconnect(recognizer,SIGNAL(detected(QString)), - this,SIGNAL(detected(QString))); - //disconnect recognizer signals - Q_FOREACH (QString method,recognizer->gestureSignals()) { - method.prepend(QLatin1String("2")); - disconnect(recognizer, method.toLatin1(), - this, method.toLatin1()); - } - - recognizer->stopBackend(); - } - d_ptr->isActive = false; -} - -/*! - Returns all the possible gestures signals that may be emitted. - */ -QStringList QSensorGesture::gestureSignals() const -{ - if (d_ptr->m_sensorRecognizers.count() > 0) { - return d_ptr->localGestureSignals; - } - return QStringList(); -} - -/*! - Returns whether this gesture is active or not. - */ - -bool QSensorGesture::isActive() -{ - return d_ptr->isActive; -} - -/*! - \internal -*/ -const QMetaObject* QSensorGesture::metaObject() const -{ - return d_ptr->meta; -} -/*! - \internal -*/ -int QSensorGesture::qt_metacall(QMetaObject::Call c, int id, void **a) -{ - id = QObject::qt_metacall(c, id, a); - - if (id < 0 || !d_ptr->meta) - return id; - - QMetaObject::activate(this, d_ptr->meta, id, a); - return id; -} - -QSensorGesturePrivate::QSensorGesturePrivate(QObject *parent) - : QObject(parent),isActive(0), valid(0) -{ -} - -QSensorGesturePrivate::~QSensorGesturePrivate() -{ - -} diff --git a/src/sensors/gestures/qsensorgesture.h b/src/sensors/gestures/qsensorgesture.h deleted file mode 100644 index de727954..00000000 --- a/src/sensors/gestures/qsensorgesture.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 QSENSORGESTURE_H -#define QSENSORGESTURE_H - -#include <QtCore/QObject> -#include <QtCore/QStringList> -#include <QtSensors/qsensorsglobal.h> - -#include <QtCore/QList> -#include <QtCore/QMap> -#include <QtCore/QVector> - -#include <QtCore/qmetatype.h> - -QT_BEGIN_NAMESPACE - -class QSensorGesturePrivate; - -class Q_SENSORS_EXPORT QSensorGesture : public QObject -{ - //Do not use Q_OBJECT here -public: - explicit QSensorGesture(const QStringList &ids, QObject *parent = Q_NULLPTR); - ~QSensorGesture(); - - bool isActive(); - - QStringList validIds() const; - QStringList invalidIds() const; - - QStringList gestureSignals() const; - - void startDetection(); - void stopDetection(); - -private: - QSensorGesturePrivate * d_ptr; - - // ### fixme: Qt 6: Make public to enable Qt for Python bindings -private: - // Pretend to be a Q_OBJECT - const QMetaObject *metaObject() const override; - int qt_metacall(QMetaObject::Call, int, void **) override; - -#ifdef Q_QDOC -Q_SIGNALS: - // these signals are created at runtime, along with - // gesture recognizer specific signals. - void detected(QString); -#endif -}; - -QT_END_NAMESPACE - - -#endif // QSENSORGESTURE_H diff --git a/src/sensors/gestures/qsensorgesture_p.h b/src/sensors/gestures/qsensorgesture_p.h deleted file mode 100644 index 9ec80c8b..00000000 --- a/src/sensors/gestures/qsensorgesture_p.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 QSENSORGESTURE_P_H -#define QSENSORGESTURE_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 <QtSensors/QSensor> -#include <QtSensors/QAccelerometer> -#include <QtSensors/QAccelerometerFilter> -#include <QTimer> - -#include "qsensorgesture.h" -#include "qsensorgesturemanager.h" -#include <QtCore/private/qmetaobjectbuilder_p.h> - -QT_BEGIN_NAMESPACE - -class QSensorGesturePrivate : public QObject -{ - -public: - QSensorGesturePrivate(QObject *parent = 0); - ~QSensorGesturePrivate(); - - QList<QSensorGestureRecognizer *> m_sensorRecognizers; - - QByteArray metadata; - QMetaObject* meta; - bool isActive; - QStringList localGestureSignals; - QStringList availableIds; - QStringList invalidIds; - bool valid; -}; - - -QT_END_NAMESPACE - -#endif // QSENSORGESTURE_P_H diff --git a/src/sensors/gestures/qsensorgesturemanager.cpp b/src/sensors/gestures/qsensorgesturemanager.cpp deleted file mode 100644 index e99be929..00000000 --- a/src/sensors/gestures/qsensorgesturemanager.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 "qsensorgesturemanager.h" -#include "qsensorgesturemanagerprivate_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QSensorGestureManager - \ingroup sensorgestures_main - \inmodule QtSensors - \since 5.1 - - \brief The QSensorGestureManager class manages sensor gestures, registers and creates sensor gesture plugins. - - Sensor Gesture plugins register their recognizers using the registerSensorGestureRecognizer() function. - - \snippet sensorgestures/creating.cpp Receiving sensor gesture signals -*/ - -/*! - \fn QSensorGestureManager::newSensorGestureAvailable() - Signals when a new sensor gesture becomes available for use. - */ - -/*! - Constructs the QSensorGestureManager as a child of \a parent - */ -QSensorGestureManager::QSensorGestureManager(QObject *parent) - : QObject(parent) -{ - QSensorGestureManagerPrivate *d = QSensorGestureManagerPrivate::instance(); - if (!d) return; // hardly likely but just in case... - connect(d,SIGNAL(newSensorGestureAvailable()), - this,SIGNAL(newSensorGestureAvailable())); -} - -/*! - Destroy the QSensorGestureManager -*/ -QSensorGestureManager::~QSensorGestureManager() -{ -} - -/*! - Registers the sensor recognizer \a recognizer for use. - QSensorGestureManager retains ownership of the recognizer object. - Returns true unless the gesture has already been registered, in - which case the object is deleted. - - */ - - bool QSensorGestureManager::registerSensorGestureRecognizer(QSensorGestureRecognizer *recognizer) - { - QSensorGestureManagerPrivate *d = QSensorGestureManagerPrivate::instance(); - if (!d) { // hardly likely but just in case... - delete recognizer; - return false; - } - bool ok = d->registerSensorGestureRecognizer(recognizer); - if (!ok) - delete recognizer; - - return ok; - } - - - /*! - Returns the list of the currently registered gestures. - Includes all the standard built-ins as well as available plugins. - */ - QStringList QSensorGestureManager::gestureIds() const - { - QSensorGestureManagerPrivate *d = QSensorGestureManagerPrivate::instance(); - if (!d) return QStringList(); // hardly likely but just in case... - return d->gestureIds(); - } - - /*! - Returns the list of all the gesture signals for the registered \a gestureId gesture recognizer id. - */ - QStringList QSensorGestureManager::recognizerSignals(const QString &gestureId) const - { - QSensorGestureRecognizer *recognizer = sensorGestureRecognizer(gestureId); - if (recognizer != 0) - return recognizer->gestureSignals(); - else - return QStringList(); - } - -/*! - Returns the sensor gesture object for the recognizer \a id. - */ -QSensorGestureRecognizer *QSensorGestureManager::sensorGestureRecognizer(const QString &id) -{ - QSensorGestureManagerPrivate *d = QSensorGestureManagerPrivate::instance(); - if (!d) return 0; // hardly likely but just in case... - return d->sensorGestureRecognizer(id); -} - -QT_END_NAMESPACE diff --git a/src/sensors/gestures/qsensorgesturemanager.h b/src/sensors/gestures/qsensorgesturemanager.h deleted file mode 100644 index 1ddc84c2..00000000 --- a/src/sensors/gestures/qsensorgesturemanager.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 QSENSORGESTUREMANAGER_P_H -#define QSENSORGESTUREMANAGER_P_H - -#include <QtCore/QObject> -#include <QtCore/QStringList> - -#include <QtSensors/qsensorgesture.h> -#include <QtSensors/qsensorgesturerecognizer.h> - -QT_BEGIN_NAMESPACE - -class QSensorGestureManagerPrivate; -class Q_SENSORS_EXPORT QSensorGestureManager : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QSensorGestureManager) - -public: - explicit QSensorGestureManager(QObject *parent = Q_NULLPTR); - - ~QSensorGestureManager(); - - bool registerSensorGestureRecognizer(QSensorGestureRecognizer *recognizer); - - QStringList gestureIds() const; - QStringList recognizerSignals(const QString &recognizerId) const; - - static QSensorGestureRecognizer *sensorGestureRecognizer(const QString &id); - -Q_SIGNALS: - void newSensorGestureAvailable(); - -}; - - -QT_END_NAMESPACE - -#endif // QSENSORGESTUREMANAGER_P_H diff --git a/src/sensors/gestures/qsensorgesturemanagerprivate.cpp b/src/sensors/gestures/qsensorgesturemanagerprivate.cpp deleted file mode 100644 index 81e87de0..00000000 --- a/src/sensors/gestures/qsensorgesturemanagerprivate.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 <QDir> -#include <QLibraryInfo> - -#include <QtCore/private/qfactoryloader_p.h> - -#include "qsensorgesturerecognizer.h" -#include "qsensorgesturemanagerprivate_p.h" -#include "qsensorgestureplugininterface.h" - -#ifdef SIMULATOR_BUILD -#include "simulatorgesturescommon_p.h" -#endif - -Q_GLOBAL_STATIC(QSensorGestureManagerPrivate, sensorGestureManagerPrivate) - -QT_BEGIN_NAMESPACE - -QSensorGestureManagerPrivate::QSensorGestureManagerPrivate(QObject *parent) : - QObject(parent) -{ -#ifdef SIMULATOR_BUILD - SensorGesturesConnection *connection = new SensorGesturesConnection(this); - connect(connection,SIGNAL(sensorGestureDetected()), - this,SLOT(sensorGestureDetected())); - - connect(this,SIGNAL(newSensorGestures(QStringList)), - connection,SLOT(newSensorGestures(QStringList))); - - connect(this,SIGNAL(removeSensorGestures(QStringList)), - connection,SLOT(removeSensorGestures(QStringList))); -#endif - - loader = new QFactoryLoader("org.qt-project.QSensorGesturePluginInterface", QLatin1String("/sensorgestures")); - loadPlugins(); -} - -QSensorGestureManagerPrivate::~QSensorGestureManagerPrivate() -{ -// qDeleteAll(registeredSensorGestures); -// delete loader; -} - - - void QSensorGestureManagerPrivate::initPlugin(QObject *plugin) -{ - if (QSensorGesturePluginInterface *pInterface - = qobject_cast<QSensorGesturePluginInterface *>(plugin)) { - - Q_FOREACH (const QString &id, pInterface->supportedIds()) { - - if (!knownIds.contains(id)) - knownIds.append(id); - else - qWarning() << id <<"from the plugin" - << pInterface->name() - << "is already known."; - - } - plugins << plugin; - } else { - qWarning() << "Could not load "<< plugin; - } -} - - -/*! - Internal - Loads the sensorgesture plugins. - */ -void QSensorGestureManagerPrivate::loadPlugins() -{ - Q_FOREACH (QObject *plugin, QPluginLoader::staticInstances()) { - initPlugin(plugin); - } - QList<QJsonObject> meta = loader->metaData(); - for (int i = 0; i < meta.count(); i++) { - QObject *plugin = loader->instance(i); - initPlugin(plugin); - } -} - - -/*! - Internal - creates the requested recognizer. - */ - -bool QSensorGestureManagerPrivate::loadRecognizer(const QString &recognizerId) -{ - //if no plugin is used return true if this is a registered recognizer - - if (registeredSensorGestures.contains(recognizerId)) - return true; - - for (int i= 0; i < plugins.count(); i++) { - - if (QSensorGesturePluginInterface *pInterface - = qobject_cast<QSensorGesturePluginInterface *>(plugins.at(i))) { - - if (pInterface->supportedIds().contains(recognizerId)) { - - if (!registeredSensorGestures.contains(recognizerId)) { - //create these recognizers - QList <QSensorGestureRecognizer *> recognizers = pInterface->createRecognizers(); - - Q_FOREACH (QSensorGestureRecognizer *recognizer, recognizers) { - - if (registeredSensorGestures.contains(recognizer->id())) { - qWarning() << "Ignoring recognizer " << recognizer->id() << "from plugin" << pInterface->name() << "because it is already registered"; - delete recognizer; - } else { - registeredSensorGestures.insert(recognizer->id(),recognizer); - } - } - } - return true; - } - } - } - return false; -} - -bool QSensorGestureManagerPrivate::registerSensorGestureRecognizer(QSensorGestureRecognizer *recognizer) -{ - if (!knownIds.contains(recognizer->id())) { - knownIds.append(recognizer->id()); - Q_ASSERT (!registeredSensorGestures.contains(recognizer->id())); - recognizer->setParent(0); - registeredSensorGestures.insert(recognizer->id(),recognizer); - Q_EMIT newSensorGestureAvailable(); - - return true; - } - return false; -} - -QSensorGestureRecognizer *QSensorGestureManagerPrivate::sensorGestureRecognizer(const QString &id) -{ - QSensorGestureRecognizer *recognizer = 0; - - if (loadRecognizer(id)) { - recognizer= registeredSensorGestures.value(id); - } - - return recognizer; -} - -QStringList QSensorGestureManagerPrivate::gestureIds() -{ - return knownIds; -} - -#ifdef SIMULATOR_BUILD -void QSensorGestureManagerPrivate::sensorGestureDetected() -{ - QString str = get_qtSensorGestureData(); - - Q_FOREACH (const QString &id, gestureIds()) { - QSensorGestureRecognizer *recognizer = sensorGestureRecognizer(id); - if (recognizer != 0) { - Q_FOREACH (const QString &sig, recognizer->gestureSignals()) { - if (!sig.contains(QLatin1String("detected"))) { //weed out detected signals - QString tmp; - tmp = sig.left(sig.length() - 2); - if (str == tmp) { - // named signal for c++ - QMetaObject::invokeMethod(recognizer, str.toLocal8Bit(), Qt::DirectConnection); - // detected signal for qml and c++ - QMetaObject::invokeMethod(recognizer, "detected", Qt::DirectConnection, - Q_ARG(QString, str)); - break; - - } - } - } - } - } -} - -void QSensorGestureManagerPrivate::recognizerStarted(const QSensorGestureRecognizer *recognizer) -{ - QStringList list = recognizer->gestureSignals(); - list.removeOne(QLatin1String("detected(QString)")); - Q_EMIT newSensorGestures(list); -} - -void QSensorGestureManagerPrivate::recognizerStopped(const QSensorGestureRecognizer *recognizer) -{ - QStringList list = recognizer->gestureSignals(); - list.removeOne(QLatin1String("detected(QString)")); - Q_EMIT removeSensorGestures(list); -} - -#endif - -QSensorGestureManagerPrivate * QSensorGestureManagerPrivate::instance() -{ - QSensorGestureManagerPrivate *priv = sensorGestureManagerPrivate(); - // It's safe to return 0 because this is checked when used - //if (!priv) qFatal("Cannot return from QSensorGestureManagerPrivate::instance() because sensorGestureManagerPrivate() returned 0."); - return priv; -} - - -QT_END_NAMESPACE diff --git a/src/sensors/gestures/qsensorgesturemanagerprivate_p.h b/src/sensors/gestures/qsensorgesturemanagerprivate_p.h deleted file mode 100644 index 2ca4d648..00000000 --- a/src/sensors/gestures/qsensorgesturemanagerprivate_p.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 QSENSORGESTUREMANAGERPRIVATE_P_H -#define QSENSORGESTUREMANAGERPRIVATE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QObject> -#include <QMap> -#include <QStringList> -#include <QDebug> -#include <QSharedPointer> -#include <QPluginLoader> - -#include "qsensorgesture.h" -#include "qsensorgesturerecognizer.h" - -QT_BEGIN_NAMESPACE - -class QFactoryLoader; - -class QSensorGestureManagerPrivate : public QObject -{ - Q_OBJECT -public: - explicit QSensorGestureManagerPrivate(QObject *parent = 0); - ~QSensorGestureManagerPrivate(); - - QMap<QString, QSensorGestureRecognizer *> registeredSensorGestures; - - QList <QObject *> plugins; - - QFactoryLoader *loader; - void loadPlugins(); - bool loadRecognizer(const QString &id); - - QSensorGestureRecognizer *sensorGestureRecognizer(const QString &id); - - bool registerSensorGestureRecognizer(QSensorGestureRecognizer *recognizer); - QStringList gestureIds(); - QStringList knownIds; - void initPlugin(QObject *o); -#ifdef SIMULATOR_BUILD - void recognizerStarted(const QSensorGestureRecognizer *); - void recognizerStopped(const QSensorGestureRecognizer *); -#endif - - static QSensorGestureManagerPrivate * instance(); -Q_SIGNALS: - void newSensorGestureAvailable(); - -#ifdef SIMULATOR_BUILD -Q_SIGNALS: - void newSensorGestures(QStringList); - void removeSensorGestures(QStringList); - -private slots: - void sensorGestureDetected(); - -#endif -}; - -QT_END_NAMESPACE - -#endif // QSENSORGESTUREMANAGERPRIVATE_P_H diff --git a/src/sensors/gestures/qsensorgestureplugininterface.cpp b/src/sensors/gestures/qsensorgestureplugininterface.cpp deleted file mode 100644 index c80862e3..00000000 --- a/src/sensors/gestures/qsensorgestureplugininterface.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 "qsensorgestureplugininterface.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QSensorGesturePluginInterface - \ingroup sensorgestures_recognizer - \inmodule QtSensors - - \brief The QSensorGesturePluginInterface class is the pure virtual interface to sensor gesture - plugins. - - \since 5.1 - - The QSensorGesturePluginInterface class is implemented in sensor gesture plugins to register - sensor gesture recognizers with QSensorGestureManager. - - \sa {QtSensorGestures Plugins} -*/ - -/*! - \fn QSensorGesturePluginInterface::createRecognizers() - - Called by the manager to create the recognizers. - Plugins should initialize and register their recognizers using - QSensorGestureManager::registerSensorGestureRecognizer() here. - - \sa QSensorGestureManager -*/ - -/*! - \fn QSensorGesturePluginInterface::supportedIds() const - - Returns a list of the recognizer Id's that this plugin supports. - */ - - -/*! - \fn QSensorGesturePluginInterface::name() const - - Returns this plugins name. - */ - -/*! - Construct the QSensorGesturePluginInterface. -*/ -QSensorGesturePluginInterface::QSensorGesturePluginInterface() -{ -} - -/*! - Destroy the QSensorGesturePluginInterface. -*/ -QSensorGesturePluginInterface::~QSensorGesturePluginInterface() -{ -} - -QT_END_NAMESPACE diff --git a/src/sensors/gestures/qsensorgestureplugininterface.h b/src/sensors/gestures/qsensorgestureplugininterface.h deleted file mode 100644 index 3de9ab84..00000000 --- a/src/sensors/gestures/qsensorgestureplugininterface.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 QSENSORGESTUREPLUGININTERFACE_H -#define QSENSORGESTUREPLUGININTERFACE_H - -#include <QtCore/QObject> -#include <QtCore/QtGlobal> -#include <QtCore/qplugin.h> -#include <QtSensors/qsensorgesture.h> -#include <QtSensors/qsensorgesturerecognizer.h> - -QT_BEGIN_NAMESPACE - -class QSensorGestureRecognizer; - -class Q_SENSORS_EXPORT QSensorGesturePluginInterface -{ -public: - QSensorGesturePluginInterface(); - virtual ~QSensorGesturePluginInterface(); - virtual QList <QSensorGestureRecognizer *> createRecognizers() = 0; - virtual QStringList supportedIds() const = 0; - virtual QString name() const = 0; -}; - -Q_DECLARE_INTERFACE(QSensorGesturePluginInterface, "org.qt-project.QSensorGesturePluginInterface") - -QT_END_NAMESPACE - -#endif // QSENSORGESTUREPLUGININTERFACE_H diff --git a/src/sensors/gestures/qsensorgesturerecognizer.cpp b/src/sensors/gestures/qsensorgesturerecognizer.cpp deleted file mode 100644 index 9254da28..00000000 --- a/src/sensors/gestures/qsensorgesturerecognizer.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 "qsensorgesturerecognizer.h" -#include "qsensorgesture_p.h" - -#include "qsensorgesturemanager.h" -#ifdef SIMULATOR_BUILD -#include "qsensorgesturemanagerprivate_p.h" -#endif -QT_BEGIN_NAMESPACE - -/*! - \class QSensorGestureRecognizer - \ingroup sensorgestures_recognizer - \inmodule QtSensors - \since 5.1 - - \brief The QSensorGestureRecognizer class is the base class for a sensor gesture - recognizer. - - QSensorGesture recognizer developers should sub-class this to implement their own recognizer. - - All sensor gesture recognizers have a detected(QString) signal. Implementors can use this - and send recognizer specific gestures, such as detected("shake_left") or implement custom signals - such as shakeLeft(). - - These custom signals will be available in the QSensorGesture object at runtime. - - \sa QSensorGestureRecognizer::gestureSignals() - - */ - -/*! - \fn void QSensorGestureRecognizer::create() - - Called by QSensorGesture object constructor to create the recognizers backend. - - Implementors would use this to instantiate QSensors and connect signals. - - */ - -/*! - \fn QString QSensorGestureRecognizer::id() const - Returns the identifier for this recognizer. - */ -/*! - \fn bool QSensorGestureRecognizer::start() - - Called by QSensorGesture::startDetection() to start this recognizer. - Implementors should start the sensors. - Returns true if the operation is successful. - - */ -/*! - \fn bool QSensorGestureRecognizer::stop() - - Called by QSensorGesture::stopDetection() to stop this recognizer. - Returns true if the call succeeds, otherwise false. - - Implementors should stop the sensors. - - */ -/*! - \fn bool QSensorGestureRecognizer::isActive() - - Returns true if this recognizer is active, otherwise false. - */ - -/*! - \fn QSensorGestureRecognizer::detected(const QString &gestureId) - Signals when the gesture with id \a &gestureId been recognized. - */ - -class QSensorGestureRecognizerPrivate -{ -public: - bool initialized; - int count; -}; - - -/*! - Constructs the QSensorGestureRecognizer with \a parent as parent. - */ -QSensorGestureRecognizer::QSensorGestureRecognizer(QObject *parent) - :QObject(parent), - d_ptr(new QSensorGestureRecognizerPrivate()) -{ -} - -/*! - Destroy the QSensorGestureRecognizer -*/ -QSensorGestureRecognizer::~QSensorGestureRecognizer() -{ - delete d_ptr; -} - -/*! - Returns a list of signals that this recognizer supports. - - Note that all signals declared will be exported to the QSensorGesture - object. If you need to use signals that are not exported, you should use a private class - to do so. - - */ -QStringList QSensorGestureRecognizer::gestureSignals() const -{ - QStringList list; - bool ok = false; - for (int i = 0; i < this->metaObject()->methodCount(); i++) { - //weed out objectsignals and slots - const QByteArray sig(this->metaObject()->method(i).methodSignature()); - if (this->metaObject()->indexOfSignal(sig) != -1) { - if (sig.contains("detected")) - ok = true; - if (ok) - list.append(QString::fromLatin1(sig)); - } - } - return list; -} - -/*! - Calls QSensorGestureRecognizer::create() if the recognizer is valid. -*/ -void QSensorGestureRecognizer::createBackend() -{ - if (d_ptr->initialized) { - return; - } - d_ptr->initialized = true; - create(); -} - -/*! - Calls QSensorGestureRecognizer::start() if the recognizer isn't already initialized. - This is called by the QSensorGesture object, so please use that instead. - -\sa QSensorGesture::startDetection() - -*/ -void QSensorGestureRecognizer::startBackend() -{ - if (!d_ptr->initialized) { - qWarning() << "Not starting. Gesture Recognizer not initialized"; - return; - } - if (d_ptr->count++ == 0) { - start(); -#ifdef SIMULATOR_BUILD - QSensorGestureManagerPrivate::instance()->recognizerStarted(this); -#endif - } -} - -/*! - Calls QSensorGestureRecognizer::stop() if no other clients are using it. - This is called by the QSensorGesture object, so please use that instead. - -\sa QSensorGesture::stopDetection() -*/ -void QSensorGestureRecognizer::stopBackend() -{ - if (!d_ptr->initialized) { - qWarning() << "Not stopping. Gesture Recognizer not initialized"; - return; - } - if (--d_ptr->count == 0) { - stop(); -#ifdef SIMULATOR_BUILD - QSensorGestureManagerPrivate::instance()->recognizerStopped(this); -#endif - } -} - -QT_END_NAMESPACE diff --git a/src/sensors/gestures/qsensorgesturerecognizer.h b/src/sensors/gestures/qsensorgesturerecognizer.h deleted file mode 100644 index 27181983..00000000 --- a/src/sensors/gestures/qsensorgesturerecognizer.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 QSENSORGESTURERECOGNIZER_H -#define QSENSORGESTURERECOGNIZER_H - -#include <QtCore/QDebug> -#include <QtCore/QTimer> -#include <QtCore/QStringList> - -#include <QtSensors/qsensorgesture.h> - -QT_BEGIN_NAMESPACE - -class QSensorGestureRecognizerPrivate; -class Q_SENSORS_EXPORT QSensorGestureRecognizer : public QObject -{ - Q_OBJECT -public: - explicit QSensorGestureRecognizer(QObject *parent = Q_NULLPTR); - virtual ~QSensorGestureRecognizer(); - - virtual QString id() const = 0; - - virtual bool isActive() = 0; - - void startBackend(); - void stopBackend(); - void createBackend(); - - QStringList gestureSignals() const; - -Q_SIGNALS: - void detected(const QString &); - -protected: - virtual void create() = 0; - virtual bool start() = 0; - virtual bool stop() = 0; - -private: - QSensorGestureRecognizerPrivate * d_ptr; -}; - -QT_END_NAMESPACE - -#endif // QSENSORGESTURERECOGNIZER_H diff --git a/src/sensors/gestures/simulatorgesturescommon.cpp b/src/sensors/gestures/simulatorgesturescommon.cpp deleted file mode 100644 index b7860423..00000000 --- a/src/sensors/gestures/simulatorgesturescommon.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 "simulatorgesturescommon_p.h" - -#include <QtSimulator/version.h> -#include <QtSimulator/QtSimulator> - -#include <QDebug> -#include <QStringList> - -using namespace Simulator; - - -Q_GLOBAL_STATIC(QString, qtSensorGestureData) - -SensorGesturesConnection::SensorGesturesConnection(QObject *parent) - : QObject(parent) -{ - mConnection = new Connection(Connection::Client, QLatin1String("QtSimulator_Mobility_ServerName1.3.0.0"), - 0xbeef+1, Version(1,0,0,0), this); - mWorker = mConnection->connectToServer(Connection::simulatorHostName(true), 0xbeef+1); - - if (!mWorker) { - qWarning() << "Could not connect to server"; - return; - } - - mWorker->addReceiver(this); - mWorker->call("setRequestsSensorGestures"); -} - -SensorGesturesConnection::~SensorGesturesConnection() -{ - mWorker->call("setSensorGestures", QStringList()); - delete mWorker; -} - -void SensorGesturesConnection::setSensorGestureData(const QString &data) -{ - QString gesture = data; - if (data.contains(QLatin1String("detected"))) { - gesture.remove(QLatin1String("detected(")); - gesture.remove(QLatin1String(")")); - } - *qtSensorGestureData() = gesture; -} - -void SensorGesturesConnection::newSensorGestureDetected() -{ - emit sensorGestureDetected(); -} - -void SensorGesturesConnection::newSensorGestures(const QStringList &gestures) -{ - if (!mWorker) return; - - Q_FOREACH (const QString &gest, gestures) { - if (!gest.contains(QLatin1String("detected"))) { - QString tmp = gest.left(gest.length()-2); - if (!allGestures.contains(tmp)) { - allGestures.append(tmp); - } - } - } - - mWorker->call("setSensorGestures", allGestures); -} - -void SensorGesturesConnection::removeSensorGestures(const QStringList &gestures) -{ - Q_FOREACH (const QString &gest, gestures) { - QString tmp = gest.left(gest.length()-2); - if (allGestures.contains(tmp)) { - allGestures.removeOne(tmp); - } - } - mWorker->call("setSensorGestures", allGestures); -} - -QString get_qtSensorGestureData() -{ - return *qtSensorGestureData(); -} - diff --git a/src/sensors/gestures/simulatorgesturescommon_p.h b/src/sensors/gestures/simulatorgesturescommon_p.h deleted file mode 100644 index 63022238..00000000 --- a/src/sensors/gestures/simulatorgesturescommon_p.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors 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 SIMULATORGESTURESCOMMON_H -#define SIMULATORGESTURESCOMMON_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtSimulator/connection.h> -#include <QtSimulator/connectionworker.h> -#include <QStringList> - -class QTimer; - -namespace Simulator -{ - class Connection; - class ConnectionWorker; -} - -class SensorGesturesConnection : public QObject -{ - Q_OBJECT -public: - explicit SensorGesturesConnection(QObject *parent = 0); - virtual ~SensorGesturesConnection(); - -Q_SIGNALS: - void sensorGestureDetected(); - -public slots: - void setSensorGestureData(const QString &); - void newSensorGestureDetected(); - void newSensorGestures(const QStringList &gestures); - void removeSensorGestures(const QStringList &gestures); - -private: - Simulator::Connection *mConnection; - Simulator::ConnectionWorker *mWorker; - QStringList allGestures; - -}; - -QString get_qtSensorGestureData(); - -#endif //SIMULATORGESTURESCOMMON_H - |