From 7a94c109e6805b35150522b6714f04e63d751888 Mon Sep 17 00:00:00 2001 From: Juha Vuolle Date: Thu, 29 Sep 2022 17:53:56 +0300 Subject: Remove disabled sensor gesture code Support for sensor gestures in their then-current form was removed in Qt 6 (QTBUG-95747). This commit removes the disabled code. This is to avoid distraction when keeping the repository up-to-date with rest of Qt. The gestures may be reintroduced in some shape or form in the future (QTBUG-97066). For those reference purposes the old code can be found in the git history. Fixes: QTBUG-107065 Change-Id: If2c50171f84d483dde55600422d138d550124bdc Reviewed-by: Lorn Potter --- src/sensors/gestures/qsensorgesture.cpp | 214 --------------------- src/sensors/gestures/qsensorgesture.h | 53 ----- src/sensors/gestures/qsensorgesture_p.h | 49 ----- src/sensors/gestures/qsensorgesturemanager.cpp | 102 ---------- src/sensors/gestures/qsensorgesturemanager.h | 41 ---- .../gestures/qsensorgesturemanagerprivate.cpp | 143 -------------- .../gestures/qsensorgesturemanagerprivate_p.h | 62 ------ .../gestures/qsensorgestureplugininterface.cpp | 61 ------ .../gestures/qsensorgestureplugininterface.h | 31 --- src/sensors/gestures/qsensorgesturerecognizer.cpp | 171 ---------------- src/sensors/gestures/qsensorgesturerecognizer.h | 47 ----- 11 files changed, 974 deletions(-) delete mode 100644 src/sensors/gestures/qsensorgesture.cpp delete mode 100644 src/sensors/gestures/qsensorgesture.h delete mode 100644 src/sensors/gestures/qsensorgesture_p.h delete mode 100644 src/sensors/gestures/qsensorgesturemanager.cpp delete mode 100644 src/sensors/gestures/qsensorgesturemanager.h delete mode 100644 src/sensors/gestures/qsensorgesturemanagerprivate.cpp delete mode 100644 src/sensors/gestures/qsensorgesturemanagerprivate_p.h delete mode 100644 src/sensors/gestures/qsensorgestureplugininterface.cpp delete mode 100644 src/sensors/gestures/qsensorgestureplugininterface.h delete mode 100644 src/sensors/gestures/qsensorgesturerecognizer.cpp delete mode 100644 src/sensors/gestures/qsensorgesturerecognizer.h (limited to 'src/sensors/gestures') diff --git a/src/sensors/gestures/qsensorgesture.cpp b/src/sensors/gestures/qsensorgesture.cpp deleted file mode 100644 index dd1fdf80..00000000 --- a/src/sensors/gestures/qsensorgesture.cpp +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#include -#include -#include - -#include "qsensorgesture.h" -#include "qsensorgesture_p.h" -#include "qsensorgesturemanager.h" - -#include - -/*! - \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(ptr) will - not work.} - - \sa QSensorGestureRecognizer - - You may use QSensorGestureManager to obtain the systems known sensor gesture ids. - - \sa QSensorGestureManager - */ - -/*! - \fn void QSensorGesture::detected(QString) - Signals when the gesture has been recognized. - */ - -/*! - 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(); - for (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"); - - for (QSensorGestureRecognizer *recognizer : d_ptr->m_sensorRecognizers) { - for (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; - - for (QSensorGestureRecognizer *recognizer : d_ptr->m_sensorRecognizers) { - - Q_ASSERT(recognizer !=0); - - connect(recognizer,SIGNAL(detected(QString)), - this,SIGNAL(detected(QString)),Qt::UniqueConnection); - - //connect recognizer signals - for (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; - - for (QSensorGestureRecognizer *recognizer : d_ptr->m_sensorRecognizers) { - disconnect(recognizer,SIGNAL(detected(QString)), - this,SIGNAL(detected(QString))); - //disconnect recognizer signals - for (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 93282805..00000000 --- a/src/sensors/gestures/qsensorgesture.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#ifndef QSENSORGESTURE_H -#define QSENSORGESTURE_H - -#include -#include -#include - -#include -#include - -#include - -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 = nullptr); - ~QSensorGesture(); - - bool isActive(); - - QStringList validIds() const; - QStringList invalidIds() const; - - QStringList gestureSignals() const; - - void startDetection(); - void stopDetection(); - - // Pretend to be a Q_OBJECT - const QMetaObject *metaObject() const override; - int qt_metacall(QMetaObject::Call, int, void **) override; - -private: - QSensorGesturePrivate * d_ptr; - -Q_SIGNALS: - // these signals are created at runtime, along with - // gesture recognizer specific signals. - void detected(QString); -}; - -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 9794be66..00000000 --- a/src/sensors/gestures/qsensorgesture_p.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#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 -#include -#include -#include - -#include "qsensorgesture.h" -#include "qsensorgesturemanager.h" -#include - -QT_BEGIN_NAMESPACE - -class QSensorGesturePrivate : public QObject -{ - -public: - QSensorGesturePrivate(QObject *parent = 0); - ~QSensorGesturePrivate(); - - QList 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 b754878f..00000000 --- a/src/sensors/gestures/qsensorgesturemanager.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#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 948a63cb..00000000 --- a/src/sensors/gestures/qsensorgesturemanager.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#ifndef QSENSORGESTUREMANAGER_P_H -#define QSENSORGESTUREMANAGER_P_H - -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QSensorGestureManagerPrivate; -class Q_SENSORS_EXPORT QSensorGestureManager : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QSensorGestureManager) - -public: - explicit QSensorGestureManager(QObject *parent = 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 d87823e2..00000000 --- a/src/sensors/gestures/qsensorgesturemanagerprivate.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#include -#include - -#include - -#include "qsensorgesturerecognizer.h" -#include "qsensorgesturemanagerprivate_p.h" -#include "qsensorgestureplugininterface.h" - -Q_GLOBAL_STATIC(QSensorGestureManagerPrivate, sensorGestureManagerPrivate) - -QT_BEGIN_NAMESPACE - -QSensorGestureManagerPrivate::QSensorGestureManagerPrivate(QObject *parent) : - QObject(parent) -{ - 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(plugin)) { - for (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() -{ - for (QObject *plugin : QPluginLoader::staticInstances()) - initPlugin(plugin); - - QList 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(plugins.at(i))) { - - if (pInterface->supportedIds().contains(recognizerId)) { - - if (!registeredSensorGestures.contains(recognizerId)) { - //create these recognizers - QList recognizers = pInterface->createRecognizers(); - - for (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; -} - -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 2a62d5f7..00000000 --- a/src/sensors/gestures/qsensorgesturemanagerprivate_p.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#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 -#include -#include -#include -#include -#include - -#include "qsensorgesture.h" -#include "qsensorgesturerecognizer.h" -#include "private/qglobal_p.h" - -QT_BEGIN_NAMESPACE - -class QFactoryLoader; - -class QSensorGestureManagerPrivate : public QObject -{ - Q_OBJECT -public: - explicit QSensorGestureManagerPrivate(QObject *parent = 0); - ~QSensorGestureManagerPrivate(); - - QMap registeredSensorGestures; - - QList 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); - - static QSensorGestureManagerPrivate * instance(); -Q_SIGNALS: - void newSensorGestureAvailable(); -}; - -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 c9e54f77..00000000 --- a/src/sensors/gestures/qsensorgestureplugininterface.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#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 fa98385d..00000000 --- a/src/sensors/gestures/qsensorgestureplugininterface.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#ifndef QSENSORGESTUREPLUGININTERFACE_H -#define QSENSORGESTUREPLUGININTERFACE_H - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QSensorGestureRecognizer; - -class Q_SENSORS_EXPORT QSensorGesturePluginInterface -{ -public: - QSensorGesturePluginInterface(); - virtual ~QSensorGesturePluginInterface(); - virtual QList 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 eb5dc32b..00000000 --- a/src/sensors/gestures/qsensorgesturerecognizer.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#include "qsensorgesturerecognizer.h" -#include "qsensorgesture_p.h" -#include "qsensorgesturemanager.h" - -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 &) - Signals when a gesture is recognized. Implementors can use this signal to send - recognizer-specific gestures, such as \c detected("shake_left") or implement - custom signals such as \c shakeLeft(). - - The custom signals are available in the QSensorGesture object at runtime. - */ - -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(); -} - -/*! - 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(); -} - -QT_END_NAMESPACE diff --git a/src/sensors/gestures/qsensorgesturerecognizer.h b/src/sensors/gestures/qsensorgesturerecognizer.h deleted file mode 100644 index 1d5a6513..00000000 --- a/src/sensors/gestures/qsensorgesturerecognizer.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#ifndef QSENSORGESTURERECOGNIZER_H -#define QSENSORGESTURERECOGNIZER_H - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class QSensorGestureRecognizerPrivate; -class Q_SENSORS_EXPORT QSensorGestureRecognizer : public QObject -{ - Q_OBJECT -public: - explicit QSensorGestureRecognizer(QObject *parent = 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 -- cgit v1.2.3