summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/examples/sensors.qdoc8
-rw-r--r--examples/sensors/qmlsensorgestures/plugin/plugin.pro27
-rw-r--r--examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp78
-rw-r--r--examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h64
-rw-r--r--examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp89
-rw-r--r--examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.h70
-rw-r--r--examples/sensors/qmlsensorgestures/qml_app/Button.qml129
-rw-r--r--examples/sensors/qmlsensorgestures/qml_app/Gesture.qml113
-rw-r--r--examples/sensors/qmlsensorgestures/qml_app/GestureList.qml131
-rw-r--r--examples/sensors/qmlsensorgestures/qml_app/GestureView.qml146
-rw-r--r--examples/sensors/qmlsensorgestures/qml_app/GesturesView.qml156
-rwxr-xr-xexamples/sensors/qmlsensorgestures/qml_app/icon.pngbin0 -> 2298 bytes
-rw-r--r--examples/sensors/qmlsensorgestures/qml_app/info.json14
-rw-r--r--examples/sensors/qmlsensorgestures/qml_app/qml_app.qmlproject18
-rw-r--r--examples/sensors/qmlsensorgestures/qmlsensorgestures.pro5
-rw-r--r--examples/sensors/sensors.pro8
-rw-r--r--src/imports/sensors2/qsensor2gesture.cpp266
-rw-r--r--src/imports/sensors2/qsensor2gesture.h106
-rw-r--r--src/imports/sensors2/sensors2.cpp2
-rw-r--r--src/imports/sensors2/sensors2.pro8
-rw-r--r--tests/auto/qtsensors5/tst_qtsensors5.cpp1
-rw-r--r--tests/auto/sensors2qmlapi/qtemplategestureplugin.cpp81
-rw-r--r--tests/auto/sensors2qmlapi/qtemplategestureplugin.h65
-rw-r--r--tests/auto/sensors2qmlapi/qtemplaterecognizer.cpp136
-rw-r--r--tests/auto/sensors2qmlapi/qtemplaterecognizer.h93
-rw-r--r--tests/auto/sensors2qmlapi/sensors2qmlapi.pro10
-rw-r--r--tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp124
27 files changed, 1941 insertions, 7 deletions
diff --git a/doc/src/examples/sensors.qdoc b/doc/src/examples/sensors.qdoc
index 9de40042..7d4ee4c2 100644
--- a/doc/src/examples/sensors.qdoc
+++ b/doc/src/examples/sensors.qdoc
@@ -69,6 +69,14 @@
*/
/*!
+ \example sensors/qmlsensorgestures/qml_app
+ \title SensorGesture QML Element example
+ \ingroup qtsensors-examples
+
+ This example demonstrates use of the SensorGesture QML element.
+*/
+
+/*!
\example sensors/maze
\title Maze
\brief The Maze example demonstrates the TiltSensor QML element
diff --git a/examples/sensors/qmlsensorgestures/plugin/plugin.pro b/examples/sensors/qmlsensorgestures/plugin/plugin.pro
new file mode 100644
index 00000000..ab250884
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/plugin/plugin.pro
@@ -0,0 +1,27 @@
+TEMPLATE = lib
+CONFIG += plugin
+
+TARGET = qtsensorgestures_counterplugin
+
+QT += sensors
+DESTDIR = $$QT.sensors.plugins/sensorgestures
+
+# Input
+HEADERS += \
+ qcountergestureplugin.h \
+ qcounterrecognizer.h
+SOURCES += \
+ qcountergestureplugin.cpp \
+ qcounterrecognizer.cpp
+
+target.path += $$[QT_INSTALL_PLUGINS]/sensorgestures
+INSTALLS += target
+
+
+
+
+
+
+
+
+
diff --git a/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp b/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp
new file mode 100644
index 00000000..21b819aa
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtPlugin>
+#include <QStringList>
+#include <QObject>
+
+#include "qcountergestureplugin.h"
+#include <qsensorgestureplugininterface.h>
+#include <qsensorgesturemanager.h>
+#include "qcounterrecognizer.h"
+
+
+QCounterGesturePlugin::QCounterGesturePlugin()
+{
+}
+
+QCounterGesturePlugin::~QCounterGesturePlugin()
+{
+}
+
+QStringList QCounterGesturePlugin::supportedIds() const
+{
+ QStringList list;
+ list << "QtSensors.SecondCounter";
+ return list;
+}
+
+
+QList <QSensorGestureRecognizer *> QCounterGesturePlugin::createRecognizers()
+{
+ QList <QSensorGestureRecognizer *> recognizers;
+
+ QSensorGestureRecognizer *sRec = new QCounterGestureRecognizer(this);
+ recognizers.append(sRec);
+
+ return recognizers;
+}
+
+Q_EXPORT_PLUGIN2(QCounterGestureRecognizer, QCounterGesturePlugin)
+
diff --git a/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h b/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h
new file mode 100644
index 00000000..33075f43
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOUNTERGESTUREPLUGIN_H
+#define QCOUNTERGESTUREPLUGIN_H
+
+#include <QObject>
+#include <QStringList>
+
+#include <qsensorgestureplugininterface.h>
+
+class QCounterGesturePlugin : public QObject, QSensorGesturePluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QSensorGesturePluginInterface)
+public:
+ explicit QCounterGesturePlugin();
+ ~QCounterGesturePlugin();
+
+ QList <QSensorGestureRecognizer *> createRecognizers();
+
+ QStringList gestureSignals() const;
+ QStringList supportedIds() const;
+ QString name() const { return "CounterGestures"; }
+};
+
+#endif // QCOUNTERGESTUREPLUGIN_H
diff --git a/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp b/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp
new file mode 100644
index 00000000..0856f734
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include <QTimer>
+
+#include "qcounterrecognizer.h"
+
+QCounterGestureRecognizer::QCounterGestureRecognizer(QObject *parent)
+ : QSensorGestureRecognizer(parent)
+{
+}
+
+QCounterGestureRecognizer::~QCounterGestureRecognizer()
+{
+
+}
+
+void QCounterGestureRecognizer::create()
+{
+ connect(&_timer,SIGNAL(timeout()),this,SLOT(timeout()));
+ _timer.setInterval(1000);
+}
+
+bool QCounterGestureRecognizer::start()
+{
+ Q_EMIT detected(id());
+ _timer.start();
+ return _timer.isActive();
+}
+
+bool QCounterGestureRecognizer::stop()
+{
+ _timer.stop();
+ return true;
+}
+
+
+bool QCounterGestureRecognizer::isActive()
+{
+ return _timer.isActive();
+}
+
+QString QCounterGestureRecognizer::id() const
+{
+ return QString("QtSensors.SecondCounter");
+}
+
+void QCounterGestureRecognizer::timeout()
+{
+ Q_EMIT detected(id());
+}
diff --git a/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.h b/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.h
new file mode 100644
index 00000000..5a7464e9
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOUNTERGESTURERECOGNIZER_H
+#define QCOUNTERGESTURERECOGNIZER_H
+
+#include <QDebug>
+#include <QtCore/QTimer>
+#include <qsensorgesturerecognizer.h>
+
+class QCounterGestureRecognizer : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+public:
+
+ QCounterGestureRecognizer(QObject *parent = 0);
+ ~QCounterGestureRecognizer();
+
+ void create();
+
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+private slots:
+ void timeout();
+
+private:
+ QTimer _timer;
+};
+
+#endif // QCOUNTERGESTURERECOGNIZER_H
diff --git a/examples/sensors/qmlsensorgestures/qml_app/Button.qml b/examples/sensors/qmlsensorgestures/qml_app/Button.qml
new file mode 100644
index 00000000..311dd166
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/qml_app/Button.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//Import the declarative plugins
+import QtQuick 2.0
+
+//Implementation of the Button control.
+Item {
+ id: button
+ width: 30
+ height: 30
+ property alias buttonText: innerText.text;
+ property color color: "white"
+ property color hoverColor: "#aaaaaa"
+ property color pressColor: "slategray"
+ property int fontSize: 10
+ property int borderWidth: 1
+ property int borderRadius: 2
+ scale: state === "Pressed" ? 0.96 : 1.0
+ onEnabledChanged: state = ""
+ signal clicked
+
+ //define a scale animation
+ Behavior on scale {
+ NumberAnimation {
+ duration: 100
+ easing.type: Easing.InOutQuad
+ }
+ }
+
+ //Rectangle to draw the button
+ Rectangle {
+ id: rectangleButton
+ anchors.fill: parent
+ radius: borderRadius
+ color: button.enabled ? button.color : "grey"
+ border.width: borderWidth
+ border.color: "black"
+
+ Text {
+ id: innerText
+ font.pointSize: fontSize
+ anchors.centerIn: parent
+ }
+ }
+
+ //change the color of the button in differen button states
+ states: [
+ State {
+ name: "Hovering"
+ PropertyChanges {
+ target: rectangleButton
+ color: hoverColor
+ }
+ },
+ State {
+ name: "Pressed"
+ PropertyChanges {
+ target: rectangleButton
+ color: pressColor
+ }
+ }
+ ]
+
+ //define transmission for the states
+ transitions: [
+ Transition {
+ from: ""; to: "Hovering"
+ ColorAnimation { duration: 200 }
+ },
+ Transition {
+ from: "*"; to: "Pressed"
+ ColorAnimation { duration: 10 }
+ }
+ ]
+
+ //Mouse area to react on click events
+ MouseArea {
+ hoverEnabled: true
+ anchors.fill: button
+ onEntered: { button.state='Hovering'}
+ onExited: { button.state=''}
+ onClicked: { button.clicked();}
+ onPressed: { button.state="Pressed" }
+ onReleased: {
+ if (containsMouse)
+ button.state="Hovering";
+ else
+ button.state="";
+ }
+ }
+}
diff --git a/examples/sensors/qmlsensorgestures/qml_app/Gesture.qml b/examples/sensors/qmlsensorgestures/qml_app/Gesture.qml
new file mode 100644
index 00000000..0e41578a
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/qml_app/Gesture.qml
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//Import the declarative plugins
+import QtQuick 2.0
+import QtSensors 5.0
+
+/* Layout
+--------------------------------------------------
+| ---------------------------------------------- |
+| | | |
+| | | |
+| | | |
+| | gestureList | |
+| | | |
+| | | |
+| | | |
+| | | |
+| | | |
+| | | |
+| | | |
+| | | |
+| ---------------------------------------------- |
+| ---------------------------------------------- |
+| | | |
+| | gesture | |
+| | | |
+| | | |
+| ---------------------------------------------- |
+| ---------------------------------------------- |
+| | | |
+| | gestures | |
+| | | |
+| | | |
+| ---------------------------------------------- |
+--------------------------------------------------
+*/
+
+Rectangle {
+ id: viewArea
+ width: 320
+ height: 480
+ color: '#d6d6d6'
+
+ GestureList {
+ id: gestureList
+ parent: viewArea
+ anchors.left: viewArea.left
+ anchors.top: viewArea.top
+ anchors.right: viewArea.right
+ height: viewArea.height / 2
+ onSelectedGestureChanged: {
+ gesture.enabled = false;
+ gesture.gestureid = gestureList.selectedGesture;
+ gesture.gesturetitle = gestureList.selectedGesture;
+ }
+ }
+
+ GestureView {
+ id: gesture
+ parent: viewArea
+ anchors.left: viewArea.left
+ anchors.top: gestureList.bottom
+ anchors.right: viewArea.right
+ height: 100
+ }
+
+ GesturesView {
+ id: gestures
+ parent: viewArea
+ anchors.left: viewArea.left
+ anchors.top: gesture.bottom
+ anchors.right: viewArea.right
+ height: 100
+ }
+}
diff --git a/examples/sensors/qmlsensorgestures/qml_app/GestureList.qml b/examples/sensors/qmlsensorgestures/qml_app/GestureList.qml
new file mode 100644
index 00000000..6edfd4c9
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/qml_app/GestureList.qml
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//Import the declarative plugins
+import QtQuick 2.0
+import QtSensors 5.0
+
+/* Layout
+ gesturerect
+ /
+---------------------------------------/
+|-------------------------------------|
+|| labelGesture ||
+|-------------------------------------|
+|-------------------------------------|
+|| |<---- gestureListRect
+|| ||
+|| ||
+|| gestureList ||
+|| ||
+|| ||
+|| ||
+|| ||
+|| ||
+|| ||
+|-------------------------------------|
+*/
+
+Rectangle {
+ id: gesturerect
+ border.width: 1
+ anchors.margins: 5
+
+ property string selectedGesture: "";
+ signal selectedGestureChanged();
+
+ SensorGesture {
+ id: gesture
+ }
+
+ Text {
+ id: labelGesture
+ anchors.top: gesturerect.top
+ anchors.left: gesturerect.left
+ anchors.right: gesturerect.right
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 30
+ font.bold: true
+ text: "Gestures"
+ }
+
+ Rectangle {
+ id: gestureListRect
+ border.width: 1
+ anchors.top: labelGesture.bottom
+ anchors.left: gesturerect.left
+ anchors.right: gesturerect.right
+ anchors.bottom: gesturerect.bottom
+ anchors.margins: 5
+
+ ListView {
+ id: gestureList
+ anchors.fill: gestureListRect
+ anchors.margins: 5
+ model: gesture.availableGestures
+ focus: true
+ currentIndex: -1
+ delegate: gestureListDelegate
+ }
+
+ Component {
+ id: gestureListDelegate
+
+ Rectangle {
+ width: gestureList.width
+ height: itemText.height
+ color: (index === gestureList.currentIndex ? "#999933" : "#FFFFFF")
+
+ Text {
+ id: itemText
+ text: model.modelData
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ gestureList.currentIndex = index;
+ selectedGesture = model.modelData;
+ selectedGestureChanged();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/sensors/qmlsensorgestures/qml_app/GestureView.qml b/examples/sensors/qmlsensorgestures/qml_app/GestureView.qml
new file mode 100644
index 00000000..324b90e2
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/qml_app/GestureView.qml
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//Import the declarative plugins
+import QtQuick 2.0
+import QtSensors 5.0
+
+/* Layout
+ gesturerect
+ /
+---------------------------------------/
+| ----------------------------------- |
+| | id: titleText | |
+| ----------------------------------- |
+| |
+| |
+| ----------------------------------- |
+| | id: detectionText | |
+| ----------------------------------- |
+| |
+| |
+| |
+| ----------------------------------- |
+| | id: valueText | |
+| ----------------------------------- |
+| |
+| |
+| |
+| ------------------------------ |
+| | id: gestureStartStopButton | |
+| ------------------------------ |
+---------------------------------------
+*/
+
+Rectangle {
+ id: gesturerect
+ border.width: 1
+ anchors.margins: 5
+ property alias gestureid: sensorGuesture.gestures
+ property alias gesturetitle: titleText.text
+ property alias enabled: sensorGuesture.enabled
+ property string oldgesture: ""
+ property int count: 0
+
+ SensorGesture {
+ id: sensorGuesture
+ enabled: false
+ onDetected:{
+ if (gesture !== oldgesture)
+ count = 0;
+ valueText.text = gesture + " " + count;
+ oldgesture = gesture;
+ count++;
+ }
+ onEnabledChanged: {
+ valueText.text = ""
+ }
+ }
+
+ Text {
+ id: titleText
+ anchors.top: gesturerect.top
+ anchors.left: gesturerect.left
+ anchors.right: gesturerect.right
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 20
+ font.bold: true
+ text: ""
+ }
+
+ Text {
+ id: detectionText
+ anchors.top: titleText.bottom
+ anchors.left: gesturerect.left
+ anchors.right: gesturerect.right
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 15
+ text: "detection:"
+ }
+
+ Text {
+ id: valueText
+ anchors.top: detectionText.bottom
+ anchors.left: gesturerect.left
+ anchors.right: gesturerect.right
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 15
+ text: ("")
+ visible: sensorGuesture.enabled
+ }
+
+ Button{
+ id: gestureStartStopButton
+ anchors.left: gesturerect.left
+ anchors.bottom: gesturerect.bottom
+ height: 30
+ width: 100
+ buttonText: (sensorGuesture.enabled ? "Stop" : "Start")
+ enabled: true;
+ onClicked: {
+ if (gestureStartStopButton.buttonText === "Start") {
+ sensorGuesture.enabled = true;
+ }
+ else {
+ sensorGuesture.enabled = false;
+ }
+ }
+ }
+}
diff --git a/examples/sensors/qmlsensorgestures/qml_app/GesturesView.qml b/examples/sensors/qmlsensorgestures/qml_app/GesturesView.qml
new file mode 100644
index 00000000..c20caf14
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/qml_app/GesturesView.qml
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//Import the declarative plugins
+import QtQuick 2.0
+import QtSensors 5.0
+
+/* Layout
+ gesturerect
+ /
+---------------------------------------/
+| ----------------------------------- |
+| | id: titleText | |
+| ----------------------------------- |
+| |
+| |
+| ----------------------------------- |
+| | id: detectionText | |
+| ----------------------------------- |
+| |
+| |
+| |
+| ----------------- ----------------- |
+| | id: valueText | | id: valueText1| |
+| ----------------- ----------------- |
+| |
+| |
+| |
+| ------------------------------ |
+| | id: gestureStartStopButton | |
+| ------------------------------ |
+---------------------------------------
+*/
+
+Rectangle {
+ id: gesturerect
+ border.width: 1
+ anchors.margins: 5
+ property alias enabled: sensorGuesture.enabled
+ property int count: 0
+ property int count1: 0
+
+ SensorGesture {
+ id: sensorGuesture
+ enabled: true
+ gestures: ["QtSensors.shake", "QtSensors.SecondCounter"]
+ onDetected:{
+ if (gesture === "QtSensors.shake")
+ gesturerect.count++;
+ else
+ gesturerect.count1++;
+ }
+ onEnabledChanged: {
+ gesturerect.count = 0;
+ gesturerect.count1 = 0;
+ }
+ }
+
+ Text {
+ id: titleText
+ anchors.top: gesturerect.top
+ anchors.left: gesturerect.left
+ anchors.right: gesturerect.right
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 20
+ font.bold: true
+ text: "templates gestures"
+ }
+
+ Text {
+ id: detectionText
+ anchors.top: titleText.bottom
+ anchors.left: gesturerect.left
+ anchors.right: gesturerect.right
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 15
+ text: "shake : SecondCounter"
+ }
+
+ Text {
+ id: valueText
+ anchors.top: detectionText.bottom
+ anchors.left: gesturerect.left
+ width: gesturerect.width / 2
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 15
+ text: gesturerect.count
+ visible: sensorGuesture.enabled
+ }
+
+ Text {
+ id: valueText1
+ anchors.top: detectionText.bottom
+ anchors.right: gesturerect.right
+ width: gesturerect.width / 2
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 15
+ text: gesturerect.count1
+ visible: sensorGuesture.enabled
+ }
+
+ Button{
+ id: gestureStartStopButton
+ anchors.left: gesturerect.left
+ anchors.bottom: gesturerect.bottom
+ height: 30
+ width: 100
+ buttonText: (sensorGuesture.enabled ? "Stop" : "Start")
+ enabled: true;
+ onClicked: {
+ if (gestureStartStopButton.buttonText === "Start") {
+ sensorGuesture.enabled = true;
+ }
+ else {
+ sensorGuesture.enabled = false;
+ }
+ }
+ }
+}
diff --git a/examples/sensors/qmlsensorgestures/qml_app/icon.png b/examples/sensors/qmlsensorgestures/qml_app/icon.png
new file mode 100755
index 00000000..c445bd7f
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/qml_app/icon.png
Binary files differ
diff --git a/examples/sensors/qmlsensorgestures/qml_app/info.json b/examples/sensors/qmlsensorgestures/qml_app/info.json
new file mode 100644
index 00000000..39a62190
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/qml_app/info.json
@@ -0,0 +1,14 @@
+{
+ "info-version": "1.0",
+ "dict": {
+ "Category": "application",
+ "Runtime": "qml",
+ "DisplayName": "Gesture",
+ "Subcategory": "utility",
+ "MainQML": "Gesture.qml",
+ "Version": "1.0",
+ "Identifier": "com.nokia.mt.qmlsensorsgesture.demo",
+ "Summary": "QML Sensors Gesture demo",
+ "Author": "Qt"
+ }
+}
diff --git a/examples/sensors/qmlsensorgestures/qml_app/qml_app.qmlproject b/examples/sensors/qmlsensorgestures/qml_app/qml_app.qmlproject
new file mode 100644
index 00000000..90245a62
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/qml_app/qml_app.qmlproject
@@ -0,0 +1,18 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "Gesture.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ "../exampleplugin" ]
+}
diff --git a/examples/sensors/qmlsensorgestures/qmlsensorgestures.pro b/examples/sensors/qmlsensorgestures/qmlsensorgestures.pro
new file mode 100644
index 00000000..46b8228d
--- /dev/null
+++ b/examples/sensors/qmlsensorgestures/qmlsensorgestures.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+
+SUBDIRS += plugin
+SUBDIRS += #qml_app
+
diff --git a/examples/sensors/sensors.pro b/examples/sensors/sensors.pro
index 50b5fac0..7a79b5f5 100644
--- a/examples/sensors/sensors.pro
+++ b/examples/sensors/sensors.pro
@@ -1,9 +1,11 @@
TEMPLATE = subdirs
SUBDIRS += \
- accel\
+ accel \
grue \
+ qmlsensorgestures
+
+contains(QT_CONFIG,widgets):SUBDIRS += \
+ sensor_explorer \
sensorgestures
-#contains(QT_CONFIG,widgets):SUBDIRS += \
- # sensor_explorer \
diff --git a/src/imports/sensors2/qsensor2gesture.cpp b/src/imports/sensors2/qsensor2gesture.cpp
new file mode 100644
index 00000000..33d97231
--- /dev/null
+++ b/src/imports/sensors2/qsensor2gesture.cpp
@@ -0,0 +1,266 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsensor2gesture.h"
+#include <qsensorgesture.h>
+#include <qsensorgesturemanager.h>
+
+QT_BEGIN_NAMESPACE
+
+//#define LOGGESTURQMLAPI
+
+/*!
+ \qmlclass SensorGesture QSensor2Gesture
+ \inqmlmodule QtSensors 5
+ \since QtSensors 5.0
+ \brief The SensorGesture element provide notification when sensor gestures are triggered.
+
+ This element is part of the \bold{QtSensors 5} module.
+
+ The following QML code creates a "shake" and "template" SensorGesture QML element.
+
+ \qml
+ Item {
+ SensorGesture {
+ id: sensorGesture
+ enabled: false
+ gestures : ["QtSensors.shake", "QtSensors.SecondCounter"]
+ onDetected:{
+ detectedText.text = gesture
+ }
+ }
+ Text {
+ id: detectedText
+ x:5
+ y:160
+ text: ""
+ }
+ }
+ \endqml
+*/
+QSensor2Gesture::QSensor2Gesture(QObject* parent)
+ : QObject(parent)
+ , _enabled(false)
+ , _oldEnabled(false)
+ , _init(true)
+ , _sensorGesture(0)
+ , _sensorGestureManager(0)
+{
+ _sensorGestureManager = new QSensorGestureManager(this);
+ connect(_sensorGestureManager, SIGNAL(newSensorGestureAvailable()), SIGNAL(availableGesturesChanged()));
+}
+
+QSensor2Gesture::~QSensor2Gesture()
+{
+}
+
+/*
+ QDeclarativeParserStatus interface implementation
+*/
+void QSensor2Gesture::classBegin()
+{
+}
+
+void QSensor2Gesture::componentComplete()
+{
+ /*
+ this is needed in the case the customer defines the type(s) and set it enabled = true
+ */
+ _init = false;
+ setEnabled(_enabled);
+}
+/*
+ End of QDeclarativeParserStatus interface implementation
+*/
+
+/*!
+ \qmlproperty QStringList QtSensors5::SensorGesture::availableGestures
+ This property can be used to determine all available gestures on the system.
+*/
+QStringList QSensor2Gesture::availableGestures()
+{
+ return _sensorGestureManager->gestureIds();
+}
+
+/*!
+ \qmlproperty QString QtSensors5::SensorGesture::gestures
+ Set this property to the gestures the application is interested in detecting.
+ The properties validGestures and invalidGestures will be set as appropriate immediately.
+ The list of available gestures can be found in the availableGestures property.
+ This property cannot be changed while the element is enabled.
+ To determine all available getures on the system please use the
+ \l {QtSensors5::SensorGesture::availableGestures} {availableGestures} property.
+*/
+QStringList QSensor2Gesture::gestures() const
+{
+ return _gestures;
+}
+
+void QSensor2Gesture::setGestures(const QStringList& value)
+{
+ if (_gestures == value)
+ return;
+
+ if (!_init && enabled()){
+ qWarning() << "Cannot change gestures while running.";
+ return;
+ }
+ _gestures.clear();
+ _gestures = value;
+ createGesture();
+ emit gesturesChanged();
+}
+
+
+/*!
+ \qmlproperty QStringList QtSensors5::SensorGesture::validGestures
+ This property holds the requested gestures that were found on the system.
+*/
+QStringList QSensor2Gesture::validGestures() const
+{
+ if (_sensorGesture)
+ return _sensorGesture->validIds();
+ return QStringList();
+}
+
+/*!
+ \qmlproperty QStringList QtSensors5::SensorGesture::invalidGestures
+ This property holds the requested gestures that were not found on the system.
+*/
+QStringList QSensor2Gesture::invalidGestures() const
+{
+ if (_sensorGesture)
+ return _sensorGesture->invalidIds();
+ return QStringList();
+}
+
+/*!
+ \qmlproperty bool QtSensors5::SensorGesture::enabled
+ This property can be used to activate or deactivate the sensor gesture.
+ \sa {QtSensors5::SensorGesture::detected} {detected}
+*/
+bool QSensor2Gesture::enabled() const
+{
+ return _enabled;
+}
+
+void QSensor2Gesture::setEnabled(bool value)
+{
+ _enabled = value;
+ if (_init)
+ return;
+
+ if (_enabled != _oldEnabled){
+ _oldEnabled = _enabled;
+ if (_sensorGesture){
+ if (_enabled){
+#ifdef LOGGESTURQMLAPI
+ qDebug() << "start detection" << _gestureIds;
+#endif
+ _sensorGesture->startDetection();
+ }
+ else {
+#ifdef LOGGESTURQMLAPI
+ qDebug() << "stop detection" << _gestureIds;
+#endif
+ _sensorGesture->stopDetection();
+ }
+ }
+ emit enabledChanged();
+ }
+}
+
+/*!
+ \qmlsignal QtSensors5::SensorGesture::detected(QString gesture)
+ This signal is emitted whenever a gesture is detected.
+ The gesture parameter contains the gesture that was detected.
+*/
+
+/*
+ private funtion implementation
+*/
+void QSensor2Gesture::deleteGesture()
+{
+ if (_sensorGesture){
+ bool emitinvalidchange = !invalidGestures().isEmpty();
+ bool emitvalidchange = !validGestures().isEmpty();
+
+ if (_sensorGesture->isActive()) {
+ _sensorGesture->stopDetection();
+ }
+ delete _sensorGesture;
+ _sensorGesture = 0;
+
+ if (emitinvalidchange){
+ emit invalidGesturesChanged();
+ }
+ if (emitvalidchange){
+ emit validGesturesChanged();
+ }
+ }
+}
+
+void QSensor2Gesture::createGesture()
+{
+ deleteGesture();
+#ifdef LOGGESTURQMLAPI
+ qDebug() << "Create Gestrues:";
+ for (int i = 0; i < _gestures.count(); i++){
+ qDebug() << " -" << _gestures[i];
+ }
+#endif
+ _sensorGesture = new QSensorGesture(_gestures, this);
+ if (!validGestures().isEmpty()){
+ QObject::connect(_sensorGesture
+ , SIGNAL(detected(QString))
+ , this
+ , SIGNAL(detected(QString)));
+ emit validGesturesChanged();
+ }
+ if (!invalidGestures().isEmpty())
+ emit invalidGesturesChanged();
+}
+
+/*
+ End of private funtion implementation
+*/
+
+QT_END_NAMESPACE
diff --git a/src/imports/sensors2/qsensor2gesture.h b/src/imports/sensors2/qsensor2gesture.h
new file mode 100644
index 00000000..009428d2
--- /dev/null
+++ b/src/imports/sensors2/qsensor2gesture.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSENSOR2GESTURE_H
+#define QSENSOR2GESTURE_H
+
+#include <QtDeclarative/QDeclarativeParserStatus>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtCore/QStringList>
+#include <QtCore/QMap>
+
+QT_BEGIN_NAMESPACE
+
+class QSensorGesture;
+class QSensorGestureManager;
+class QSensor2Gesture : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_PROPERTY(QStringList availableGestures READ availableGestures NOTIFY availableGesturesChanged)
+ Q_PROPERTY(QStringList gestures READ gestures WRITE setGestures NOTIFY gesturesChanged)
+ Q_PROPERTY(QStringList validGestures READ validGestures NOTIFY validGesturesChanged)
+ Q_PROPERTY(QStringList invalidGestures READ invalidGestures NOTIFY invalidGesturesChanged)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_INTERFACES(QDeclarativeParserStatus)
+
+public:
+ QSensor2Gesture(QObject* parent = 0);
+ virtual ~QSensor2Gesture();
+ void classBegin();
+ void componentComplete();
+
+Q_SIGNALS:
+ void detected(const QString &gesture);
+ void availableGesturesChanged();
+ void gesturesChanged();
+ void validGesturesChanged();
+ void invalidGesturesChanged();
+ void enabledChanged();
+
+public:
+ QStringList availableGestures();
+ QStringList gestures() const;
+ void setGestures(const QStringList& value);
+ bool enabled() const;
+ void setEnabled(bool value);
+ QStringList validGestures() const;
+ QStringList invalidGestures() const;
+
+private:
+ void deleteGesture();
+ void createGesture();
+
+private:
+ QStringList _gestureIds;
+ bool _enabled;
+ bool _oldEnabled;
+ bool _init;
+ QStringList _gestures;
+
+ QSensorGesture* _sensorGesture;
+ QSensorGestureManager* _sensorGestureManager;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QSensor2Gesture)
+
+#endif // QSENSOR2GESTURE_H
diff --git a/src/imports/sensors2/sensors2.cpp b/src/imports/sensors2/sensors2.cpp
index d91ba4d5..b1320e73 100644
--- a/src/imports/sensors2/sensors2.cpp
+++ b/src/imports/sensors2/sensors2.cpp
@@ -44,6 +44,7 @@
#include "qsensor2ambientlight.h"
#include "qsensor2proximity.h"
#include "qsensor2tilt.h"
+#include "qsensor2gesture.h"
#include <QtCore/QDebug>
QT_BEGIN_NAMESPACE
@@ -60,6 +61,7 @@ public:
qmlRegisterType<QSensor2Tilt>(uri, 5, 0, "TiltSensor");
qmlRegisterType<QSensor2AmbientLight>(uri, 5, 0, "AmbientLightSensor");
qmlRegisterType<QSensor2Proximity>(uri, 5, 0, "ProximitySensor");
+ qmlRegisterType<QSensor2Gesture>(uri, 5, 0, "SensorGesture");
}
};
diff --git a/src/imports/sensors2/sensors2.pro b/src/imports/sensors2/sensors2.pro
index d7133b27..ec0bca97 100644
--- a/src/imports/sensors2/sensors2.pro
+++ b/src/imports/sensors2/sensors2.pro
@@ -8,11 +8,13 @@ QT += declarative sensors
SOURCES += sensors2.cpp \
qsensor2ambientlight.cpp \
qsensor2proximity.cpp \
- qsensor2tilt.cpp
+ qsensor2tilt.cpp \
+ qsensor2gesture.cpp
HEADERS += qsensor2ambientlight.h \
qsensor2proximity.h \
- qsensor2tilt.h
+ qsensor2tilt.h \
+ qsensor2gesture.h
DESTDIR = $$QT.sensors.imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
@@ -35,3 +37,5 @@ symbian {
DEPLOYMENT = importFiles
}
+
+
diff --git a/tests/auto/qtsensors5/tst_qtsensors5.cpp b/tests/auto/qtsensors5/tst_qtsensors5.cpp
index 687bf2f7..90c074c2 100644
--- a/tests/auto/qtsensors5/tst_qtsensors5.cpp
+++ b/tests/auto/qtsensors5/tst_qtsensors5.cpp
@@ -102,6 +102,7 @@ private slots:
QTest::newRow("TiltSensor 5.0") << "5.0" << "TiltSensor" << true;
QTest::newRow("AmbientLightSensor 5.0") << "5.0" << "AmbientLightSensor" << true;
QTest::newRow("ProximitySensor 5.0") << "5.0" << "ProximitySensor" << true;
+ QTest::newRow("SensorGesture 5.0") << "5.0" << "SensorGesture" << true;
}
void elements()
diff --git a/tests/auto/sensors2qmlapi/qtemplategestureplugin.cpp b/tests/auto/sensors2qmlapi/qtemplategestureplugin.cpp
new file mode 100644
index 00000000..59318895
--- /dev/null
+++ b/tests/auto/sensors2qmlapi/qtemplategestureplugin.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtPlugin>
+#include <QStringList>
+#include <QObject>
+
+#include "qtemplategestureplugin.h"
+#include <qsensorgestureplugininterface.h>
+#include <qsensorgesturemanager.h>
+#include "qtemplaterecognizer.h"
+
+
+QTemplateGesturePlugin::QTemplateGesturePlugin()
+{
+}
+
+QTemplateGesturePlugin::~QTemplateGesturePlugin()
+{
+}
+
+QStringList QTemplateGesturePlugin::supportedIds() const
+{
+ QStringList list;
+ list << "QtSensors.template" << "QtSensors.template1";
+ return list;
+}
+
+
+QList <QSensorGestureRecognizer *> QTemplateGesturePlugin::createRecognizers()
+{
+ QList <QSensorGestureRecognizer *> recognizers;
+
+ QSensorGestureRecognizer *sRec = new QTemplateGestureRecognizer(this);
+ recognizers.append(sRec);
+ sRec = new QTemplateGestureRecognizer1(this);
+ recognizers.append(sRec);
+
+ return recognizers;
+}
+
+Q_EXPORT_PLUGIN2(QTemplateGestureRecognizer, QTemplateGesturePlugin)
+
diff --git a/tests/auto/sensors2qmlapi/qtemplategestureplugin.h b/tests/auto/sensors2qmlapi/qtemplategestureplugin.h
new file mode 100644
index 00000000..04e2662e
--- /dev/null
+++ b/tests/auto/sensors2qmlapi/qtemplategestureplugin.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEMPLATEGESTUREPLUGIN_H
+#define QTEMPLATEGESTUREPLUGIN_H
+
+#include <QObject>
+#include <QStringList>
+
+#include <qsensorgestureplugininterface.h>
+
+class QTemplateGesturePlugin : public QObject, QSensorGesturePluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QSensorGesturePluginInterface)
+public:
+ explicit QTemplateGesturePlugin();
+ ~QTemplateGesturePlugin();
+
+ QList <QSensorGestureRecognizer *> createRecognizers();
+
+ QStringList gestureSignals() const;
+ QStringList supportedIds() const;
+ QString name() const { return "TemplateGestures"; }
+};
+
+#endif // QTEMPLATEGESTUREPLUGIN_H
diff --git a/tests/auto/sensors2qmlapi/qtemplaterecognizer.cpp b/tests/auto/sensors2qmlapi/qtemplaterecognizer.cpp
new file mode 100644
index 00000000..73bc1621
--- /dev/null
+++ b/tests/auto/sensors2qmlapi/qtemplaterecognizer.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include <QTimer>
+
+#include "qtemplaterecognizer.h"
+
+QTemplateGestureRecognizer::QTemplateGestureRecognizer(QObject *parent)
+ : QSensorGestureRecognizer(parent)
+{
+}
+
+QTemplateGestureRecognizer::~QTemplateGestureRecognizer()
+{
+
+}
+
+void QTemplateGestureRecognizer::create()
+{
+ connect(&_timer,SIGNAL(timeout()),this,SLOT(timeout()));
+ _timer.setInterval(1000);
+}
+
+bool QTemplateGestureRecognizer::start()
+{
+ Q_EMIT detected(id());
+ _timer.start();
+ return _timer.isActive();
+}
+
+bool QTemplateGestureRecognizer::stop()
+{
+ _timer.stop();
+ return true;
+}
+
+
+bool QTemplateGestureRecognizer::isActive()
+{
+ return _timer.isActive();
+}
+
+QString QTemplateGestureRecognizer::id() const
+{
+ return QString("QtSensors.template");
+}
+
+void QTemplateGestureRecognizer::timeout()
+{
+ Q_EMIT detected(id());
+}
+
+
+QTemplateGestureRecognizer1::QTemplateGestureRecognizer1(QObject *parent)
+ : QSensorGestureRecognizer(parent)
+{
+}
+
+QTemplateGestureRecognizer1::~QTemplateGestureRecognizer1()
+{
+
+}
+
+void QTemplateGestureRecognizer1::create()
+{
+ connect(&_timer,SIGNAL(timeout()),this,SLOT(timeout()));
+ _timer.setInterval(500);
+}
+
+bool QTemplateGestureRecognizer1::start()
+{
+ Q_EMIT detected(id());
+ _timer.start();
+ return _timer.isActive();
+}
+
+bool QTemplateGestureRecognizer1::stop()
+{
+ _timer.stop();
+ return true;
+}
+
+
+bool QTemplateGestureRecognizer1::isActive()
+{
+ return _timer.isActive();
+}
+
+QString QTemplateGestureRecognizer1::id() const
+{
+ return QString("QtSensors.template1");
+}
+
+void QTemplateGestureRecognizer1::timeout()
+{
+ Q_EMIT detected(id());
+}
diff --git a/tests/auto/sensors2qmlapi/qtemplaterecognizer.h b/tests/auto/sensors2qmlapi/qtemplaterecognizer.h
new file mode 100644
index 00000000..1a4c4196
--- /dev/null
+++ b/tests/auto/sensors2qmlapi/qtemplaterecognizer.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEMPLATERECOGNIZER_H
+#define QTEMPLATERECOGNIZER_H
+
+#include <QDebug>
+#include <QtCore/QTimer>
+#include <qsensorgesturerecognizer.h>
+
+class QTemplateGestureRecognizer : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+public:
+
+ QTemplateGestureRecognizer(QObject *parent = 0);
+ ~QTemplateGestureRecognizer();
+
+ void create();
+
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+private slots:
+ void timeout();
+
+private:
+ QTimer _timer;
+};
+
+class QTemplateGestureRecognizer1 : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+public:
+
+ QTemplateGestureRecognizer1(QObject *parent = 0);
+ ~QTemplateGestureRecognizer1();
+
+ void create();
+
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+private slots:
+ void timeout();
+
+private:
+ QTimer _timer;
+};
+
+#endif // QTEMPLATERECOGNIZER_H
diff --git a/tests/auto/sensors2qmlapi/sensors2qmlapi.pro b/tests/auto/sensors2qmlapi/sensors2qmlapi.pro
index acd8951b..cdd9c02e 100644
--- a/tests/auto/sensors2qmlapi/sensors2qmlapi.pro
+++ b/tests/auto/sensors2qmlapi/sensors2qmlapi.pro
@@ -9,7 +9,10 @@ DEPENDPATH += ./
SOURCES += tst_sensors2qmlapi.cpp \
./../../../src/imports/sensors2/qsensor2ambientlight.cpp \
./../../../src/imports/sensors2/qsensor2proximity.cpp \
- ./../../../src/imports/sensors2/qsensor2tilt.cpp
+ ./../../../src/imports/sensors2/qsensor2tilt.cpp \
+ ./../../../src/imports/sensors2/qsensor2gesture.cpp \
+ qtemplategestureplugin.cpp \
+ qtemplaterecognizer.cpp
HEADERS += qdeclaccelerometer.h \
qdeclambientlightsensor.h \
@@ -17,4 +20,7 @@ HEADERS += qdeclaccelerometer.h \
qbackends.h \
./../../../src/imports/sensors2/qsensor2ambientlight.h \
./../../../src/imports/sensors2/qsensor2proximity.h \
- ./../../../src/imports/sensors2/qsensor2tilt.h
+ ./../../../src/imports/sensors2/qsensor2tilt.h \
+ ./../../../src/imports/sensors2/qsensor2gesture.h \
+ qtemplategestureplugin.h \
+ qtemplaterecognizer.h
diff --git a/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp b/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp
index cc24d990..568019b8 100644
--- a/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp
+++ b/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp
@@ -45,6 +45,10 @@
#include "../../../src/imports/sensors2/qsensor2ambientlight.h"
#include "../../../src/imports/sensors2/qsensor2proximity.h"
#include "../../../src/imports/sensors2/qsensor2tilt.h"
+#include "../../../src/imports/sensors2/qsensor2gesture.h"
+#include "qtemplategestureplugin.h"
+#include "qtemplaterecognizer.h"
+#include <qsensorgesturemanager.h>
#include "qbackends.h"
#include "qsensormanager.h"
@@ -71,6 +75,7 @@ private slots:
void testTiltUnit();
void testProximity();
void testAmbientLight();
+ void testGesture();
protected:
TestSensorPlugin _plugin;
@@ -497,5 +502,124 @@ void tst_Sensors2QMLAPI::testTiltRunningMode()
QCOMPARE(speed, QSensor2Tilt::Fast);
}
+void tst_Sensors2QMLAPI::testGesture()
+{
+ QTemplateGesturePlugin* plugin = new QTemplateGesturePlugin();
+ QList <QSensorGestureRecognizer *> recognizers = plugin->createRecognizers();
+ QSensorGestureManager manager;
+
+ QSensor2Gesture* gs = new QSensor2Gesture(this);
+ gs->componentComplete();
+ qDebug() << "QSensor2Gesture gestures:";
+ qDebug() << gs->availableGestures();
+ QSignalSpy spy_availableGesturesChanged(gs, SIGNAL(availableGesturesChanged()));
+ QSignalSpy spy_detected(gs, SIGNAL(detected(const QString)));
+ QSignalSpy spy_gesturesChanged(gs, SIGNAL(gesturesChanged()));
+ QSignalSpy spy_validGesturesChanged(gs, SIGNAL(validGesturesChanged()));
+ QSignalSpy spy_invalidGesturesChanged(gs, SIGNAL(invalidGesturesChanged()));
+ QSignalSpy spy_enabledChanged(gs, SIGNAL(enabledChanged()));
+
+ //This flag is needed if you run this unit test with an alread installed template plugin
+ bool registered = false;
+ for (int i = 0; i < recognizers.count(); i++){
+ registered = manager.registerSensorGestureRecognizer(recognizers[i]);
+ }
+ if (registered) {
+ QCOMPARE(spy_availableGesturesChanged.count(), 2);
+ }
+
+ //check creation of a not known plugin
+ QCOMPARE(spy_invalidGesturesChanged.count(), 0);
+ QCOMPARE(spy_gesturesChanged.count(), 0);
+ gs->setGestures(QStringList() << "lollipop");
+ QCOMPARE(spy_gesturesChanged.count(), 1);
+ QCOMPARE(spy_invalidGesturesChanged.count(), 1);
+
+ //check creation of a known plugin
+ QCOMPARE(spy_validGesturesChanged.count(), 0);
+ QCOMPARE(spy_gesturesChanged.count(), 1);
+ spy_invalidGesturesChanged.clear();
+ spy_validGesturesChanged.clear();
+ gs->setGestures(QStringList() << "QtSensors.template");
+ QCOMPARE(spy_gesturesChanged.count(), 2);
+ QCOMPARE(spy_invalidGesturesChanged.count(), 1);
+ QCOMPARE(spy_validGesturesChanged.count(), 1);
+
+ //enable "QtSensors.template"
+ QCOMPARE(spy_enabledChanged.count(), 0);
+ QCOMPARE(spy_detected.count(), 0);
+ gs->setEnabled(true);
+ QCOMPARE(spy_enabledChanged.count(), 1);
+ QCOMPARE(spy_detected.count(), 1);
+
+ //set gesture during running sensor should not emit gesture changed
+ spy_gesturesChanged.clear();
+ gs->setGestures(QStringList() << "QtSensors.template2");
+ QCOMPARE(spy_gesturesChanged.count(), 0);
+
+ gs->setEnabled(false);
+
+ QSensor2Gesture* gs1 = new QSensor2Gesture(this);
+ QSignalSpy spy1_detected(gs1, SIGNAL(detected(const QString)));
+ QSignalSpy spy1_gesturesChanged(gs1, SIGNAL(gesturesChanged()));
+ QSignalSpy spy1_validGesturesChanged(gs1, SIGNAL(validGesturesChanged()));
+ QSignalSpy spy1_invalidGesturesChanged(gs1, SIGNAL(invalidGesturesChanged()));
+ QSignalSpy spy1_enabledChanged(gs1, SIGNAL(enabledChanged()));
+ gs1->componentComplete();
+
+ //set enable = true without gesture should
+ gs1->setEnabled(true);
+ QCOMPARE(spy1_enabledChanged.count(), 1);
+ gs1->setEnabled(false);
+ spy1_enabledChanged.clear();
+
+ //reding gestures check if we get back an empty string list
+ QStringList gestures = gs1->gestures();
+ QCOMPARE(gestures.count(), 0);
+ QStringList validgestures = gs1->validGestures();
+ QCOMPARE(validgestures.count(), 0);
+ QStringList invalidgestures = gs1->invalidGestures();
+ QCOMPARE(invalidgestures.count(), 0);
+
+ //check types "QtSensors.template" "QtSensors.template1" "lollipop"
+ //expect valid 2 not available 1
+ gestures << "QtSensors.template" << "QtSensors.template1" << "lollipop";
+ gs1->setGestures(gestures);
+ gestures = gs1->gestures();
+ QCOMPARE(gestures.count(), 3);
+ QCOMPARE(spy1_validGesturesChanged.count(), 1);
+ QCOMPARE(spy1_invalidGesturesChanged.count(), 1);
+ QCOMPARE(spy1_gesturesChanged.count(), 1);
+ //set same gesture again should not emit gesture changed
+ gs1->setGestures(gestures);
+ QCOMPARE(spy1_gesturesChanged.count(), 1);
+
+ spy1_gesturesChanged.clear();
+ gestures.clear();
+ gs1->setGestures(gestures);
+ QCOMPARE(spy1_gesturesChanged.count(), 1);
+
+ //enable "QtSensors.template" and "QtSensors.template1"
+ gestures << "QtSensors.template" << "QtSensors.template1";
+ gs1->setEnabled(false);
+ gs1->setGestures(gestures);
+ spy1_enabledChanged.clear();
+ spy1_detected.clear();
+ gs1->setEnabled(true);
+ QCOMPARE(spy1_enabledChanged.count(), 1);
+ QCOMPARE(spy1_detected.count(), 2);
+ gs1->setEnabled(false);
+
+ //check sensor shouldn't run until the componentComplete gets called
+ QSensor2Gesture* gs2 = new QSensor2Gesture(this);
+ QSignalSpy spy2_detected(gs2, SIGNAL(detected(const QString)));
+ gs2->setGestures(QStringList() << "QtSensors.template");
+ gs2->setEnabled(true);
+ QCOMPARE(spy2_detected.count(), 0);
+ gs2->componentComplete();
+ QCOMPARE(spy2_detected.count(), 1);
+}
+
+
QTEST_MAIN(tst_Sensors2QMLAPI)
#include "tst_sensors2qmlapi.moc"