diff options
author | Lincoln Ramsay <lincoln.ramsay@nokia.com> | 2012-06-19 15:47:09 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-20 01:56:15 +0200 |
commit | b2e97817684f40ab9353fa279a4c02ef9c12e13d (patch) | |
tree | b7c7114b555539de9e1bc5a1bd1ed5afeed777bb /examples/sensors/qmlsensorgestures | |
parent | 5e89b386f4aae5a4953c725b6aab565b21a3330f (diff) |
Remove the 'special' naming of examples.
Just go back to the naming convention we had before.
Change-Id: Iefecb7a5e0ab3aa4d22267b4f475a8e9c1c96058
Reviewed-by: Lorn Potter <lorn.potter@nokia.com>
Diffstat (limited to 'examples/sensors/qmlsensorgestures')
15 files changed, 1043 insertions, 0 deletions
diff --git a/examples/sensors/qmlsensorgestures/Button.qml b/examples/sensors/qmlsensorgestures/Button.qml new file mode 100644 index 00000000..23fc0f66 --- /dev/null +++ b/examples/sensors/qmlsensorgestures/Button.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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/GestureList.qml b/examples/sensors/qmlsensorgestures/GestureList.qml new file mode 100644 index 00000000..9dc3fd92 --- /dev/null +++ b/examples/sensors/qmlsensorgestures/GestureList.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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 + +//! [4] + ListView { + id: gestureList + anchors.fill: gestureListRect + anchors.margins: 5 + model: gesture.availableGestures + focus: true + currentIndex: -1 + delegate: gestureListDelegate + clip: true + } +//! [4] + 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/GestureView.qml b/examples/sensors/qmlsensorgestures/GestureView.qml new file mode 100644 index 00000000..07a9a5cc --- /dev/null +++ b/examples/sensors/qmlsensorgestures/GestureView.qml @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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 + +//! [0] +import QtSensors 5.0 +//! [0] + +/* Layout + gesturerect + / +---------------------------------------/ +| ----------------------------------- | +| | id: titleText | | +| ----------------------------------- | +| | +| | +| ----------------------------------- | +| | id: detectionText | | +| ----------------------------------- | +| | +| | +| | +| ----------------------------------- | +| | id: valueText | | +| ----------------------------------- | +| | +| | +| | +| ------------------------------ | +| | id: gestureStartStopButton | | +| ------------------------------ | +--------------------------------------- +*/ + +Rectangle { + id: gesturerect + border.width: 1 + anchors.margins: 5 +//! [2] + property alias gestureid: sensorGesture.gestures +//! [2] + property alias gesturetitle: titleText.text + property alias enabled: sensorGesture.enabled + property string oldgesture: "" + property int count: 0 + +//! [1] + SensorGesture { + id: sensorGesture + enabled: false + onDetected:{ + if (gesture !== oldgesture) + count = 0; + valueText.text = gesture + " " + count; + oldgesture = gesture; + count++; + } + onEnabledChanged: { + valueText.text = "" + } + } +//! [1] + + 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: sensorGesture.enabled + } + + Button{ + id: gestureStartStopButton + anchors.left: gesturerect.left + anchors.bottom: gesturerect.bottom + height: 30 + width: 100 + buttonText: (sensorGesture.enabled ? "Stop" : "Start") + enabled: true; + onClicked: { + if (gestureStartStopButton.buttonText === "Start") { + sensorGesture.enabled = true; + } + else { + sensorGesture.enabled = false; + } + } + } +} diff --git a/examples/sensors/qmlsensorgestures/GesturesView.qml b/examples/sensors/qmlsensorgestures/GesturesView.qml new file mode 100644 index 00000000..23924cad --- /dev/null +++ b/examples/sensors/qmlsensorgestures/GesturesView.qml @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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: availableGestures + 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/icon.png b/examples/sensors/qmlsensorgestures/icon.png Binary files differnew file mode 100644 index 00000000..c445bd7f --- /dev/null +++ b/examples/sensors/qmlsensorgestures/icon.png diff --git a/examples/sensors/qmlsensorgestures/info.json b/examples/sensors/qmlsensorgestures/info.json new file mode 100644 index 00000000..57241dab --- /dev/null +++ b/examples/sensors/qmlsensorgestures/info.json @@ -0,0 +1,14 @@ +{ + "info-version": "1.0", + "dict": { + "displayName": { + "en_US": "Gesture" + }, + "identifier": "com.nokia.mt.qmlsensorsgesture", + "runtime": "qml", + "main": "QtSensors_qmlsensorgestures.qml", + "version": "1.0.0", + "category": "application", + "subcategory": "utility" + } +} diff --git a/examples/sensors/qmlsensorgestures/plugin/plugin.json b/examples/sensors/qmlsensorgestures/plugin/plugin.json new file mode 100644 index 00000000..8a55b3ae --- /dev/null +++ b/examples/sensors/qmlsensorgestures/plugin/plugin.json @@ -0,0 +1 @@ +{ "Keys": [ "notused" ] } diff --git a/examples/sensors/qmlsensorgestures/plugin/plugin.pro b/examples/sensors/qmlsensorgestures/plugin/plugin.pro new file mode 100644 index 00000000..2003e910 --- /dev/null +++ b/examples/sensors/qmlsensorgestures/plugin/plugin.pro @@ -0,0 +1,21 @@ +TEMPLATE = lib +CONFIG += plugin + +TARGET = qtsensorgestures_counterplugin + +QT += sensors +DESTDIR = $$QT.sensors.plugins/sensorgestures + +HEADERS += \ + qcountergestureplugin.h \ + qcounterrecognizer.h +SOURCES += \ + qcountergestureplugin.cpp \ + qcounterrecognizer.cpp + +target.path += $$[QT_INSTALL_PLUGINS]/sensorgestures +INSTALLS += target + +OTHER_FILES += \ + plugin.json + diff --git a/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp b/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp new file mode 100644 index 00000000..1fda1879 --- /dev/null +++ b/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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; +} diff --git a/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h b/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h new file mode 100644 index 00000000..4755f96e --- /dev/null +++ b/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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, public QSensorGesturePluginInterface +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "com.Nokia.QSensorGesturePluginInterface" FILE "plugin.json") + 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..03319e81 --- /dev/null +++ b/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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..37c16eb1 --- /dev/null +++ b/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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.pro b/examples/sensors/qmlsensorgestures/qml.pro new file mode 100644 index 00000000..333f251c --- /dev/null +++ b/examples/sensors/qmlsensorgestures/qml.pro @@ -0,0 +1,14 @@ +TEMPLATE = aux + +app.files = \ + $$files(*.qml) \ + info.json \ + icon.png + +MT_SYSROOT=$$(MT_SYSROOT) +!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications +!isEmpty(EXAMPLES_PREFIX) { + app.path = $$EXAMPLES_PREFIX/com.nokia.mt.qmlsensorgestures + INSTALLS = app +} + diff --git a/examples/sensors/qmlsensorgestures/qmlsensorgestures.pro b/examples/sensors/qmlsensorgestures/qmlsensorgestures.pro new file mode 100644 index 00000000..011f5f95 --- /dev/null +++ b/examples/sensors/qmlsensorgestures/qmlsensorgestures.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs +CONFIG += ordered + +SUBDIRS = \ + plugin \ + qml.pro diff --git a/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml b/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml new file mode 100644 index 00000000..5a7a4e20 --- /dev/null +++ b/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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: 460 + y: 20 + color: '#d6d6d6' + + GestureList { + id: gestureList + parent: viewArea + anchors.left: viewArea.left + anchors.top: viewArea.top + anchors.right: viewArea.right + height: viewArea.height / 2 +//! [3] + onSelectedGestureChanged: { + gesture.enabled = false; + gesture.gestureid = gestureList.selectedGesture; +//! [3] + 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 + } +} |