From 5effd1712aa6f1ae2359762cdadeb70198121f77 Mon Sep 17 00:00:00 2001 From: Wolfgang Beck Date: Fri, 25 May 2012 12:31:38 +1000 Subject: Update Examples using the same name conventions e.g. Folder of example should start with QtSensorrs_ Example documentation title should start with QtSensors - images folder renamed to content Change-Id: I341fb8510ba3ad64068d786559e8d28af5d135c3 Reviewed-by: Lincoln Ramsay --- examples/QtSensors/QtSensors.pro | 12 +- .../QtSensors/QtSensors_accel/QtSensors_accel.pro | 7 + examples/QtSensors/QtSensors_accel/main.cpp | 77 ++++++ .../QtSensors_accelbubble.pro | 15 ++ .../QtSensors_accelbubble.qml | 132 ++++++++++ .../QtSensors_accelbubble/content/Bluebubble2.png | Bin 0 -> 12815 bytes examples/QtSensors/QtSensors_accelbubble/icon.png | Bin 0 -> 2034 bytes examples/QtSensors/QtSensors_accelbubble/info.json | 14 + examples/QtSensors/QtSensors_cubehouse/Cube.qml | 81 ++++++ .../QtSensors_cubehouse/QtSensors_cubehouse.pro | 19 ++ .../QtSensors_cubehouse/QtSensors_cubehouse.qml | 113 ++++++++ examples/QtSensors/QtSensors_cubehouse/Room.qml | 288 +++++++++++++++++++++ examples/QtSensors/QtSensors_cubehouse/Table.qml | 50 ++++ .../QtSensors_cubehouse/content/ground.jpg | Bin 0 -> 3077 bytes .../QtSensors_cubehouse/content/qtlogo.png | Bin 0 -> 13923 bytes .../QtSensors/QtSensors_cubehouse/content/roof.jpg | Bin 0 -> 3866 bytes .../QtSensors/QtSensors_cubehouse/content/wall.jpg | Bin 0 -> 6195 bytes examples/QtSensors/QtSensors_cubehouse/icon.png | Bin 0 -> 7607 bytes examples/QtSensors/QtSensors_cubehouse/info.json | 14 + .../QtSensors/QtSensors_cubehouse/mesh/table.3ds | Bin 0 -> 9149 bytes .../QtSensors/QtSensors_grue/QtSensors_grue.pro | 8 + .../QtSensors/QtSensors_grue/QtSensors_grue.qml | 95 +++++++ .../QtSensors_grue/console_app/console_app.pro | 6 + .../QtSensors/QtSensors_grue/console_app/main.cpp | 89 +++++++ examples/QtSensors/QtSensors_grue/grue.png | Bin 0 -> 11207 bytes examples/QtSensors/QtSensors_grue/grue.xcf | Bin 0 -> 23704 bytes examples/QtSensors/QtSensors_grue/icon.png | Bin 0 -> 7951 bytes examples/QtSensors/QtSensors_grue/icon.xcf | Bin 0 -> 22397 bytes .../QtSensors/QtSensors_grue/import/import.pro | 33 +++ examples/QtSensors/QtSensors_grue/import/main.cpp | 142 ++++++++++ .../QtSensors/QtSensors_grue/import/plugin.json | 1 + examples/QtSensors/QtSensors_grue/import/qmldir | 1 + examples/QtSensors/QtSensors_grue/info.json | 14 + .../QtSensors/QtSensors_grue/lib/gruesensor.cpp | 137 ++++++++++ examples/QtSensors/QtSensors_grue/lib/gruesensor.h | 85 ++++++ .../QtSensors/QtSensors_grue/lib/gruesensor_p.h | 66 +++++ examples/QtSensors/QtSensors_grue/lib/lib.pro | 27 ++ .../QtSensors_grue/plugin/gruesensorimpl.cpp | 140 ++++++++++ .../QtSensors_grue/plugin/gruesensorimpl.h | 77 ++++++ examples/QtSensors/QtSensors_grue/plugin/main.cpp | 81 ++++++ .../QtSensors/QtSensors_grue/plugin/plugin.json | 1 + .../QtSensors/QtSensors_grue/plugin/plugin.pro | 27 ++ examples/QtSensors/QtSensors_grue/qml.pro | 15 ++ .../QtSensors_qmlsensorgestures/Button.qml | 129 +++++++++ .../QtSensors_qmlsensorgestures/GestureList.qml | 132 ++++++++++ .../QtSensors_qmlsensorgestures/GestureView.qml | 153 +++++++++++ .../QtSensors_qmlsensorgestures/GesturesView.qml | 156 +++++++++++ .../QtSensors_qmlsensorgestures.pro | 6 + .../QtSensors_qmlsensorgestures.qml | 115 ++++++++ .../QtSensors/QtSensors_qmlsensorgestures/icon.png | Bin 0 -> 2298 bytes .../QtSensors_qmlsensorgestures/info.json | 14 + .../QtSensors_qmlsensorgestures/plugin/plugin.json | 1 + .../QtSensors_qmlsensorgestures/plugin/plugin.pro | 21 ++ .../plugin/qcountergestureplugin.cpp | 75 ++++++ .../plugin/qcountergestureplugin.h | 66 +++++ .../plugin/qcounterrecognizer.cpp | 89 +++++++ .../plugin/qcounterrecognizer.h | 70 +++++ .../QtSensors/QtSensors_qmlsensorgestures/qml.pro | 18 ++ .../QtSensors_sensorgestures.pro | 13 + .../QtSensors/QtSensors_sensorgestures/gesture.png | Bin 0 -> 3400 bytes .../QtSensors/QtSensors_sensorgestures/main.cpp | 51 ++++ .../QtSensors_sensorgestures/mainwindow.cpp | 168 ++++++++++++ .../QtSensors_sensorgestures/mainwindow.h | 76 ++++++ .../QtSensors_sensorgestures/mainwindow.ui | 84 ++++++ examples/QtSensors/accel/accel.pro | 7 - examples/QtSensors/accel/main.cpp | 77 ------ examples/QtSensors/accelbubble/accelbubble.pro | 15 -- examples/QtSensors/accelbubble/icon.png | Bin 2034 -> 0 bytes .../QtSensors/accelbubble/images/Bluebubble2.png | Bin 12815 -> 0 bytes examples/QtSensors/accelbubble/info.json | 14 - examples/QtSensors/accelbubble/main.qml | 132 ---------- examples/QtSensors/cubehouse/Cube.qml | 81 ------ examples/QtSensors/cubehouse/Cubehouse.qml | 113 -------- examples/QtSensors/cubehouse/Room.qml | 288 --------------------- examples/QtSensors/cubehouse/Table.qml | 50 ---- examples/QtSensors/cubehouse/cubehouse.pro | 19 -- examples/QtSensors/cubehouse/icon.png | Bin 7607 -> 0 bytes examples/QtSensors/cubehouse/images/ground.jpg | Bin 3077 -> 0 bytes examples/QtSensors/cubehouse/images/qtlogo.png | Bin 13923 -> 0 bytes examples/QtSensors/cubehouse/images/roof.jpg | Bin 3866 -> 0 bytes examples/QtSensors/cubehouse/images/wall.jpg | Bin 6195 -> 0 bytes examples/QtSensors/cubehouse/info.json | 14 - examples/QtSensors/cubehouse/mesh/table.3ds | Bin 9149 -> 0 bytes .../QtSensors/grue/console_app/console_app.pro | 6 - examples/QtSensors/grue/console_app/main.cpp | 89 ------- examples/QtSensors/grue/grue.pro | 8 - examples/QtSensors/grue/import/import.pro | 33 --- examples/QtSensors/grue/import/main.cpp | 142 ---------- examples/QtSensors/grue/import/plugin.json | 1 - examples/QtSensors/grue/import/qmldir | 1 - examples/QtSensors/grue/lib/gruesensor.cpp | 137 ---------- examples/QtSensors/grue/lib/gruesensor.h | 85 ------ examples/QtSensors/grue/lib/gruesensor_p.h | 66 ----- examples/QtSensors/grue/lib/lib.pro | 27 -- examples/QtSensors/grue/plugin/gruesensorimpl.cpp | 140 ---------- examples/QtSensors/grue/plugin/gruesensorimpl.h | 77 ------ examples/QtSensors/grue/plugin/main.cpp | 81 ------ examples/QtSensors/grue/plugin/plugin.json | 1 - examples/QtSensors/grue/plugin/plugin.pro | 27 -- examples/QtSensors/grue/qml_app/grue.png | Bin 11207 -> 0 bytes examples/QtSensors/grue/qml_app/grue.xcf | Bin 23704 -> 0 bytes examples/QtSensors/grue/qml_app/icon.png | Bin 7951 -> 0 bytes examples/QtSensors/grue/qml_app/icon.xcf | Bin 22397 -> 0 bytes examples/QtSensors/grue/qml_app/info.json | 14 - examples/QtSensors/grue/qml_app/main.qml | 95 ------- examples/QtSensors/grue/qml_app/qml_app.pro | 15 -- .../QtSensors/qmlsensorgestures/plugin/plugin.json | 1 - .../QtSensors/qmlsensorgestures/plugin/plugin.pro | 21 -- .../plugin/qcountergestureplugin.cpp | 75 ------ .../plugin/qcountergestureplugin.h | 66 ----- .../plugin/qcounterrecognizer.cpp | 89 ------- .../qmlsensorgestures/plugin/qcounterrecognizer.h | 70 ----- .../QtSensors/qmlsensorgestures/qml_app/Button.qml | 129 --------- .../qmlsensorgestures/qml_app/Gesture.qml | 115 -------- .../qmlsensorgestures/qml_app/GestureList.qml | 132 ---------- .../qmlsensorgestures/qml_app/GestureView.qml | 153 ----------- .../qmlsensorgestures/qml_app/GesturesView.qml | 156 ----------- .../QtSensors/qmlsensorgestures/qml_app/icon.png | Bin 2298 -> 0 bytes .../QtSensors/qmlsensorgestures/qml_app/info.json | 14 - .../qmlsensorgestures/qml_app/qml_app.pro | 18 -- .../qmlsensorgestures/qmlsensorgestures.pro | 5 - examples/QtSensors/sensorgestures/gesture.png | Bin 3400 -> 0 bytes examples/QtSensors/sensorgestures/main.cpp | 51 ---- examples/QtSensors/sensorgestures/mainwindow.cpp | 168 ------------ examples/QtSensors/sensorgestures/mainwindow.h | 76 ------ examples/QtSensors/sensorgestures/mainwindow.ui | 84 ------ .../QtSensors/sensorgestures/sensorgestures.pro | 13 - 127 files changed, 3298 insertions(+), 3297 deletions(-) create mode 100644 examples/QtSensors/QtSensors_accel/QtSensors_accel.pro create mode 100644 examples/QtSensors/QtSensors_accel/main.cpp create mode 100644 examples/QtSensors/QtSensors_accelbubble/QtSensors_accelbubble.pro create mode 100644 examples/QtSensors/QtSensors_accelbubble/QtSensors_accelbubble.qml create mode 100644 examples/QtSensors/QtSensors_accelbubble/content/Bluebubble2.png create mode 100644 examples/QtSensors/QtSensors_accelbubble/icon.png create mode 100644 examples/QtSensors/QtSensors_accelbubble/info.json create mode 100644 examples/QtSensors/QtSensors_cubehouse/Cube.qml create mode 100644 examples/QtSensors/QtSensors_cubehouse/QtSensors_cubehouse.pro create mode 100644 examples/QtSensors/QtSensors_cubehouse/QtSensors_cubehouse.qml create mode 100644 examples/QtSensors/QtSensors_cubehouse/Room.qml create mode 100644 examples/QtSensors/QtSensors_cubehouse/Table.qml create mode 100644 examples/QtSensors/QtSensors_cubehouse/content/ground.jpg create mode 100644 examples/QtSensors/QtSensors_cubehouse/content/qtlogo.png create mode 100644 examples/QtSensors/QtSensors_cubehouse/content/roof.jpg create mode 100644 examples/QtSensors/QtSensors_cubehouse/content/wall.jpg create mode 100644 examples/QtSensors/QtSensors_cubehouse/icon.png create mode 100644 examples/QtSensors/QtSensors_cubehouse/info.json create mode 100644 examples/QtSensors/QtSensors_cubehouse/mesh/table.3ds create mode 100644 examples/QtSensors/QtSensors_grue/QtSensors_grue.pro create mode 100644 examples/QtSensors/QtSensors_grue/QtSensors_grue.qml create mode 100644 examples/QtSensors/QtSensors_grue/console_app/console_app.pro create mode 100644 examples/QtSensors/QtSensors_grue/console_app/main.cpp create mode 100644 examples/QtSensors/QtSensors_grue/grue.png create mode 100644 examples/QtSensors/QtSensors_grue/grue.xcf create mode 100644 examples/QtSensors/QtSensors_grue/icon.png create mode 100644 examples/QtSensors/QtSensors_grue/icon.xcf create mode 100644 examples/QtSensors/QtSensors_grue/import/import.pro create mode 100644 examples/QtSensors/QtSensors_grue/import/main.cpp create mode 100644 examples/QtSensors/QtSensors_grue/import/plugin.json create mode 100644 examples/QtSensors/QtSensors_grue/import/qmldir create mode 100644 examples/QtSensors/QtSensors_grue/info.json create mode 100644 examples/QtSensors/QtSensors_grue/lib/gruesensor.cpp create mode 100644 examples/QtSensors/QtSensors_grue/lib/gruesensor.h create mode 100644 examples/QtSensors/QtSensors_grue/lib/gruesensor_p.h create mode 100644 examples/QtSensors/QtSensors_grue/lib/lib.pro create mode 100644 examples/QtSensors/QtSensors_grue/plugin/gruesensorimpl.cpp create mode 100644 examples/QtSensors/QtSensors_grue/plugin/gruesensorimpl.h create mode 100644 examples/QtSensors/QtSensors_grue/plugin/main.cpp create mode 100644 examples/QtSensors/QtSensors_grue/plugin/plugin.json create mode 100644 examples/QtSensors/QtSensors_grue/plugin/plugin.pro create mode 100644 examples/QtSensors/QtSensors_grue/qml.pro create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/Button.qml create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/GestureList.qml create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/GestureView.qml create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/GesturesView.qml create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/QtSensors_qmlsensorgestures.pro create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/QtSensors_qmlsensorgestures.qml create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/icon.png create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/info.json create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/plugin/plugin.json create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/plugin/plugin.pro create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/plugin/qcountergestureplugin.cpp create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/plugin/qcountergestureplugin.h create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/plugin/qcounterrecognizer.cpp create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/plugin/qcounterrecognizer.h create mode 100644 examples/QtSensors/QtSensors_qmlsensorgestures/qml.pro create mode 100644 examples/QtSensors/QtSensors_sensorgestures/QtSensors_sensorgestures.pro create mode 100644 examples/QtSensors/QtSensors_sensorgestures/gesture.png create mode 100644 examples/QtSensors/QtSensors_sensorgestures/main.cpp create mode 100644 examples/QtSensors/QtSensors_sensorgestures/mainwindow.cpp create mode 100644 examples/QtSensors/QtSensors_sensorgestures/mainwindow.h create mode 100644 examples/QtSensors/QtSensors_sensorgestures/mainwindow.ui delete mode 100644 examples/QtSensors/accel/accel.pro delete mode 100644 examples/QtSensors/accel/main.cpp delete mode 100644 examples/QtSensors/accelbubble/accelbubble.pro delete mode 100644 examples/QtSensors/accelbubble/icon.png delete mode 100644 examples/QtSensors/accelbubble/images/Bluebubble2.png delete mode 100644 examples/QtSensors/accelbubble/info.json delete mode 100644 examples/QtSensors/accelbubble/main.qml delete mode 100644 examples/QtSensors/cubehouse/Cube.qml delete mode 100644 examples/QtSensors/cubehouse/Cubehouse.qml delete mode 100644 examples/QtSensors/cubehouse/Room.qml delete mode 100644 examples/QtSensors/cubehouse/Table.qml delete mode 100644 examples/QtSensors/cubehouse/cubehouse.pro delete mode 100644 examples/QtSensors/cubehouse/icon.png delete mode 100644 examples/QtSensors/cubehouse/images/ground.jpg delete mode 100644 examples/QtSensors/cubehouse/images/qtlogo.png delete mode 100644 examples/QtSensors/cubehouse/images/roof.jpg delete mode 100644 examples/QtSensors/cubehouse/images/wall.jpg delete mode 100644 examples/QtSensors/cubehouse/info.json delete mode 100644 examples/QtSensors/cubehouse/mesh/table.3ds delete mode 100644 examples/QtSensors/grue/console_app/console_app.pro delete mode 100644 examples/QtSensors/grue/console_app/main.cpp delete mode 100644 examples/QtSensors/grue/grue.pro delete mode 100644 examples/QtSensors/grue/import/import.pro delete mode 100644 examples/QtSensors/grue/import/main.cpp delete mode 100644 examples/QtSensors/grue/import/plugin.json delete mode 100644 examples/QtSensors/grue/import/qmldir delete mode 100644 examples/QtSensors/grue/lib/gruesensor.cpp delete mode 100644 examples/QtSensors/grue/lib/gruesensor.h delete mode 100644 examples/QtSensors/grue/lib/gruesensor_p.h delete mode 100644 examples/QtSensors/grue/lib/lib.pro delete mode 100644 examples/QtSensors/grue/plugin/gruesensorimpl.cpp delete mode 100644 examples/QtSensors/grue/plugin/gruesensorimpl.h delete mode 100644 examples/QtSensors/grue/plugin/main.cpp delete mode 100644 examples/QtSensors/grue/plugin/plugin.json delete mode 100644 examples/QtSensors/grue/plugin/plugin.pro delete mode 100644 examples/QtSensors/grue/qml_app/grue.png delete mode 100644 examples/QtSensors/grue/qml_app/grue.xcf delete mode 100644 examples/QtSensors/grue/qml_app/icon.png delete mode 100644 examples/QtSensors/grue/qml_app/icon.xcf delete mode 100644 examples/QtSensors/grue/qml_app/info.json delete mode 100644 examples/QtSensors/grue/qml_app/main.qml delete mode 100644 examples/QtSensors/grue/qml_app/qml_app.pro delete mode 100644 examples/QtSensors/qmlsensorgestures/plugin/plugin.json delete mode 100644 examples/QtSensors/qmlsensorgestures/plugin/plugin.pro delete mode 100644 examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp delete mode 100644 examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.h delete mode 100644 examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp delete mode 100644 examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.h delete mode 100644 examples/QtSensors/qmlsensorgestures/qml_app/Button.qml delete mode 100644 examples/QtSensors/qmlsensorgestures/qml_app/Gesture.qml delete mode 100644 examples/QtSensors/qmlsensorgestures/qml_app/GestureList.qml delete mode 100644 examples/QtSensors/qmlsensorgestures/qml_app/GestureView.qml delete mode 100644 examples/QtSensors/qmlsensorgestures/qml_app/GesturesView.qml delete mode 100644 examples/QtSensors/qmlsensorgestures/qml_app/icon.png delete mode 100644 examples/QtSensors/qmlsensorgestures/qml_app/info.json delete mode 100644 examples/QtSensors/qmlsensorgestures/qml_app/qml_app.pro delete mode 100644 examples/QtSensors/qmlsensorgestures/qmlsensorgestures.pro delete mode 100644 examples/QtSensors/sensorgestures/gesture.png delete mode 100644 examples/QtSensors/sensorgestures/main.cpp delete mode 100644 examples/QtSensors/sensorgestures/mainwindow.cpp delete mode 100644 examples/QtSensors/sensorgestures/mainwindow.h delete mode 100644 examples/QtSensors/sensorgestures/mainwindow.ui delete mode 100644 examples/QtSensors/sensorgestures/sensorgestures.pro (limited to 'examples') diff --git a/examples/QtSensors/QtSensors.pro b/examples/QtSensors/QtSensors.pro index 3e64991..fd775ab 100644 --- a/examples/QtSensors/QtSensors.pro +++ b/examples/QtSensors/QtSensors.pro @@ -1,16 +1,16 @@ TEMPLATE = subdirs SUBDIRS += \ - accel \ - accelbubble \ - cubehouse \ - grue \ - qmlsensorgestures \ + QtSensors_accel \ + QtSensors_accelbubble \ + QtSensors_cubehouse \ + QtSensors_grue \ + QtSensors_qmlsensorgestures \ QtSensors_maze \ QtSensors_qmlqtsensors \ QtSensors_sensor_explorer \ QtSensors_shakeit !isEmpty(QT.widgets.name):SUBDIRS += \ - sensorgestures + QtSensors_sensorgestures diff --git a/examples/QtSensors/QtSensors_accel/QtSensors_accel.pro b/examples/QtSensors/QtSensors_accel/QtSensors_accel.pro new file mode 100644 index 0000000..86303ec --- /dev/null +++ b/examples/QtSensors/QtSensors_accel/QtSensors_accel.pro @@ -0,0 +1,7 @@ +TEMPLATE=app +TARGET=accel + +QT=core sensors + +SOURCES=main.cpp + diff --git a/examples/QtSensors/QtSensors_accel/main.cpp b/examples/QtSensors/QtSensors_accel/main.cpp new file mode 100644 index 0000000..012c8c6 --- /dev/null +++ b/examples/QtSensors/QtSensors_accel/main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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 +#include + +QAccelerometer *accelerometer; + +class AccelerometerFilter : public QAccelerometerFilter +{ +public: + bool filter(QAccelerometerReading *reading) + { + qDebug() << "acceleration: " + << QString().sprintf("%0.2f %0.2f %0.2f", + reading->x(), + reading->y(), + reading->z()); + return false; // don't store the reading in the sensor + } +}; + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + QAccelerometer sensor; + accelerometer = &sensor; + AccelerometerFilter filter; + sensor.addFilter(&filter); + sensor.start(); + + if (!sensor.isActive()) { + qWarning("Accelerometer didn't start!"); + return 1; + } + + return app.exec(); +} + diff --git a/examples/QtSensors/QtSensors_accelbubble/QtSensors_accelbubble.pro b/examples/QtSensors/QtSensors_accelbubble/QtSensors_accelbubble.pro new file mode 100644 index 0000000..feeec68 --- /dev/null +++ b/examples/QtSensors/QtSensors_accelbubble/QtSensors_accelbubble.pro @@ -0,0 +1,15 @@ +TEMPLATE = aux + +app.files = \ + info.json \ + main.qml \ + icon.png \ + images + +MT_SYSROOT=$$(MT_SYSROOT) +!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications +!isEmpty(EXAMPLES_PREFIX) { + app.path = $$EXAMPLES_PREFIX/com.nokia.mt.accelbubble + INSTALLS = app +} + diff --git a/examples/QtSensors/QtSensors_accelbubble/QtSensors_accelbubble.qml b/examples/QtSensors/QtSensors_accelbubble/QtSensors_accelbubble.qml new file mode 100644 index 0000000..2117698 --- /dev/null +++ b/examples/QtSensors/QtSensors_accelbubble/QtSensors_accelbubble.qml @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** 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 QtQuick 2.0 +//! [0] +import QtMobility.sensors 1.2 +//! [0] + + +Rectangle { + width: 360 + height: 360 + id: mainPage + +//! [1] + Accelerometer { + id: accel +//! [1] +//! [3] + active:true +//! [3] + property real accelY; + property real accelX; + } + +//! [2] + Timer { + interval: 500; running: true; repeat: true + + property real xdiff; + property real ydiff; + + onTriggered: { + xdiff = accel.reading.x - accel.accelX; + ydiff = accel.reading.y - accel.accelY; + + if (Math.abs(xdiff) > 0.3) { + accel.accelX = -accel.reading.x + } + if (Math.abs(ydiff) > 0.3) { + accel.accelY = accel.reading.y + } + } + } +//! [2] + + Image { + id: bubble + source: "content/Bluebubble2.png" + property real centerX: parent.width / 2 + property real centerY: parent.height / 2; + property real bubbleCenter: bubble.width / 2 + + function calX() { + var newX = centerX + accel.accelX / -1 * centerX + + if ((newX - bubbleCenter) < 0) { + return 0 + } + else if ((newX + bubbleCenter) > parent.width) { + return parent.width - 2 * bubbleCenter + } + return newX - bubbleCenter; + } + x: calX(); + + function calY() { + var newY = centerY + accel.accelY / -1 * centerY + + if ((newY - bubbleCenter) < 0) { + return 0 + } + else if ((newY + bubbleCenter) > parent.height) { + return parent.height - 2 * bubbleCenter + } + return newY - bubbleCenter; + } + y: calY(); + + smooth: true + + Behavior on y { + SmoothedAnimation { + easing.type: Easing.Linear + duration: 2500 + } + } + Behavior on x { + SmoothedAnimation { + easing.type: Easing.Linear + duration: 2500 + } + } + } +} diff --git a/examples/QtSensors/QtSensors_accelbubble/content/Bluebubble2.png b/examples/QtSensors/QtSensors_accelbubble/content/Bluebubble2.png new file mode 100644 index 0000000..f96126e Binary files /dev/null and b/examples/QtSensors/QtSensors_accelbubble/content/Bluebubble2.png differ diff --git a/examples/QtSensors/QtSensors_accelbubble/icon.png b/examples/QtSensors/QtSensors_accelbubble/icon.png new file mode 100644 index 0000000..d74f111 Binary files /dev/null and b/examples/QtSensors/QtSensors_accelbubble/icon.png differ diff --git a/examples/QtSensors/QtSensors_accelbubble/info.json b/examples/QtSensors/QtSensors_accelbubble/info.json new file mode 100644 index 0000000..b91dd9f --- /dev/null +++ b/examples/QtSensors/QtSensors_accelbubble/info.json @@ -0,0 +1,14 @@ +{ + "info-version": "1.0", + "dict": { + "displayName": { + "en_US": "Accel Bubble" + }, + "identifier": "com.nokia.mt.accelbubble", + "runtime": "qml", + "main": "QtSensors_accelbubble.qml", + "version": "1.0.0", + "category": "application", + "subcategory": "utility" + } +} diff --git a/examples/QtSensors/QtSensors_cubehouse/Cube.qml b/examples/QtSensors/QtSensors_cubehouse/Cube.qml new file mode 100644 index 0000000..b8afe81 --- /dev/null +++ b/examples/QtSensors/QtSensors_cubehouse/Cube.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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 QtQuick 2.0 +import Qt3D 1.0 +import Qt3D.Shapes 1.0 + +Cube { + objectName: "cube" + + transform: [ + Rotation3D { + angle: 45.0 + axis: Qt.vector3d(1, 0, 0) + }, + Rotation3D { + angle: 45.0 + axis: Qt.vector3d(0, 0, 1) + }, + Rotation3D { + id: yRT + angle: 0 + axis: Qt.vector3d(0, -1, 0) + } + ] + + SequentialAnimation { + running: true + loops: Animation.Infinite + NumberAnimation { + target: yRT + property: "angle" + from: 0 + to: 360 + duration: 1000 + } + } + + effect: Effect { + color: "#aaca00" + texture: "content/qtlogo.png" + decal: true + } +} diff --git a/examples/QtSensors/QtSensors_cubehouse/QtSensors_cubehouse.pro b/examples/QtSensors/QtSensors_cubehouse/QtSensors_cubehouse.pro new file mode 100644 index 0000000..075ec4e --- /dev/null +++ b/examples/QtSensors/QtSensors_cubehouse/QtSensors_cubehouse.pro @@ -0,0 +1,19 @@ +TEMPLATE = aux + +app.files = \ + Cube.qml \ + Cubehouse.qml \ + Room.qml \ + Table.qml \ + icon.png \ + images \ + info.json \ + mesh + +MT_SYSROOT=$$(MT_SYSROOT) +!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications +!isEmpty(EXAMPLES_PREFIX) { + app.path = $$EXAMPLES_PREFIX/com.nokia.mt.cubehouse + INSTALLS = app +} + diff --git a/examples/QtSensors/QtSensors_cubehouse/QtSensors_cubehouse.qml b/examples/QtSensors/QtSensors_cubehouse/QtSensors_cubehouse.qml new file mode 100644 index 0000000..5a1b91f --- /dev/null +++ b/examples/QtSensors/QtSensors_cubehouse/QtSensors_cubehouse.qml @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** 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 QtQuick 2.0 +import Qt3D 1.0 +import Qt3D.Shapes 1.0 + +//! [0] +import QtMobility.sensors 1.3 +//! [0] + +import "." + +Item { + id: mainWindow + width: 320 + height: 480 + + Viewport { + id: view + anchors.top: parent.top + width: parent.width + height: parent.height + fillColor: "darkblue" + objectName: "cube viewport" + camera: Camera { eye: Qt.vector3d(0, 3, 1.6 * room.scale - 4)} + + Room{ + id: room + scale: 7.0 + } + + function rotateY(y) + { + room.rotateY(y); + } + + function rotateX(x) + { + room.rotateX(x); + } + } + +//! [1] + Accelerometer { + id: accel + active: true + dataRate: 20 +//! [1] + +//! [2] + property double pitch: 0.0 + property double roll: 0.0 +//! [2] + +//! [3] + onReadingChanged: { + pitch = -(Math.atan2(reading.x, Math.sqrt(reading.y * reading.y + reading.z * reading.z)) * 180) / Math.PI; + roll = (Math.atan2(reading.y, Math.sqrt(reading.x * reading.x + reading.z * reading.z)) * 180) / Math.PI; + } + } +//! [3] + + + //Timer to read out the x and y rotation of the TiltSensor +//! [4] + Timer { + interval: 50; running: true; repeat: true + + onTriggered: { + view.rotateY(accel.pitch); + view.rotateX(accel.roll); + } + } +//! [4] +} diff --git a/examples/QtSensors/QtSensors_cubehouse/Room.qml b/examples/QtSensors/QtSensors_cubehouse/Room.qml new file mode 100644 index 0000000..848735b --- /dev/null +++ b/examples/QtSensors/QtSensors_cubehouse/Room.qml @@ -0,0 +1,288 @@ +/**************************************************************************** +** +** 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 QtQuick 2.0 +import Qt3D 1.0 +import Qt3D.Shapes 1.0 +import "." + +Item3D{ + id: room + property double scale: 1.0 + property bool yspin: false + property bool xspin: false + property int yrot: 0 + property int xrot: 0 + property double distanceCorrection: 3.7 + + transform: [ + Rotation3D { + id: yRT + angle: 0 + axis: Qt.vector3d(0, -1, 0) + }, + Rotation3D { + id: xRT + angle: 0 + axis: Qt.vector3d(-1, 0, 0) + } + ] + + SequentialAnimation { + running: yspin + NumberAnimation { + target: yRT + property: "angle" + to: yrot + easing.type:"Linear" + duration: 50 + } + onCompleted: yspin = false + } + + SequentialAnimation { + running: xspin + NumberAnimation { + target: xRT + property: "angle" + to: xrot + easing.type:"Linear" + duration: 50 + } + onCompleted: xspin = false + } + + function rotateY(y) + { + room.yrot=y; + room.yspin = true; + } + + function rotateX(x) + { + room.xrot=x; + room.xspin = true; + } + + Quad { + id: frontWall + scale: room.scale + effect: Effect { + texture: "content/wall.jpg" + } + transform: [ + Translation3D { + translate: Qt.vector3d(0, -frontWall.scale + room.distanceCorrection, 0) + }, + Rotation3D { + angle: 90 + axis: Qt.vector3d(1, 0, 0) + }, + Rotation3D { + angle: 0 + axis: Qt.vector3d(0, 1, 0) + }, + Rotation3D { + angle: 0 + axis: Qt.vector3d(0, 0, 1) + } + ] + } + + Quad { + id: ground + scale: room.scale + effect: Effect { + texture: "content/ground.jpg" + } + transform: [ + Translation3D { + translate: Qt.vector3d(0, -ground.scale + room.distanceCorrection, 0) + }, + Rotation3D { + angle: 90 + axis: Qt.vector3d(1, 0, 0) + }, + Rotation3D { + angle: 90 + axis: Qt.vector3d(0, 1, 0) + }, + Rotation3D { + angle: 90 + axis: Qt.vector3d(0, 0, 1) + } + ] + } + + Quad { + id: leftWall + scale: room.scale + effect: Effect { + texture: "content/wall.jpg" + } + transform: [ + Translation3D { + translate: Qt.vector3d(0, -leftWall.scale + room.distanceCorrection, 0) + }, + Rotation3D { + angle: 0 + axis: Qt.vector3d(1, 0, 0) + }, + Rotation3D { + angle: 90 + axis: Qt.vector3d(0, 1, 0) + }, + Rotation3D { + angle: 90 + axis: Qt.vector3d(0, 0, 1) + } + ] + } + + Quad { + id: rightWall + scale: room.scale + effect: Effect { + texture: "content/wall.jpg" + } + transform: [ + Translation3D { + translate: Qt.vector3d(0, -rightWall.scale + room.distanceCorrection, 0) + }, + Rotation3D { + angle: 180 + axis: Qt.vector3d(1, 0, 0) + }, + Rotation3D { + angle: 90 + axis: Qt.vector3d(0, 1, 0) + }, + Rotation3D { + angle: 90 + axis: Qt.vector3d(0, 0, 1) + } + ] + } + + Quad { + id: roof + scale: room.scale + effect: Effect { + texture: "content/roof.jpg" + } + transform: [ + Translation3D { + translate: Qt.vector3d(0, -roof.scale + room.distanceCorrection, 0) + }, + Rotation3D { + angle: 90 + axis: Qt.vector3d(1, 0, 0) + }, + Rotation3D { + angle: -90 + axis: Qt.vector3d(0, 1, 0) + }, + Rotation3D { + angle: 90 + axis: Qt.vector3d(0, 0, 1) + } + ] + } + + Quad { + id: backWall + scale: room.scale + effect: Effect { + texture: "content/wall.jpg" + } + transform: [ + Translation3D { + translate: Qt.vector3d(0, -backWall.scale + room.distanceCorrection, 0) + }, + Rotation3D { + angle: -90 + axis: Qt.vector3d(1, 0, 0) + }, + Rotation3D { + angle: 0 + axis: Qt.vector3d(0, 1, 0) + }, + Rotation3D { + angle: 0 + axis: Qt.vector3d(0, 0, 1) + } + ] + } + + Cube { + id: cube + scale: 0.5 + + transform: [ + Translation3D { + translate: Qt.vector3d(0.0, 0.0, 0.0) + } + ] + } + + Table { + scale: 0.025 + transform: [ + Translation3D { + translate: Qt.vector3d(0, -7 + room.distanceCorrection, 0) + } + ] + } + + Teapot { + scale: 0.5 + + effect: Effect { + color: "#ffffaa" + decal: true + } + + transform: [ + Translation3D { + translate: Qt.vector3d(0.0, -4.50 + room.distanceCorrection, 0.0) + } + ] + } +} diff --git a/examples/QtSensors/QtSensors_cubehouse/Table.qml b/examples/QtSensors/QtSensors_cubehouse/Table.qml new file mode 100644 index 0000000..683d28d --- /dev/null +++ b/examples/QtSensors/QtSensors_cubehouse/Table.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** 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 QtQuick 2.0 +import Qt3D 1.0 +import Qt3D.Shapes 1.0 +import "." + +Item3D { + id: table + scale: 1 + mesh: Mesh { source: "mesh/table.3ds" } +} diff --git a/examples/QtSensors/QtSensors_cubehouse/content/ground.jpg b/examples/QtSensors/QtSensors_cubehouse/content/ground.jpg new file mode 100644 index 0000000..2664b99 Binary files /dev/null and b/examples/QtSensors/QtSensors_cubehouse/content/ground.jpg differ diff --git a/examples/QtSensors/QtSensors_cubehouse/content/qtlogo.png b/examples/QtSensors/QtSensors_cubehouse/content/qtlogo.png new file mode 100644 index 0000000..7d3e97e Binary files /dev/null and b/examples/QtSensors/QtSensors_cubehouse/content/qtlogo.png differ diff --git a/examples/QtSensors/QtSensors_cubehouse/content/roof.jpg b/examples/QtSensors/QtSensors_cubehouse/content/roof.jpg new file mode 100644 index 0000000..53a35d6 Binary files /dev/null and b/examples/QtSensors/QtSensors_cubehouse/content/roof.jpg differ diff --git a/examples/QtSensors/QtSensors_cubehouse/content/wall.jpg b/examples/QtSensors/QtSensors_cubehouse/content/wall.jpg new file mode 100644 index 0000000..7c56e23 Binary files /dev/null and b/examples/QtSensors/QtSensors_cubehouse/content/wall.jpg differ diff --git a/examples/QtSensors/QtSensors_cubehouse/icon.png b/examples/QtSensors/QtSensors_cubehouse/icon.png new file mode 100644 index 0000000..193ad56 Binary files /dev/null and b/examples/QtSensors/QtSensors_cubehouse/icon.png differ diff --git a/examples/QtSensors/QtSensors_cubehouse/info.json b/examples/QtSensors/QtSensors_cubehouse/info.json new file mode 100644 index 0000000..7b1c5af --- /dev/null +++ b/examples/QtSensors/QtSensors_cubehouse/info.json @@ -0,0 +1,14 @@ +{ + "info-version": "1.0", + "dict": { + "displayName": { + "en_US": "Cubehouse" + }, + "identifier": "com.nokia.mt.cubehouse", + "runtime": "qml", + "main": "QtSensors_cubehouse.qml", + "version": "1.0.0", + "category": "application", + "subcategory": "utility" + } +} diff --git a/examples/QtSensors/QtSensors_cubehouse/mesh/table.3ds b/examples/QtSensors/QtSensors_cubehouse/mesh/table.3ds new file mode 100644 index 0000000..3e576bd Binary files /dev/null and b/examples/QtSensors/QtSensors_cubehouse/mesh/table.3ds differ diff --git a/examples/QtSensors/QtSensors_grue/QtSensors_grue.pro b/examples/QtSensors/QtSensors_grue/QtSensors_grue.pro new file mode 100644 index 0000000..de917bf --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/QtSensors_grue.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs + +SUBDIRS += lib plugin console_app +SUBDIRS += import qml.pro + +plugin.depends = lib +import.depends = lib + diff --git a/examples/QtSensors/QtSensors_grue/QtSensors_grue.qml b/examples/QtSensors/QtSensors_grue/QtSensors_grue.qml new file mode 100644 index 0000000..05d267c --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/QtSensors_grue.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 QtQuick 2.0 +import QtMobility.sensors 1.3 +import Grue 1.0 + +Rectangle { + width: 240 + height: 320 + color: "black" + + GrueSensor { + id: sensor + active: true + onReadingChanged: { + var percent = reading.chanceOfBeingEaten; + var thetext = ""; + var theopacity = 0; + if (percent === 0) { + thetext = "It is light. You are safe from Grues."; + } + else if (percent === 100) { + thetext = "You have been eaten by a Grue!"; + sensor.active = false; + theopacity = 1; + } + else if (percent > 0) { + thetext = "It is dark. You are likely to be eaten by a Grue. " + + "Your chance of being eaten by a Grue: "+percent+" percent."; + theopacity = 0.05 + (percent * 0.001); + } + text.font.pixelSize = 30; + text.text = "

" + thetext + "

"; + grueimg.opacity = theopacity; + } + } + + Text { + id: text + anchors.top: parent.top + anchors.topMargin: 20 + anchors.left: parent.left + anchors.right: parent.right + text: "I can't tell if you're going to be eaten by a Grue or not. You're on your own!" + wrapMode: Text.WordWrap + font.pixelSize: 50 + color: "white" + } + + Image { + id: grueimg + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + source: "grue.png" + opacity: 0 + } +} diff --git a/examples/QtSensors/QtSensors_grue/console_app/console_app.pro b/examples/QtSensors/QtSensors_grue/console_app/console_app.pro new file mode 100644 index 0000000..33d4317 --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/console_app/console_app.pro @@ -0,0 +1,6 @@ +TEMPLATE=app +TARGET=detect_grue +CONFIG += console +QT=core sensors +SOURCES=main.cpp + diff --git a/examples/QtSensors/QtSensors_grue/console_app/main.cpp b/examples/QtSensors/QtSensors_grue/console_app/main.cpp new file mode 100644 index 0000000..dc62e4d --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/console_app/main.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 +#include + +class Filter : public QSensorFilter +{ + int lastPercent; +public: + Filter() + : QSensorFilter() + , lastPercent(0) + { + } + + bool filter(QSensorReading *reading) + { + int percent = reading->property("chanceOfBeingEaten").value() * 100; + if (percent == 0) { + qDebug() << "It is light. You are safe from Grues."; + } else if (lastPercent == 0) { + qDebug() << "It is dark. You are likely to be eaten by a Grue."; + } + if (percent == 100) { + qDebug() << "You have been eaten by a Grue!"; + QCoreApplication::instance()->quit(); + } else if (percent) + qDebug() << "Your chance of being eaten by a Grue:" << percent << "percent."; + lastPercent = percent; + return false; + } +}; + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + QSensor sensor("GrueSensor"); + + Filter filter; + sensor.addFilter(&filter); + sensor.start(); + + if (!sensor.isActive()) { + qWarning("The Grue sensor didn't start. You're on your own!"); + return 1; + } + + return app.exec(); +} + diff --git a/examples/QtSensors/QtSensors_grue/grue.png b/examples/QtSensors/QtSensors_grue/grue.png new file mode 100644 index 0000000..f0b070b Binary files /dev/null and b/examples/QtSensors/QtSensors_grue/grue.png differ diff --git a/examples/QtSensors/QtSensors_grue/grue.xcf b/examples/QtSensors/QtSensors_grue/grue.xcf new file mode 100644 index 0000000..2837ed7 Binary files /dev/null and b/examples/QtSensors/QtSensors_grue/grue.xcf differ diff --git a/examples/QtSensors/QtSensors_grue/icon.png b/examples/QtSensors/QtSensors_grue/icon.png new file mode 100644 index 0000000..f3f038c Binary files /dev/null and b/examples/QtSensors/QtSensors_grue/icon.png differ diff --git a/examples/QtSensors/QtSensors_grue/icon.xcf b/examples/QtSensors/QtSensors_grue/icon.xcf new file mode 100644 index 0000000..8416c49 Binary files /dev/null and b/examples/QtSensors/QtSensors_grue/icon.xcf differ diff --git a/examples/QtSensors/QtSensors_grue/import/import.pro b/examples/QtSensors/QtSensors_grue/import/import.pro new file mode 100644 index 0000000..753e1ef --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/import/import.pro @@ -0,0 +1,33 @@ +TEMPLATE = lib +CONFIG += plugin + +TARGET = $$qtLibraryTarget(declarative_grue) +TARGETPATH = Grue + +QT = core gui qml sensors + +INCLUDEPATH += $$PWD/../lib +LIBS += -L$$OUT_PWD/../lib -lgruesensor + +SOURCES = main.cpp + +MT_SYSROOT=$$(MT_SYSROOT) +!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications +!isEmpty(EXAMPLES_PREFIX):DESTPATH=$$EXAMPLES_PREFIX/com.nokia.mt.grue/imports/Grue +else:DESTPATH=$$[QT_INSTALL_IMPORTS]/Grue + +target.path=$$DESTPATH +INSTALLS += target + +qmldir.files=$$PWD/qmldir +qmldir.path=$$DESTPATH +INSTALLS += qmldir + +OTHER_FILES += \ + plugin.json qmldir + +!isEmpty(EXAMPLES_PREFIX) { + QMAKE_LFLAGS += -Wl,-rpath,$$EXAMPLES_PREFIX/com.nokia.mt.grue/lib + DEFINES += "BUNDLED_PLUGIN=\\\"$$EXAMPLES_PREFIX/com.nokia.mt.grue/plugins/sensors/libqtsensors_grue.so\\\"" +} + diff --git a/examples/QtSensors/QtSensors_grue/import/main.cpp b/examples/QtSensors/QtSensors_grue/import/main.cpp new file mode 100644 index 0000000..6c32703 --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/import/main.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** 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 +#include + +#include +#include + +#ifdef BUNDLED_PLUGIN +#include +#include +#endif + +QT_BEGIN_NAMESPACE + +class GrueSensorQmlImport : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json") +public: + virtual void registerTypes(const char *uri) + { + char const * const package = "Grue"; + if (QLatin1String(uri) != QLatin1String(package)) return; + int major; + int minor; + + // Register the 1.0 interfaces + major = 1; + minor = 0; + qmlRegisterType (package, major, minor, "GrueSensor"); + qmlRegisterUncreatableType(package, major, minor, "GrueSensorReading", QLatin1String("Cannot create GrueSensorReading")); + } + +#ifdef BUNDLED_PLUGIN + GrueSensorQmlImport() + { + // For now, this is getting called after Sensors has loaded + // Ensure that a change later does not break this by forcing + // sensors to load now + (void)QSensor::sensorTypes(); + + // Load the bundled sensor plugin + QPluginLoader loader(QString::fromLocal8Bit(BUNDLED_PLUGIN)); + QObject *instance = loader.instance(); + m_changes = qobject_cast(instance); + if (m_changes) { + QSensor *sensor = new QSensor(QByteArray(), this); + connect(sensor, SIGNAL(availableSensorsChanged()), this, SLOT(sensorsChanged())); + m_changes->sensorsChanged(); + } + QSensorPluginInterface *plugin = qobject_cast(instance); + if (plugin) { + plugin->registerSensors(); + } + } + +private slots: + void sensorsChanged() + { + m_changes->sensorsChanged(); + } + +private: + QSensorChangesInterface *m_changes; +#endif +}; + +QT_END_NAMESPACE + +#include "main.moc" + +/* + \qmlclass GrueSensor GrueSensor + \inherits QtMobility.sensors1::Sensor + \inqmlmodule Grue 1 + \brief The GrueSensor element reports on your chance of being eaten by a Grue. + + The GrueSensor element reports on your chance of being eaten by a Grue. + + This element wraps the GrueSensor class. Please see the documentation for + GrueSensor for details. + + \sa {QtMobility.sensors QML Limitations} +*/ + +/* + \qmlclass GrueSensorReading GrueSensorReading + \inherits QtMobility.sensors1::SensorReading + \inqmlmodule Grue 1 + \brief The GrueSensorReading element holds the most recent GrueSensor reading. + + The GrueSensorReading element holds the most recent GrueSensor reading. + + This element wraps the GrueSensorReading class. Please see the documentation for + GrueSensorReading for details. + + This element cannot be directly created. +*/ + +/* + \qmlproperty qreal Grue1::GrueSensorReading::chanceOfBeingEaten + Please see GrueSensorReading::chanceOfBeingEaten for information about this property. +*/ diff --git a/examples/QtSensors/QtSensors_grue/import/plugin.json b/examples/QtSensors/QtSensors_grue/import/plugin.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/import/plugin.json @@ -0,0 +1 @@ +{} diff --git a/examples/QtSensors/QtSensors_grue/import/qmldir b/examples/QtSensors/QtSensors_grue/import/qmldir new file mode 100644 index 0000000..266b7c1 --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/import/qmldir @@ -0,0 +1 @@ +plugin declarative_grue diff --git a/examples/QtSensors/QtSensors_grue/info.json b/examples/QtSensors/QtSensors_grue/info.json new file mode 100644 index 0000000..7512905 --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/info.json @@ -0,0 +1,14 @@ +{ + "info-version": "1.0", + "dict": { + "displayName": { + "en_US": "Grue Sensor" + }, + "identifier": "com.nokia.mt.grue", + "runtime": "qml", + "main": "QtSensors_grue.qml", + "version": "1.0.0", + "category": "application", + "subcategory": "utility" + } +} diff --git a/examples/QtSensors/QtSensors_grue/lib/gruesensor.cpp b/examples/QtSensors/QtSensors_grue/lib/gruesensor.cpp new file mode 100644 index 0000000..b1f00ed --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/lib/gruesensor.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** 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 "gruesensor.h" +#include "gruesensor_p.h" + +IMPLEMENT_READING(GrueSensorReading) + +/* + \class GrueSensorReading + + \brief The GrueSensorReading class holds readings from the Grue sensor. + + The Grue Sensor informs you of your chance of being eaten by a Grue. + + Grues love the dark so as long as your surroundings are relatively light + you are safe. However the more time you spend in the dark, the higher + your chances are of being eaten by a Grue. +*/ + +/* + \property GrueSensorReading::chanceOfBeingEaten + \brief holds your chance of being eaten. + + The value is the probability (from 0 to 100) that a Grue will eat you. + A probability of 100 means you are currently being eaten. The darker + it is, the more likely you are to be eaten by a Grue. The longer you + stay in a dark area, the more likely you are to be eaten by a Grue. + If you are in a lit room, the probability will be 0 as Grues fear light. +*/ + +int GrueSensorReading::chanceOfBeingEaten() const +{ + return d->chanceOfBeingEaten; +} + +void GrueSensorReading::setChanceOfBeingEaten(int chanceOfBeingEaten) +{ + d->chanceOfBeingEaten = chanceOfBeingEaten; +} + +// ===================================================================== + +// begin generated code + +/* + \class GrueFilter + + \brief The GrueFilter class is a convenience wrapper around QSensorFilter. + + The only difference is that the filter() method features a pointer to GrueSensorReading + instead of QSensorReading. +*/ + +/* + \fn GrueFilter::filter(GrueSensorReading *reading) + + Called when \a reading changes. Returns false to prevent the reading from propagating. + + \sa QSensorFilter::filter() +*/ + +char const * const GrueSensor::type("GrueSensor"); + +/* + \class GrueSensor + + \brief The GrueSensor class is a convenience wrapper around QSensor. + + The only behavioural difference is that this class sets the type properly. + + This class also features a reading() function that returns a GrueSensorReading instead of a QSensorReading. + + For details about how the sensor works, see \l GrueSensorReading. + + \sa GrueSensorReading +*/ + +/* + \fn GrueSensor::GrueSensor(QObject *parent) + + Construct the sensor as a child of \a parent. +*/ + +/* + \fn GrueSensor::~GrueSensor() + + Destroy the sensor. Stops the sensor if it has not already been stopped. +*/ + +/* + \fn GrueSensor::reading() const + + Returns the reading class for this sensor. + + \sa QSensor::reading() +*/ +// end generated code + +#include "moc_gruesensor.cpp" diff --git a/examples/QtSensors/QtSensors_grue/lib/gruesensor.h b/examples/QtSensors/QtSensors_grue/lib/gruesensor.h new file mode 100644 index 0000000..8088988 --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/lib/gruesensor.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** 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 GRUESENSOR_H +#define GRUESENSOR_H + +#include + +class GrueSensorReadingPrivate; + +#if defined(QT_BUILD_GRUE_LIB) +# define Q_GRUE_EXPORT Q_DECL_EXPORT +#else +# define Q_GRUE_EXPORT Q_DECL_IMPORT +#endif + +class Q_GRUE_EXPORT GrueSensorReading : public QSensorReading +{ + Q_OBJECT + Q_PROPERTY(int chanceOfBeingEaten READ chanceOfBeingEaten WRITE setChanceOfBeingEaten) + DECLARE_READING(GrueSensorReading) +public: + int chanceOfBeingEaten() const; + void setChanceOfBeingEaten(int chanceOfBeingEaten); +}; + +// begin generated code + +class Q_GRUE_EXPORT GrueFilter : public QSensorFilter +{ +public: + virtual bool filter(GrueSensorReading *reading) = 0; +private: + bool filter(QSensorReading *reading) { return filter(static_cast(reading)); } +}; + +class Q_GRUE_EXPORT GrueSensor : public QSensor +{ + Q_OBJECT +public: + explicit GrueSensor(QObject *parent = 0) : QSensor(GrueSensor::type, parent) {} + virtual ~GrueSensor() {} + GrueSensorReading *reading() const { return static_cast(QSensor::reading()); } + static char const * const type; +}; +// end generated code + +#endif diff --git a/examples/QtSensors/QtSensors_grue/lib/gruesensor_p.h b/examples/QtSensors/QtSensors_grue/lib/gruesensor_p.h new file mode 100644 index 0000000..4996e86 --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/lib/gruesensor_p.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 GRUESENSOR_P_H +#define GRUESENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +class GrueSensorReadingPrivate +{ +public: + GrueSensorReadingPrivate() + : chanceOfBeingEaten(-1) + { + } + + int chanceOfBeingEaten; +}; + +#endif diff --git a/examples/QtSensors/QtSensors_grue/lib/lib.pro b/examples/QtSensors/QtSensors_grue/lib/lib.pro new file mode 100644 index 0000000..e048e60 --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/lib/lib.pro @@ -0,0 +1,27 @@ +TEMPLATE = lib +TARGET = gruesensor + +# avoid going to release/debug subdirectory +win32:DESTDIR = $$OUT_PWD + +DEFINES *= QT_BUILD_GRUE_LIB +QT = core sensors + +HEADERS += gruesensor.h\ + gruesensor_p.h\ + +SOURCES += gruesensor.cpp\ + +target.path=$$[QT_INSTALL_LIBS] +INSTALLS += target + +MT_SYSROOT=$$(MT_SYSROOT) +!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications +!isEmpty(EXAMPLES_PREFIX) { + target.path = $$EXAMPLES_PREFIX/com.nokia.mt.grue/lib + remove_so.commands = "rm $(INSTALL_ROOT)$${target.path}/lib$${TARGET}.so" + remove_so.CONFIG = no_path + remove_so.depends = install_target + INSTALLS += remove_so +} + diff --git a/examples/QtSensors/QtSensors_grue/plugin/gruesensorimpl.cpp b/examples/QtSensors/QtSensors_grue/plugin/gruesensorimpl.cpp new file mode 100644 index 0000000..e7152a6 --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/plugin/gruesensorimpl.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** 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 "gruesensorimpl.h" +#include +#include + +char const * const gruesensorimpl::id("grue.gruesensor"); + +gruesensorimpl::gruesensorimpl(QSensor *sensor) + : QSensorBackend(sensor) + , lightLevel(QAmbientLightReading::Undefined) +{ + // We need a light sensor + lightSensor = new QAmbientLightSensor(this); + connect(lightSensor, SIGNAL(readingChanged()), this, SLOT(lightChanged())); + lightSensor->connectToBackend(); + + // We need a timer + darkTimer = new QTimer(this); + darkTimer->setInterval(1000); + connect(darkTimer, SIGNAL(timeout()), this, SLOT(increaseChance())); + + // We use this as our timestamp source + timer.start(); + +//! [setReading] + // Register our reading instance + setReading(&m_reading); +//! [setReading] + +//! [metadata] + // Supply metadata + // We can run as fast as the light sensor does + setDataRates(lightSensor); + // Only one output range, 0 to 1 in .1 increments + addOutputRange(0, 1, 0.1); + setDescription(QLatin1String("Grue Sensor")); +//! [metadata] +} + +void gruesensorimpl::start() +{ +//! [start] + lightSensor->setDataRate(sensor()->dataRate()); + lightSensor->start(); + // If the light sensor doesn't work we don't work either + if (!lightSensor->isActive()) + sensorStopped(); + if (lightSensor->isBusy()) + sensorBusy(); +//! [start] +} + +void gruesensorimpl::stop() +{ + lightSensor->stop(); +} + +void gruesensorimpl::lightChanged() +{ + if (lightLevel == lightSensor->reading()->lightLevel()) + return; + + lightLevel = lightSensor->reading()->lightLevel(); + + int chance = 0; + darkTimer->stop(); + + switch (lightSensor->reading()->lightLevel()) { + case QAmbientLightReading::Dark: + // It is dark. You are likely to be eaten by a grue. + chance = 10; + darkTimer->start(); + break; + default: + break; + } + + // Only send an update if the value has changed. + if (chance != m_reading.chanceOfBeingEaten() || m_reading.timestamp() == 0) { + m_reading.setTimestamp(timer.elapsed()); + m_reading.setChanceOfBeingEaten(chance); + newReadingAvailable(); + } +} + +void gruesensorimpl::increaseChance() +{ + // The longer you stay in the dark, the higher your chance of being eaten + int chance = m_reading.chanceOfBeingEaten() + 10; + + m_reading.setTimestamp(timer.elapsed()); + m_reading.setChanceOfBeingEaten(chance); + + newReadingAvailable(); + + // No point in using the timer anymore if we've hit 100... you can't get more + // likely to be eaten than 100% + if (chance >= 100) + darkTimer->stop(); +} + diff --git a/examples/QtSensors/QtSensors_grue/plugin/gruesensorimpl.h b/examples/QtSensors/QtSensors_grue/plugin/gruesensorimpl.h new file mode 100644 index 0000000..ed89711 --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/plugin/gruesensorimpl.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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 GRUESENSORIMPL_H +#define GRUESENSORIMPL_H + +#include +#include "gruesensor.h" +#include +#include + +QT_BEGIN_NAMESPACE +class QTimer; +QT_END_NAMESPACE + +class gruesensorimpl : public QSensorBackend +{ + Q_OBJECT +public: + static char const * const id; + + gruesensorimpl(QSensor *sensor); + + void start(); + void stop(); + +private Q_SLOTS: + void lightChanged(); + void increaseChance(); + +private: + GrueSensorReading m_reading; + QAmbientLightSensor *lightSensor; + QTimer *darkTimer; + QTime timer; + QAmbientLightReading::LightLevel lightLevel; +}; + +#endif + diff --git a/examples/QtSensors/QtSensors_grue/plugin/main.cpp b/examples/QtSensors/QtSensors_grue/plugin/main.cpp new file mode 100644 index 0000000..36aec29 --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/plugin/main.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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 "gruesensorimpl.h" +#include +#include +#include +#include +#include + +class GrueSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorChangesInterface, public QSensorBackendFactory +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "com.nokia.Qt.QSensorPluginInterface/1.0" FILE "plugin.json") + Q_INTERFACES(QSensorPluginInterface QSensorChangesInterface) +public: + void registerSensors() + { + qDebug() << "loaded the grue plugin"; + } + + void sensorsChanged() + { + if (!QSensor::defaultSensorForType(QAmbientLightSensor::type).isEmpty()) { + // There is a light sensor available. Register the backend + if (!QSensorManager::isBackendRegistered(GrueSensor::type, gruesensorimpl::id)) + QSensorManager::registerBackend(GrueSensor::type, gruesensorimpl::id, this); + } else { + if (QSensorManager::isBackendRegistered(GrueSensor::type, gruesensorimpl::id)) + QSensorManager::unregisterBackend(GrueSensor::type, gruesensorimpl::id); + } + } + + QSensorBackend *createBackend(QSensor *sensor) + { + if (sensor->identifier() == gruesensorimpl::id) + return new gruesensorimpl(sensor); + + return 0; + } +}; + +#include "main.moc" + diff --git a/examples/QtSensors/QtSensors_grue/plugin/plugin.json b/examples/QtSensors/QtSensors_grue/plugin/plugin.json new file mode 100644 index 0000000..8a55b3a --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/plugin/plugin.json @@ -0,0 +1 @@ +{ "Keys": [ "notused" ] } diff --git a/examples/QtSensors/QtSensors_grue/plugin/plugin.pro b/examples/QtSensors/QtSensors_grue/plugin/plugin.pro new file mode 100644 index 0000000..32e127f --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/plugin/plugin.pro @@ -0,0 +1,27 @@ +TEMPLATE = lib +CONFIG += plugin +TARGET = $$qtLibraryTarget(qtsensors_grue) +PLUGIN_TYPE = sensors + +QT = core sensors + +INCLUDEPATH += $$PWD/../lib +LIBS += -L$$OUT_PWD/../lib -lgruesensor + +HEADERS += gruesensorimpl.h\ + +SOURCES += gruesensorimpl.cpp\ + main.cpp\ + +target.path=$$[QT_INSTALL_PLUGINS]/sensors +INSTALLS += target + +OTHER_FILES += \ + plugin.json + +MT_SYSROOT=$$(MT_SYSROOT) +!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications +!isEmpty(EXAMPLES_PREFIX) { + target.path = $$EXAMPLES_PREFIX/com.nokia.mt.grue/plugins/sensors +} + diff --git a/examples/QtSensors/QtSensors_grue/qml.pro b/examples/QtSensors/QtSensors_grue/qml.pro new file mode 100644 index 0000000..c017dcc --- /dev/null +++ b/examples/QtSensors/QtSensors_grue/qml.pro @@ -0,0 +1,15 @@ +TEMPLATE = aux + +app.files = \ + icon.png \ + info.json \ + main.qml \ + grue.png + +MT_SYSROOT=$$(MT_SYSROOT) +!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications +!isEmpty(EXAMPLES_PREFIX) { + app.path = $$EXAMPLES_PREFIX/com.nokia.mt.grue + INSTALLS = app +} + diff --git a/examples/QtSensors/QtSensors_qmlsensorgestures/Button.qml b/examples/QtSensors/QtSensors_qmlsensorgestures/Button.qml new file mode 100644 index 0000000..23fc0f6 --- /dev/null +++ b/examples/QtSensors/QtSensors_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/QtSensors/QtSensors_qmlsensorgestures/GestureList.qml b/examples/QtSensors/QtSensors_qmlsensorgestures/GestureList.qml new file mode 100644 index 0000000..c9b1f09 --- /dev/null +++ b/examples/QtSensors/QtSensors_qmlsensorgestures/GestureList.qml @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** 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 + } +//! [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/QtSensors/QtSensors_qmlsensorgestures/GestureView.qml b/examples/QtSensors/QtSensors_qmlsensorgestures/GestureView.qml new file mode 100644 index 0000000..07a9a5c --- /dev/null +++ b/examples/QtSensors/QtSensors_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/QtSensors/QtSensors_qmlsensorgestures/GesturesView.qml b/examples/QtSensors/QtSensors_qmlsensorgestures/GesturesView.qml new file mode 100644 index 0000000..23924ca --- /dev/null +++ b/examples/QtSensors/QtSensors_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/QtSensors/QtSensors_qmlsensorgestures/QtSensors_qmlsensorgestures.pro b/examples/QtSensors/QtSensors_qmlsensorgestures/QtSensors_qmlsensorgestures.pro new file mode 100644 index 0000000..011f5f9 --- /dev/null +++ b/examples/QtSensors/QtSensors_qmlsensorgestures/QtSensors_qmlsensorgestures.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs +CONFIG += ordered + +SUBDIRS = \ + plugin \ + qml.pro diff --git a/examples/QtSensors/QtSensors_qmlsensorgestures/QtSensors_qmlsensorgestures.qml b/examples/QtSensors/QtSensors_qmlsensorgestures/QtSensors_qmlsensorgestures.qml new file mode 100644 index 0000000..2982c09 --- /dev/null +++ b/examples/QtSensors/QtSensors_qmlsensorgestures/QtSensors_qmlsensorgestures.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** 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: 480 + 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 + } +} diff --git a/examples/QtSensors/QtSensors_qmlsensorgestures/icon.png b/examples/QtSensors/QtSensors_qmlsensorgestures/icon.png new file mode 100644 index 0000000..c445bd7 Binary files /dev/null and b/examples/QtSensors/QtSensors_qmlsensorgestures/icon.png differ diff --git a/examples/QtSensors/QtSensors_qmlsensorgestures/info.json b/examples/QtSensors/QtSensors_qmlsensorgestures/info.json new file mode 100644 index 0000000..57241da --- /dev/null +++ b/examples/QtSensors/QtSensors_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/QtSensors/QtSensors_qmlsensorgestures/plugin/plugin.json b/examples/QtSensors/QtSensors_qmlsensorgestures/plugin/plugin.json new file mode 100644 index 0000000..8a55b3a --- /dev/null +++ b/examples/QtSensors/QtSensors_qmlsensorgestures/plugin/plugin.json @@ -0,0 +1 @@ +{ "Keys": [ "notused" ] } diff --git a/examples/QtSensors/QtSensors_qmlsensorgestures/plugin/plugin.pro b/examples/QtSensors/QtSensors_qmlsensorgestures/plugin/plugin.pro new file mode 100644 index 0000000..2003e91 --- /dev/null +++ b/examples/QtSensors/QtSensors_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/QtSensors/QtSensors_qmlsensorgestures/plugin/qcountergestureplugin.cpp b/examples/QtSensors/QtSensors_qmlsensorgestures/plugin/qcountergestureplugin.cpp new file mode 100644 index 0000000..1fda187 --- /dev/null +++ b/examples/QtSensors/QtSensors_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 +#include +#include + +#include "qcountergestureplugin.h" +#include +#include +#include "qcounterrecognizer.h" + + +QCounterGesturePlugin::QCounterGesturePlugin() +{ +} + +QCounterGesturePlugin::~QCounterGesturePlugin() +{ +} + +QStringList QCounterGesturePlugin::supportedIds() const +{ + QStringList list; + list << "QtSensors.SecondCounter"; + return list; +} + + +QList QCounterGesturePlugin::createRecognizers() +{ + QList recognizers; + + QSensorGestureRecognizer *sRec = new QCounterGestureRecognizer(this); + recognizers.append(sRec); + + return recognizers; +} diff --git a/examples/QtSensors/QtSensors_qmlsensorgestures/plugin/qcountergestureplugin.h b/examples/QtSensors/QtSensors_qmlsensorgestures/plugin/qcountergestureplugin.h new file mode 100644 index 0000000..4755f96 --- /dev/null +++ b/examples/QtSensors/QtSensors_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 +#include + +#include + +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 createRecognizers(); + + QStringList gestureSignals() const; + QStringList supportedIds() const; + QString name() const { return "CounterGestures"; } +}; + +#endif // QCOUNTERGESTUREPLUGIN_H diff --git a/examples/QtSensors/QtSensors_qmlsensorgestures/plugin/qcounterrecognizer.cpp b/examples/QtSensors/QtSensors_qmlsensorgestures/plugin/qcounterrecognizer.cpp new file mode 100644 index 0000000..03319e8 --- /dev/null +++ b/examples/QtSensors/QtSensors_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 +#include + +#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/QtSensors/QtSensors_qmlsensorgestures/plugin/qcounterrecognizer.h b/examples/QtSensors/QtSensors_qmlsensorgestures/plugin/qcounterrecognizer.h new file mode 100644 index 0000000..37c16eb --- /dev/null +++ b/examples/QtSensors/QtSensors_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 +#include +#include + +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/QtSensors/QtSensors_qmlsensorgestures/qml.pro b/examples/QtSensors/QtSensors_qmlsensorgestures/qml.pro new file mode 100644 index 0000000..6ad9a8b --- /dev/null +++ b/examples/QtSensors/QtSensors_qmlsensorgestures/qml.pro @@ -0,0 +1,18 @@ +TEMPLATE = aux + +app.files = \ + Button.qml \ + GestureList.qml \ + GesturesView.qml \ + info.json \ + Gesture.qml \ + GestureView.qml \ + 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/QtSensors/QtSensors_sensorgestures/QtSensors_sensorgestures.pro b/examples/QtSensors/QtSensors_sensorgestures/QtSensors_sensorgestures.pro new file mode 100644 index 0000000..295db94 --- /dev/null +++ b/examples/QtSensors/QtSensors_sensorgestures/QtSensors_sensorgestures.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +TARGET = gesture +QT += core gui sensors widgets + +SOURCES += main.cpp\ + mainwindow.cpp + +HEADERS += mainwindow.h + +FORMS += mainwindow.ui + +OTHER_FILES += \ + gesture.png diff --git a/examples/QtSensors/QtSensors_sensorgestures/gesture.png b/examples/QtSensors/QtSensors_sensorgestures/gesture.png new file mode 100644 index 0000000..707d5c4 Binary files /dev/null and b/examples/QtSensors/QtSensors_sensorgestures/gesture.png differ diff --git a/examples/QtSensors/QtSensors_sensorgestures/main.cpp b/examples/QtSensors/QtSensors_sensorgestures/main.cpp new file mode 100644 index 0000000..49594d4 --- /dev/null +++ b/examples/QtSensors/QtSensors_sensorgestures/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** 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 +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/examples/QtSensors/QtSensors_sensorgestures/mainwindow.cpp b/examples/QtSensors/QtSensors_sensorgestures/mainwindow.cpp new file mode 100644 index 0000000..9dd8a61 --- /dev/null +++ b/examples/QtSensors/QtSensors_sensorgestures/mainwindow.cpp @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** 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 +#include + +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include +#include + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + //! [0] + + QSensorGestureManager manager; + + Q_FOREACH (const QString &gesture, manager.gestureIds()) { + + QTreeWidgetItem *gestureId = new QTreeWidgetItem(ui->treeWidget); + QStringList recognizerSignals = manager.recognizerSignals(gesture); + gestureId->setText(0,gesture); + + for (int i = 0; i < recognizerSignals.count(); i++) { + QTreeWidgetItem *oneSignal = new QTreeWidgetItem(gestureId); + oneSignal->setText(0,recognizerSignals.at(i)); + } + ui->treeWidget->insertTopLevelItem(0,gestureId); + } + //! [0] + + + ui->textEdit->setReadOnly(true); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::detectedShake(const QString &name) +{ + QString str = ""+name+"
"; + ui->textEdit->insertHtml(str); + ui->textEdit->ensureCursorVisible(); +} + +void MainWindow::on_pushButton_clicked() +{ + ui->textEdit->clear(); +} + +void MainWindow::onShake() +{ + QString str = "onShake()
"; + ui->textEdit->insertHtml(str); + ui->textEdit->ensureCursorVisible(); +} + +void MainWindow::on_startPushButton_clicked() +{ + if (ui->treeWidget->currentItem() == 0) + return; + QString currentRecognizer; + + if (ui->treeWidget->currentItem()->childCount() == 0) { + currentRecognizer = ui->treeWidget->currentItem()->parent()->text(0); + } else { + currentRecognizer = ui->treeWidget->currentItem()->text(0); + } + + if (recognizerMap.contains(currentRecognizer)) + return; + //! [1] + QSensorGestureManager manager; + QSensorGesture *thisGesture = new QSensorGesture(QStringList() << currentRecognizer, this); + + if (currentRecognizer.contains("QtSensors.shake")) { + connect(thisGesture,SIGNAL(shake()), + this,SLOT(onShake())); + } + + connect(thisGesture,SIGNAL(detected(QString)), + this,SLOT(detectedShake(QString))); + thisGesture->startDetection(); + + //! [1] + + recognizerMap.insert(currentRecognizer,thisGesture); + + QString str = QString("Started %1
").arg(currentRecognizer); + ui->textEdit->insertHtml(str); + ui->textEdit->ensureCursorVisible(); +} + +void MainWindow::on_stopPushButton_clicked() +{ + if (ui->treeWidget->currentItem() == 0) + return; + QString currentRecognizer; + + if (ui->treeWidget->currentItem()->childCount() == 0) { + currentRecognizer = ui->treeWidget->currentItem()->parent()->text(0); + } else { + currentRecognizer = ui->treeWidget->currentItem()->text(0); + } + + if (!recognizerMap.contains(currentRecognizer)) + return; + //! [2] + + recognizerMap[currentRecognizer]->stopDetection(); + + if (currentRecognizer == "QtSensors.shake") { + disconnect(recognizerMap[currentRecognizer],SIGNAL(shake()), + this,SLOT(onShake())); + } + disconnect(recognizerMap[currentRecognizer],SIGNAL(detected(QString)), + this,SLOT(detectedShake(QString))); + //! [2] + + recognizerMap.take(currentRecognizer); + + QString str = QString("Stopped %1
").arg(currentRecognizer); + ui->textEdit->insertHtml(str); + ui->textEdit->ensureCursorVisible(); +} diff --git a/examples/QtSensors/QtSensors_sensorgestures/mainwindow.h b/examples/QtSensors/QtSensors_sensorgestures/mainwindow.h new file mode 100644 index 0000000..1e38f1b --- /dev/null +++ b/examples/QtSensors/QtSensors_sensorgestures/mainwindow.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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 MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +QT_BEGIN_NAMESPACE +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; + QMap recognizerMap; + +private slots: + void detectedShake(const QString&); + void onShake(); + + void on_pushButton_clicked(); + + void on_startPushButton_clicked(); + void on_stopPushButton_clicked(); +}; + + +QT_END_NAMESPACE + +#endif // MAINWINDOW_H diff --git a/examples/QtSensors/QtSensors_sensorgestures/mainwindow.ui b/examples/QtSensors/QtSensors_sensorgestures/mainwindow.ui new file mode 100644 index 0000000..baccf98 --- /dev/null +++ b/examples/QtSensors/QtSensors_sensorgestures/mainwindow.ui @@ -0,0 +1,84 @@ + + + MainWindow + + + + 0 + 0 + 423 + 474 + + + + MainWindow + + + + + + + + Gesture Recognizer Id + + + + + + + + Start + + + + + + + Stop + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"></p></body></html> + + + + + + + Clear + + + + + + + + + 0 + 0 + 423 + 22 + + + + + + TopToolBarArea + + + false + + + + + + + + diff --git a/examples/QtSensors/accel/accel.pro b/examples/QtSensors/accel/accel.pro deleted file mode 100644 index 86303ec..0000000 --- a/examples/QtSensors/accel/accel.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE=app -TARGET=accel - -QT=core sensors - -SOURCES=main.cpp - diff --git a/examples/QtSensors/accel/main.cpp b/examples/QtSensors/accel/main.cpp deleted file mode 100644 index 012c8c6..0000000 --- a/examples/QtSensors/accel/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -QAccelerometer *accelerometer; - -class AccelerometerFilter : public QAccelerometerFilter -{ -public: - bool filter(QAccelerometerReading *reading) - { - qDebug() << "acceleration: " - << QString().sprintf("%0.2f %0.2f %0.2f", - reading->x(), - reading->y(), - reading->z()); - return false; // don't store the reading in the sensor - } -}; - -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - - QAccelerometer sensor; - accelerometer = &sensor; - AccelerometerFilter filter; - sensor.addFilter(&filter); - sensor.start(); - - if (!sensor.isActive()) { - qWarning("Accelerometer didn't start!"); - return 1; - } - - return app.exec(); -} - diff --git a/examples/QtSensors/accelbubble/accelbubble.pro b/examples/QtSensors/accelbubble/accelbubble.pro deleted file mode 100644 index feeec68..0000000 --- a/examples/QtSensors/accelbubble/accelbubble.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = aux - -app.files = \ - info.json \ - main.qml \ - icon.png \ - images - -MT_SYSROOT=$$(MT_SYSROOT) -!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications -!isEmpty(EXAMPLES_PREFIX) { - app.path = $$EXAMPLES_PREFIX/com.nokia.mt.accelbubble - INSTALLS = app -} - diff --git a/examples/QtSensors/accelbubble/icon.png b/examples/QtSensors/accelbubble/icon.png deleted file mode 100644 index d74f111..0000000 Binary files a/examples/QtSensors/accelbubble/icon.png and /dev/null differ diff --git a/examples/QtSensors/accelbubble/images/Bluebubble2.png b/examples/QtSensors/accelbubble/images/Bluebubble2.png deleted file mode 100644 index f96126e..0000000 Binary files a/examples/QtSensors/accelbubble/images/Bluebubble2.png and /dev/null differ diff --git a/examples/QtSensors/accelbubble/info.json b/examples/QtSensors/accelbubble/info.json deleted file mode 100644 index 80c81bd..0000000 --- a/examples/QtSensors/accelbubble/info.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "info-version": "1.0", - "dict": { - "displayName": { - "en_US": "Accel Bubble" - }, - "identifier": "com.nokia.mt.accelbubble", - "runtime": "qml", - "main": "main.qml", - "version": "1.0.0", - "category": "application", - "subcategory": "utility" - } -} diff --git a/examples/QtSensors/accelbubble/main.qml b/examples/QtSensors/accelbubble/main.qml deleted file mode 100644 index 487ee3f..0000000 --- a/examples/QtSensors/accelbubble/main.qml +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick 2.0 -//! [0] -import QtMobility.sensors 1.2 -//! [0] - - -Rectangle { - width: 360 - height: 360 - id: mainPage - -//! [1] - Accelerometer { - id: accel -//! [1] -//! [3] - active:true -//! [3] - property real accelY; - property real accelX; - } - -//! [2] - Timer { - interval: 500; running: true; repeat: true - - property real xdiff; - property real ydiff; - - onTriggered: { - xdiff = accel.reading.x - accel.accelX; - ydiff = accel.reading.y - accel.accelY; - - if (Math.abs(xdiff) > 0.3) { - accel.accelX = -accel.reading.x - } - if (Math.abs(ydiff) > 0.3) { - accel.accelY = accel.reading.y - } - } - } -//! [2] - - Image { - id: bubble - source: "images/Bluebubble2.png" - property real centerX: parent.width / 2 - property real centerY: parent.height / 2; - property real bubbleCenter: bubble.width / 2 - - function calX() { - var newX = centerX + accel.accelX / -1 * centerX - - if ((newX - bubbleCenter) < 0) { - return 0 - } - else if ((newX + bubbleCenter) > parent.width) { - return parent.width - 2 * bubbleCenter - } - return newX - bubbleCenter; - } - x: calX(); - - function calY() { - var newY = centerY + accel.accelY / -1 * centerY - - if ((newY - bubbleCenter) < 0) { - return 0 - } - else if ((newY + bubbleCenter) > parent.height) { - return parent.height - 2 * bubbleCenter - } - return newY - bubbleCenter; - } - y: calY(); - - smooth: true - - Behavior on y { - SmoothedAnimation { - easing.type: Easing.Linear - duration: 2500 - } - } - Behavior on x { - SmoothedAnimation { - easing.type: Easing.Linear - duration: 2500 - } - } - } -} diff --git a/examples/QtSensors/cubehouse/Cube.qml b/examples/QtSensors/cubehouse/Cube.qml deleted file mode 100644 index c174b8f..0000000 --- a/examples/QtSensors/cubehouse/Cube.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick 2.0 -import Qt3D 1.0 -import Qt3D.Shapes 1.0 - -Cube { - objectName: "cube" - - transform: [ - Rotation3D { - angle: 45.0 - axis: Qt.vector3d(1, 0, 0) - }, - Rotation3D { - angle: 45.0 - axis: Qt.vector3d(0, 0, 1) - }, - Rotation3D { - id: yRT - angle: 0 - axis: Qt.vector3d(0, -1, 0) - } - ] - - SequentialAnimation { - running: true - loops: Animation.Infinite - NumberAnimation { - target: yRT - property: "angle" - from: 0 - to: 360 - duration: 1000 - } - } - - effect: Effect { - color: "#aaca00" - texture: "images/qtlogo.png" - decal: true - } -} diff --git a/examples/QtSensors/cubehouse/Cubehouse.qml b/examples/QtSensors/cubehouse/Cubehouse.qml deleted file mode 100644 index 5a1b91f..0000000 --- a/examples/QtSensors/cubehouse/Cubehouse.qml +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick 2.0 -import Qt3D 1.0 -import Qt3D.Shapes 1.0 - -//! [0] -import QtMobility.sensors 1.3 -//! [0] - -import "." - -Item { - id: mainWindow - width: 320 - height: 480 - - Viewport { - id: view - anchors.top: parent.top - width: parent.width - height: parent.height - fillColor: "darkblue" - objectName: "cube viewport" - camera: Camera { eye: Qt.vector3d(0, 3, 1.6 * room.scale - 4)} - - Room{ - id: room - scale: 7.0 - } - - function rotateY(y) - { - room.rotateY(y); - } - - function rotateX(x) - { - room.rotateX(x); - } - } - -//! [1] - Accelerometer { - id: accel - active: true - dataRate: 20 -//! [1] - -//! [2] - property double pitch: 0.0 - property double roll: 0.0 -//! [2] - -//! [3] - onReadingChanged: { - pitch = -(Math.atan2(reading.x, Math.sqrt(reading.y * reading.y + reading.z * reading.z)) * 180) / Math.PI; - roll = (Math.atan2(reading.y, Math.sqrt(reading.x * reading.x + reading.z * reading.z)) * 180) / Math.PI; - } - } -//! [3] - - - //Timer to read out the x and y rotation of the TiltSensor -//! [4] - Timer { - interval: 50; running: true; repeat: true - - onTriggered: { - view.rotateY(accel.pitch); - view.rotateX(accel.roll); - } - } -//! [4] -} diff --git a/examples/QtSensors/cubehouse/Room.qml b/examples/QtSensors/cubehouse/Room.qml deleted file mode 100644 index 43af3b1..0000000 --- a/examples/QtSensors/cubehouse/Room.qml +++ /dev/null @@ -1,288 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick 2.0 -import Qt3D 1.0 -import Qt3D.Shapes 1.0 -import "." - -Item3D{ - id: room - property double scale: 1.0 - property bool yspin: false - property bool xspin: false - property int yrot: 0 - property int xrot: 0 - property double distanceCorrection: 3.7 - - transform: [ - Rotation3D { - id: yRT - angle: 0 - axis: Qt.vector3d(0, -1, 0) - }, - Rotation3D { - id: xRT - angle: 0 - axis: Qt.vector3d(-1, 0, 0) - } - ] - - SequentialAnimation { - running: yspin - NumberAnimation { - target: yRT - property: "angle" - to: yrot - easing.type:"Linear" - duration: 50 - } - onCompleted: yspin = false - } - - SequentialAnimation { - running: xspin - NumberAnimation { - target: xRT - property: "angle" - to: xrot - easing.type:"Linear" - duration: 50 - } - onCompleted: xspin = false - } - - function rotateY(y) - { - room.yrot=y; - room.yspin = true; - } - - function rotateX(x) - { - room.xrot=x; - room.xspin = true; - } - - Quad { - id: frontWall - scale: room.scale - effect: Effect { - texture: "images/wall.jpg" - } - transform: [ - Translation3D { - translate: Qt.vector3d(0, -frontWall.scale + room.distanceCorrection, 0) - }, - Rotation3D { - angle: 90 - axis: Qt.vector3d(1, 0, 0) - }, - Rotation3D { - angle: 0 - axis: Qt.vector3d(0, 1, 0) - }, - Rotation3D { - angle: 0 - axis: Qt.vector3d(0, 0, 1) - } - ] - } - - Quad { - id: ground - scale: room.scale - effect: Effect { - texture: "images/ground.jpg" - } - transform: [ - Translation3D { - translate: Qt.vector3d(0, -ground.scale + room.distanceCorrection, 0) - }, - Rotation3D { - angle: 90 - axis: Qt.vector3d(1, 0, 0) - }, - Rotation3D { - angle: 90 - axis: Qt.vector3d(0, 1, 0) - }, - Rotation3D { - angle: 90 - axis: Qt.vector3d(0, 0, 1) - } - ] - } - - Quad { - id: leftWall - scale: room.scale - effect: Effect { - texture: "images/wall.jpg" - } - transform: [ - Translation3D { - translate: Qt.vector3d(0, -leftWall.scale + room.distanceCorrection, 0) - }, - Rotation3D { - angle: 0 - axis: Qt.vector3d(1, 0, 0) - }, - Rotation3D { - angle: 90 - axis: Qt.vector3d(0, 1, 0) - }, - Rotation3D { - angle: 90 - axis: Qt.vector3d(0, 0, 1) - } - ] - } - - Quad { - id: rightWall - scale: room.scale - effect: Effect { - texture: "images/wall.jpg" - } - transform: [ - Translation3D { - translate: Qt.vector3d(0, -rightWall.scale + room.distanceCorrection, 0) - }, - Rotation3D { - angle: 180 - axis: Qt.vector3d(1, 0, 0) - }, - Rotation3D { - angle: 90 - axis: Qt.vector3d(0, 1, 0) - }, - Rotation3D { - angle: 90 - axis: Qt.vector3d(0, 0, 1) - } - ] - } - - Quad { - id: roof - scale: room.scale - effect: Effect { - texture: "images/roof.jpg" - } - transform: [ - Translation3D { - translate: Qt.vector3d(0, -roof.scale + room.distanceCorrection, 0) - }, - Rotation3D { - angle: 90 - axis: Qt.vector3d(1, 0, 0) - }, - Rotation3D { - angle: -90 - axis: Qt.vector3d(0, 1, 0) - }, - Rotation3D { - angle: 90 - axis: Qt.vector3d(0, 0, 1) - } - ] - } - - Quad { - id: backWall - scale: room.scale - effect: Effect { - texture: "images/wall.jpg" - } - transform: [ - Translation3D { - translate: Qt.vector3d(0, -backWall.scale + room.distanceCorrection, 0) - }, - Rotation3D { - angle: -90 - axis: Qt.vector3d(1, 0, 0) - }, - Rotation3D { - angle: 0 - axis: Qt.vector3d(0, 1, 0) - }, - Rotation3D { - angle: 0 - axis: Qt.vector3d(0, 0, 1) - } - ] - } - - Cube { - id: cube - scale: 0.5 - - transform: [ - Translation3D { - translate: Qt.vector3d(0.0, 0.0, 0.0) - } - ] - } - - Table { - scale: 0.025 - transform: [ - Translation3D { - translate: Qt.vector3d(0, -7 + room.distanceCorrection, 0) - } - ] - } - - Teapot { - scale: 0.5 - - effect: Effect { - color: "#ffffaa" - decal: true - } - - transform: [ - Translation3D { - translate: Qt.vector3d(0.0, -4.50 + room.distanceCorrection, 0.0) - } - ] - } -} diff --git a/examples/QtSensors/cubehouse/Table.qml b/examples/QtSensors/cubehouse/Table.qml deleted file mode 100644 index 683d28d..0000000 --- a/examples/QtSensors/cubehouse/Table.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick 2.0 -import Qt3D 1.0 -import Qt3D.Shapes 1.0 -import "." - -Item3D { - id: table - scale: 1 - mesh: Mesh { source: "mesh/table.3ds" } -} diff --git a/examples/QtSensors/cubehouse/cubehouse.pro b/examples/QtSensors/cubehouse/cubehouse.pro deleted file mode 100644 index 075ec4e..0000000 --- a/examples/QtSensors/cubehouse/cubehouse.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = aux - -app.files = \ - Cube.qml \ - Cubehouse.qml \ - Room.qml \ - Table.qml \ - icon.png \ - images \ - info.json \ - mesh - -MT_SYSROOT=$$(MT_SYSROOT) -!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications -!isEmpty(EXAMPLES_PREFIX) { - app.path = $$EXAMPLES_PREFIX/com.nokia.mt.cubehouse - INSTALLS = app -} - diff --git a/examples/QtSensors/cubehouse/icon.png b/examples/QtSensors/cubehouse/icon.png deleted file mode 100644 index 193ad56..0000000 Binary files a/examples/QtSensors/cubehouse/icon.png and /dev/null differ diff --git a/examples/QtSensors/cubehouse/images/ground.jpg b/examples/QtSensors/cubehouse/images/ground.jpg deleted file mode 100644 index 2664b99..0000000 Binary files a/examples/QtSensors/cubehouse/images/ground.jpg and /dev/null differ diff --git a/examples/QtSensors/cubehouse/images/qtlogo.png b/examples/QtSensors/cubehouse/images/qtlogo.png deleted file mode 100644 index 7d3e97e..0000000 Binary files a/examples/QtSensors/cubehouse/images/qtlogo.png and /dev/null differ diff --git a/examples/QtSensors/cubehouse/images/roof.jpg b/examples/QtSensors/cubehouse/images/roof.jpg deleted file mode 100644 index 53a35d6..0000000 Binary files a/examples/QtSensors/cubehouse/images/roof.jpg and /dev/null differ diff --git a/examples/QtSensors/cubehouse/images/wall.jpg b/examples/QtSensors/cubehouse/images/wall.jpg deleted file mode 100644 index 7c56e23..0000000 Binary files a/examples/QtSensors/cubehouse/images/wall.jpg and /dev/null differ diff --git a/examples/QtSensors/cubehouse/info.json b/examples/QtSensors/cubehouse/info.json deleted file mode 100644 index 8d297c0..0000000 --- a/examples/QtSensors/cubehouse/info.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "info-version": "1.0", - "dict": { - "displayName": { - "en_US": "Cubehouse" - }, - "identifier": "com.nokia.mt.cubehouse", - "runtime": "qml", - "main": "Cubehouse.qml", - "version": "1.0.0", - "category": "application", - "subcategory": "utility" - } -} diff --git a/examples/QtSensors/cubehouse/mesh/table.3ds b/examples/QtSensors/cubehouse/mesh/table.3ds deleted file mode 100644 index 3e576bd..0000000 Binary files a/examples/QtSensors/cubehouse/mesh/table.3ds and /dev/null differ diff --git a/examples/QtSensors/grue/console_app/console_app.pro b/examples/QtSensors/grue/console_app/console_app.pro deleted file mode 100644 index 33d4317..0000000 --- a/examples/QtSensors/grue/console_app/console_app.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE=app -TARGET=detect_grue -CONFIG += console -QT=core sensors -SOURCES=main.cpp - diff --git a/examples/QtSensors/grue/console_app/main.cpp b/examples/QtSensors/grue/console_app/main.cpp deleted file mode 100644 index dc62e4d..0000000 --- a/examples/QtSensors/grue/console_app/main.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -class Filter : public QSensorFilter -{ - int lastPercent; -public: - Filter() - : QSensorFilter() - , lastPercent(0) - { - } - - bool filter(QSensorReading *reading) - { - int percent = reading->property("chanceOfBeingEaten").value() * 100; - if (percent == 0) { - qDebug() << "It is light. You are safe from Grues."; - } else if (lastPercent == 0) { - qDebug() << "It is dark. You are likely to be eaten by a Grue."; - } - if (percent == 100) { - qDebug() << "You have been eaten by a Grue!"; - QCoreApplication::instance()->quit(); - } else if (percent) - qDebug() << "Your chance of being eaten by a Grue:" << percent << "percent."; - lastPercent = percent; - return false; - } -}; - -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - - QSensor sensor("GrueSensor"); - - Filter filter; - sensor.addFilter(&filter); - sensor.start(); - - if (!sensor.isActive()) { - qWarning("The Grue sensor didn't start. You're on your own!"); - return 1; - } - - return app.exec(); -} - diff --git a/examples/QtSensors/grue/grue.pro b/examples/QtSensors/grue/grue.pro deleted file mode 100644 index 0405286..0000000 --- a/examples/QtSensors/grue/grue.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += lib plugin console_app -SUBDIRS += import qml_app - -plugin.depends = lib -import.depends = lib - diff --git a/examples/QtSensors/grue/import/import.pro b/examples/QtSensors/grue/import/import.pro deleted file mode 100644 index 753e1ef..0000000 --- a/examples/QtSensors/grue/import/import.pro +++ /dev/null @@ -1,33 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin - -TARGET = $$qtLibraryTarget(declarative_grue) -TARGETPATH = Grue - -QT = core gui qml sensors - -INCLUDEPATH += $$PWD/../lib -LIBS += -L$$OUT_PWD/../lib -lgruesensor - -SOURCES = main.cpp - -MT_SYSROOT=$$(MT_SYSROOT) -!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications -!isEmpty(EXAMPLES_PREFIX):DESTPATH=$$EXAMPLES_PREFIX/com.nokia.mt.grue/imports/Grue -else:DESTPATH=$$[QT_INSTALL_IMPORTS]/Grue - -target.path=$$DESTPATH -INSTALLS += target - -qmldir.files=$$PWD/qmldir -qmldir.path=$$DESTPATH -INSTALLS += qmldir - -OTHER_FILES += \ - plugin.json qmldir - -!isEmpty(EXAMPLES_PREFIX) { - QMAKE_LFLAGS += -Wl,-rpath,$$EXAMPLES_PREFIX/com.nokia.mt.grue/lib - DEFINES += "BUNDLED_PLUGIN=\\\"$$EXAMPLES_PREFIX/com.nokia.mt.grue/plugins/sensors/libqtsensors_grue.so\\\"" -} - diff --git a/examples/QtSensors/grue/import/main.cpp b/examples/QtSensors/grue/import/main.cpp deleted file mode 100644 index 6c32703..0000000 --- a/examples/QtSensors/grue/import/main.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -#include -#include - -#ifdef BUNDLED_PLUGIN -#include -#include -#endif - -QT_BEGIN_NAMESPACE - -class GrueSensorQmlImport : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json") -public: - virtual void registerTypes(const char *uri) - { - char const * const package = "Grue"; - if (QLatin1String(uri) != QLatin1String(package)) return; - int major; - int minor; - - // Register the 1.0 interfaces - major = 1; - minor = 0; - qmlRegisterType (package, major, minor, "GrueSensor"); - qmlRegisterUncreatableType(package, major, minor, "GrueSensorReading", QLatin1String("Cannot create GrueSensorReading")); - } - -#ifdef BUNDLED_PLUGIN - GrueSensorQmlImport() - { - // For now, this is getting called after Sensors has loaded - // Ensure that a change later does not break this by forcing - // sensors to load now - (void)QSensor::sensorTypes(); - - // Load the bundled sensor plugin - QPluginLoader loader(QString::fromLocal8Bit(BUNDLED_PLUGIN)); - QObject *instance = loader.instance(); - m_changes = qobject_cast(instance); - if (m_changes) { - QSensor *sensor = new QSensor(QByteArray(), this); - connect(sensor, SIGNAL(availableSensorsChanged()), this, SLOT(sensorsChanged())); - m_changes->sensorsChanged(); - } - QSensorPluginInterface *plugin = qobject_cast(instance); - if (plugin) { - plugin->registerSensors(); - } - } - -private slots: - void sensorsChanged() - { - m_changes->sensorsChanged(); - } - -private: - QSensorChangesInterface *m_changes; -#endif -}; - -QT_END_NAMESPACE - -#include "main.moc" - -/* - \qmlclass GrueSensor GrueSensor - \inherits QtMobility.sensors1::Sensor - \inqmlmodule Grue 1 - \brief The GrueSensor element reports on your chance of being eaten by a Grue. - - The GrueSensor element reports on your chance of being eaten by a Grue. - - This element wraps the GrueSensor class. Please see the documentation for - GrueSensor for details. - - \sa {QtMobility.sensors QML Limitations} -*/ - -/* - \qmlclass GrueSensorReading GrueSensorReading - \inherits QtMobility.sensors1::SensorReading - \inqmlmodule Grue 1 - \brief The GrueSensorReading element holds the most recent GrueSensor reading. - - The GrueSensorReading element holds the most recent GrueSensor reading. - - This element wraps the GrueSensorReading class. Please see the documentation for - GrueSensorReading for details. - - This element cannot be directly created. -*/ - -/* - \qmlproperty qreal Grue1::GrueSensorReading::chanceOfBeingEaten - Please see GrueSensorReading::chanceOfBeingEaten for information about this property. -*/ diff --git a/examples/QtSensors/grue/import/plugin.json b/examples/QtSensors/grue/import/plugin.json deleted file mode 100644 index 0967ef4..0000000 --- a/examples/QtSensors/grue/import/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/QtSensors/grue/import/qmldir b/examples/QtSensors/grue/import/qmldir deleted file mode 100644 index 266b7c1..0000000 --- a/examples/QtSensors/grue/import/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin declarative_grue diff --git a/examples/QtSensors/grue/lib/gruesensor.cpp b/examples/QtSensors/grue/lib/gruesensor.cpp deleted file mode 100644 index b1f00ed..0000000 --- a/examples/QtSensors/grue/lib/gruesensor.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** 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 "gruesensor.h" -#include "gruesensor_p.h" - -IMPLEMENT_READING(GrueSensorReading) - -/* - \class GrueSensorReading - - \brief The GrueSensorReading class holds readings from the Grue sensor. - - The Grue Sensor informs you of your chance of being eaten by a Grue. - - Grues love the dark so as long as your surroundings are relatively light - you are safe. However the more time you spend in the dark, the higher - your chances are of being eaten by a Grue. -*/ - -/* - \property GrueSensorReading::chanceOfBeingEaten - \brief holds your chance of being eaten. - - The value is the probability (from 0 to 100) that a Grue will eat you. - A probability of 100 means you are currently being eaten. The darker - it is, the more likely you are to be eaten by a Grue. The longer you - stay in a dark area, the more likely you are to be eaten by a Grue. - If you are in a lit room, the probability will be 0 as Grues fear light. -*/ - -int GrueSensorReading::chanceOfBeingEaten() const -{ - return d->chanceOfBeingEaten; -} - -void GrueSensorReading::setChanceOfBeingEaten(int chanceOfBeingEaten) -{ - d->chanceOfBeingEaten = chanceOfBeingEaten; -} - -// ===================================================================== - -// begin generated code - -/* - \class GrueFilter - - \brief The GrueFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to GrueSensorReading - instead of QSensorReading. -*/ - -/* - \fn GrueFilter::filter(GrueSensorReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const GrueSensor::type("GrueSensor"); - -/* - \class GrueSensor - - \brief The GrueSensor class is a convenience wrapper around QSensor. - - The only behavioural difference is that this class sets the type properly. - - This class also features a reading() function that returns a GrueSensorReading instead of a QSensorReading. - - For details about how the sensor works, see \l GrueSensorReading. - - \sa GrueSensorReading -*/ - -/* - \fn GrueSensor::GrueSensor(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/* - \fn GrueSensor::~GrueSensor() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/* - \fn GrueSensor::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ -// end generated code - -#include "moc_gruesensor.cpp" diff --git a/examples/QtSensors/grue/lib/gruesensor.h b/examples/QtSensors/grue/lib/gruesensor.h deleted file mode 100644 index 8088988..0000000 --- a/examples/QtSensors/grue/lib/gruesensor.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** 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 GRUESENSOR_H -#define GRUESENSOR_H - -#include - -class GrueSensorReadingPrivate; - -#if defined(QT_BUILD_GRUE_LIB) -# define Q_GRUE_EXPORT Q_DECL_EXPORT -#else -# define Q_GRUE_EXPORT Q_DECL_IMPORT -#endif - -class Q_GRUE_EXPORT GrueSensorReading : public QSensorReading -{ - Q_OBJECT - Q_PROPERTY(int chanceOfBeingEaten READ chanceOfBeingEaten WRITE setChanceOfBeingEaten) - DECLARE_READING(GrueSensorReading) -public: - int chanceOfBeingEaten() const; - void setChanceOfBeingEaten(int chanceOfBeingEaten); -}; - -// begin generated code - -class Q_GRUE_EXPORT GrueFilter : public QSensorFilter -{ -public: - virtual bool filter(GrueSensorReading *reading) = 0; -private: - bool filter(QSensorReading *reading) { return filter(static_cast(reading)); } -}; - -class Q_GRUE_EXPORT GrueSensor : public QSensor -{ - Q_OBJECT -public: - explicit GrueSensor(QObject *parent = 0) : QSensor(GrueSensor::type, parent) {} - virtual ~GrueSensor() {} - GrueSensorReading *reading() const { return static_cast(QSensor::reading()); } - static char const * const type; -}; -// end generated code - -#endif diff --git a/examples/QtSensors/grue/lib/gruesensor_p.h b/examples/QtSensors/grue/lib/gruesensor_p.h deleted file mode 100644 index 4996e86..0000000 --- a/examples/QtSensors/grue/lib/gruesensor_p.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** 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 GRUESENSOR_P_H -#define GRUESENSOR_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -class GrueSensorReadingPrivate -{ -public: - GrueSensorReadingPrivate() - : chanceOfBeingEaten(-1) - { - } - - int chanceOfBeingEaten; -}; - -#endif diff --git a/examples/QtSensors/grue/lib/lib.pro b/examples/QtSensors/grue/lib/lib.pro deleted file mode 100644 index e048e60..0000000 --- a/examples/QtSensors/grue/lib/lib.pro +++ /dev/null @@ -1,27 +0,0 @@ -TEMPLATE = lib -TARGET = gruesensor - -# avoid going to release/debug subdirectory -win32:DESTDIR = $$OUT_PWD - -DEFINES *= QT_BUILD_GRUE_LIB -QT = core sensors - -HEADERS += gruesensor.h\ - gruesensor_p.h\ - -SOURCES += gruesensor.cpp\ - -target.path=$$[QT_INSTALL_LIBS] -INSTALLS += target - -MT_SYSROOT=$$(MT_SYSROOT) -!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications -!isEmpty(EXAMPLES_PREFIX) { - target.path = $$EXAMPLES_PREFIX/com.nokia.mt.grue/lib - remove_so.commands = "rm $(INSTALL_ROOT)$${target.path}/lib$${TARGET}.so" - remove_so.CONFIG = no_path - remove_so.depends = install_target - INSTALLS += remove_so -} - diff --git a/examples/QtSensors/grue/plugin/gruesensorimpl.cpp b/examples/QtSensors/grue/plugin/gruesensorimpl.cpp deleted file mode 100644 index e7152a6..0000000 --- a/examples/QtSensors/grue/plugin/gruesensorimpl.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** 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 "gruesensorimpl.h" -#include -#include - -char const * const gruesensorimpl::id("grue.gruesensor"); - -gruesensorimpl::gruesensorimpl(QSensor *sensor) - : QSensorBackend(sensor) - , lightLevel(QAmbientLightReading::Undefined) -{ - // We need a light sensor - lightSensor = new QAmbientLightSensor(this); - connect(lightSensor, SIGNAL(readingChanged()), this, SLOT(lightChanged())); - lightSensor->connectToBackend(); - - // We need a timer - darkTimer = new QTimer(this); - darkTimer->setInterval(1000); - connect(darkTimer, SIGNAL(timeout()), this, SLOT(increaseChance())); - - // We use this as our timestamp source - timer.start(); - -//! [setReading] - // Register our reading instance - setReading(&m_reading); -//! [setReading] - -//! [metadata] - // Supply metadata - // We can run as fast as the light sensor does - setDataRates(lightSensor); - // Only one output range, 0 to 1 in .1 increments - addOutputRange(0, 1, 0.1); - setDescription(QLatin1String("Grue Sensor")); -//! [metadata] -} - -void gruesensorimpl::start() -{ -//! [start] - lightSensor->setDataRate(sensor()->dataRate()); - lightSensor->start(); - // If the light sensor doesn't work we don't work either - if (!lightSensor->isActive()) - sensorStopped(); - if (lightSensor->isBusy()) - sensorBusy(); -//! [start] -} - -void gruesensorimpl::stop() -{ - lightSensor->stop(); -} - -void gruesensorimpl::lightChanged() -{ - if (lightLevel == lightSensor->reading()->lightLevel()) - return; - - lightLevel = lightSensor->reading()->lightLevel(); - - int chance = 0; - darkTimer->stop(); - - switch (lightSensor->reading()->lightLevel()) { - case QAmbientLightReading::Dark: - // It is dark. You are likely to be eaten by a grue. - chance = 10; - darkTimer->start(); - break; - default: - break; - } - - // Only send an update if the value has changed. - if (chance != m_reading.chanceOfBeingEaten() || m_reading.timestamp() == 0) { - m_reading.setTimestamp(timer.elapsed()); - m_reading.setChanceOfBeingEaten(chance); - newReadingAvailable(); - } -} - -void gruesensorimpl::increaseChance() -{ - // The longer you stay in the dark, the higher your chance of being eaten - int chance = m_reading.chanceOfBeingEaten() + 10; - - m_reading.setTimestamp(timer.elapsed()); - m_reading.setChanceOfBeingEaten(chance); - - newReadingAvailable(); - - // No point in using the timer anymore if we've hit 100... you can't get more - // likely to be eaten than 100% - if (chance >= 100) - darkTimer->stop(); -} - diff --git a/examples/QtSensors/grue/plugin/gruesensorimpl.h b/examples/QtSensors/grue/plugin/gruesensorimpl.h deleted file mode 100644 index ed89711..0000000 --- a/examples/QtSensors/grue/plugin/gruesensorimpl.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** 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 GRUESENSORIMPL_H -#define GRUESENSORIMPL_H - -#include -#include "gruesensor.h" -#include -#include - -QT_BEGIN_NAMESPACE -class QTimer; -QT_END_NAMESPACE - -class gruesensorimpl : public QSensorBackend -{ - Q_OBJECT -public: - static char const * const id; - - gruesensorimpl(QSensor *sensor); - - void start(); - void stop(); - -private Q_SLOTS: - void lightChanged(); - void increaseChance(); - -private: - GrueSensorReading m_reading; - QAmbientLightSensor *lightSensor; - QTimer *darkTimer; - QTime timer; - QAmbientLightReading::LightLevel lightLevel; -}; - -#endif - diff --git a/examples/QtSensors/grue/plugin/main.cpp b/examples/QtSensors/grue/plugin/main.cpp deleted file mode 100644 index 36aec29..0000000 --- a/examples/QtSensors/grue/plugin/main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** 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 "gruesensorimpl.h" -#include -#include -#include -#include -#include - -class GrueSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorChangesInterface, public QSensorBackendFactory -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "com.nokia.Qt.QSensorPluginInterface/1.0" FILE "plugin.json") - Q_INTERFACES(QSensorPluginInterface QSensorChangesInterface) -public: - void registerSensors() - { - qDebug() << "loaded the grue plugin"; - } - - void sensorsChanged() - { - if (!QSensor::defaultSensorForType(QAmbientLightSensor::type).isEmpty()) { - // There is a light sensor available. Register the backend - if (!QSensorManager::isBackendRegistered(GrueSensor::type, gruesensorimpl::id)) - QSensorManager::registerBackend(GrueSensor::type, gruesensorimpl::id, this); - } else { - if (QSensorManager::isBackendRegistered(GrueSensor::type, gruesensorimpl::id)) - QSensorManager::unregisterBackend(GrueSensor::type, gruesensorimpl::id); - } - } - - QSensorBackend *createBackend(QSensor *sensor) - { - if (sensor->identifier() == gruesensorimpl::id) - return new gruesensorimpl(sensor); - - return 0; - } -}; - -#include "main.moc" - diff --git a/examples/QtSensors/grue/plugin/plugin.json b/examples/QtSensors/grue/plugin/plugin.json deleted file mode 100644 index 8a55b3a..0000000 --- a/examples/QtSensors/grue/plugin/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "notused" ] } diff --git a/examples/QtSensors/grue/plugin/plugin.pro b/examples/QtSensors/grue/plugin/plugin.pro deleted file mode 100644 index 32e127f..0000000 --- a/examples/QtSensors/grue/plugin/plugin.pro +++ /dev/null @@ -1,27 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin -TARGET = $$qtLibraryTarget(qtsensors_grue) -PLUGIN_TYPE = sensors - -QT = core sensors - -INCLUDEPATH += $$PWD/../lib -LIBS += -L$$OUT_PWD/../lib -lgruesensor - -HEADERS += gruesensorimpl.h\ - -SOURCES += gruesensorimpl.cpp\ - main.cpp\ - -target.path=$$[QT_INSTALL_PLUGINS]/sensors -INSTALLS += target - -OTHER_FILES += \ - plugin.json - -MT_SYSROOT=$$(MT_SYSROOT) -!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications -!isEmpty(EXAMPLES_PREFIX) { - target.path = $$EXAMPLES_PREFIX/com.nokia.mt.grue/plugins/sensors -} - diff --git a/examples/QtSensors/grue/qml_app/grue.png b/examples/QtSensors/grue/qml_app/grue.png deleted file mode 100644 index f0b070b..0000000 Binary files a/examples/QtSensors/grue/qml_app/grue.png and /dev/null differ diff --git a/examples/QtSensors/grue/qml_app/grue.xcf b/examples/QtSensors/grue/qml_app/grue.xcf deleted file mode 100644 index 2837ed7..0000000 Binary files a/examples/QtSensors/grue/qml_app/grue.xcf and /dev/null differ diff --git a/examples/QtSensors/grue/qml_app/icon.png b/examples/QtSensors/grue/qml_app/icon.png deleted file mode 100644 index f3f038c..0000000 Binary files a/examples/QtSensors/grue/qml_app/icon.png and /dev/null differ diff --git a/examples/QtSensors/grue/qml_app/icon.xcf b/examples/QtSensors/grue/qml_app/icon.xcf deleted file mode 100644 index 8416c49..0000000 Binary files a/examples/QtSensors/grue/qml_app/icon.xcf and /dev/null differ diff --git a/examples/QtSensors/grue/qml_app/info.json b/examples/QtSensors/grue/qml_app/info.json deleted file mode 100644 index 700c3eb..0000000 --- a/examples/QtSensors/grue/qml_app/info.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "info-version": "1.0", - "dict": { - "displayName": { - "en_US": "Grue Sensor" - }, - "identifier": "com.nokia.mt.grue", - "runtime": "qml", - "main": "main.qml", - "version": "1.0.0", - "category": "application", - "subcategory": "utility" - } -} diff --git a/examples/QtSensors/grue/qml_app/main.qml b/examples/QtSensors/grue/qml_app/main.qml deleted file mode 100644 index 05d267c..0000000 --- a/examples/QtSensors/grue/qml_app/main.qml +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick 2.0 -import QtMobility.sensors 1.3 -import Grue 1.0 - -Rectangle { - width: 240 - height: 320 - color: "black" - - GrueSensor { - id: sensor - active: true - onReadingChanged: { - var percent = reading.chanceOfBeingEaten; - var thetext = ""; - var theopacity = 0; - if (percent === 0) { - thetext = "It is light. You are safe from Grues."; - } - else if (percent === 100) { - thetext = "You have been eaten by a Grue!"; - sensor.active = false; - theopacity = 1; - } - else if (percent > 0) { - thetext = "It is dark. You are likely to be eaten by a Grue. " - + "Your chance of being eaten by a Grue: "+percent+" percent."; - theopacity = 0.05 + (percent * 0.001); - } - text.font.pixelSize = 30; - text.text = "

" + thetext + "

"; - grueimg.opacity = theopacity; - } - } - - Text { - id: text - anchors.top: parent.top - anchors.topMargin: 20 - anchors.left: parent.left - anchors.right: parent.right - text: "I can't tell if you're going to be eaten by a Grue or not. You're on your own!" - wrapMode: Text.WordWrap - font.pixelSize: 50 - color: "white" - } - - Image { - id: grueimg - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - source: "grue.png" - opacity: 0 - } -} diff --git a/examples/QtSensors/grue/qml_app/qml_app.pro b/examples/QtSensors/grue/qml_app/qml_app.pro deleted file mode 100644 index c017dcc..0000000 --- a/examples/QtSensors/grue/qml_app/qml_app.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = aux - -app.files = \ - icon.png \ - info.json \ - main.qml \ - grue.png - -MT_SYSROOT=$$(MT_SYSROOT) -!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications -!isEmpty(EXAMPLES_PREFIX) { - app.path = $$EXAMPLES_PREFIX/com.nokia.mt.grue - INSTALLS = app -} - diff --git a/examples/QtSensors/qmlsensorgestures/plugin/plugin.json b/examples/QtSensors/qmlsensorgestures/plugin/plugin.json deleted file mode 100644 index 8a55b3a..0000000 --- a/examples/QtSensors/qmlsensorgestures/plugin/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "notused" ] } diff --git a/examples/QtSensors/qmlsensorgestures/plugin/plugin.pro b/examples/QtSensors/qmlsensorgestures/plugin/plugin.pro deleted file mode 100644 index 2003e91..0000000 --- a/examples/QtSensors/qmlsensorgestures/plugin/plugin.pro +++ /dev/null @@ -1,21 +0,0 @@ -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/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp b/examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp deleted file mode 100644 index 1fda187..0000000 --- a/examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include - -#include "qcountergestureplugin.h" -#include -#include -#include "qcounterrecognizer.h" - - -QCounterGesturePlugin::QCounterGesturePlugin() -{ -} - -QCounterGesturePlugin::~QCounterGesturePlugin() -{ -} - -QStringList QCounterGesturePlugin::supportedIds() const -{ - QStringList list; - list << "QtSensors.SecondCounter"; - return list; -} - - -QList QCounterGesturePlugin::createRecognizers() -{ - QList recognizers; - - QSensorGestureRecognizer *sRec = new QCounterGestureRecognizer(this); - recognizers.append(sRec); - - return recognizers; -} diff --git a/examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.h b/examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.h deleted file mode 100644 index 4755f96..0000000 --- a/examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -#include - -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 createRecognizers(); - - QStringList gestureSignals() const; - QStringList supportedIds() const; - QString name() const { return "CounterGestures"; } -}; - -#endif // QCOUNTERGESTUREPLUGIN_H diff --git a/examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp b/examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp deleted file mode 100644 index 03319e8..0000000 --- a/examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -#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/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.h b/examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.h deleted file mode 100644 index 37c16eb..0000000 --- a/examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include - -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/QtSensors/qmlsensorgestures/qml_app/Button.qml b/examples/QtSensors/qmlsensorgestures/qml_app/Button.qml deleted file mode 100644 index 23fc0f6..0000000 --- a/examples/QtSensors/qmlsensorgestures/qml_app/Button.qml +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** 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/QtSensors/qmlsensorgestures/qml_app/Gesture.qml b/examples/QtSensors/qmlsensorgestures/qml_app/Gesture.qml deleted file mode 100644 index 2982c09..0000000 --- a/examples/QtSensors/qmlsensorgestures/qml_app/Gesture.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** 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: 480 - 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 - } -} diff --git a/examples/QtSensors/qmlsensorgestures/qml_app/GestureList.qml b/examples/QtSensors/qmlsensorgestures/qml_app/GestureList.qml deleted file mode 100644 index c9b1f09..0000000 --- a/examples/QtSensors/qmlsensorgestures/qml_app/GestureList.qml +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** 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 - } -//! [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/QtSensors/qmlsensorgestures/qml_app/GestureView.qml b/examples/QtSensors/qmlsensorgestures/qml_app/GestureView.qml deleted file mode 100644 index 07a9a5c..0000000 --- a/examples/QtSensors/qmlsensorgestures/qml_app/GestureView.qml +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** 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/QtSensors/qmlsensorgestures/qml_app/GesturesView.qml b/examples/QtSensors/qmlsensorgestures/qml_app/GesturesView.qml deleted file mode 100644 index 23924ca..0000000 --- a/examples/QtSensors/qmlsensorgestures/qml_app/GesturesView.qml +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** -** -** 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/QtSensors/qmlsensorgestures/qml_app/icon.png b/examples/QtSensors/qmlsensorgestures/qml_app/icon.png deleted file mode 100644 index c445bd7..0000000 Binary files a/examples/QtSensors/qmlsensorgestures/qml_app/icon.png and /dev/null differ diff --git a/examples/QtSensors/qmlsensorgestures/qml_app/info.json b/examples/QtSensors/qmlsensorgestures/qml_app/info.json deleted file mode 100644 index 02e1e0a..0000000 --- a/examples/QtSensors/qmlsensorgestures/qml_app/info.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "info-version": "1.0", - "dict": { - "displayName": { - "en_US": "Gesture" - }, - "identifier": "com.nokia.mt.qmlsensorsgesture", - "runtime": "qml", - "main": "Gesture.qml", - "version": "1.0.0", - "category": "application", - "subcategory": "utility" - } -} diff --git a/examples/QtSensors/qmlsensorgestures/qml_app/qml_app.pro b/examples/QtSensors/qmlsensorgestures/qml_app/qml_app.pro deleted file mode 100644 index 6ad9a8b..0000000 --- a/examples/QtSensors/qmlsensorgestures/qml_app/qml_app.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = aux - -app.files = \ - Button.qml \ - GestureList.qml \ - GesturesView.qml \ - info.json \ - Gesture.qml \ - GestureView.qml \ - 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/QtSensors/qmlsensorgestures/qmlsensorgestures.pro b/examples/QtSensors/qmlsensorgestures/qmlsensorgestures.pro deleted file mode 100644 index 01677c1..0000000 --- a/examples/QtSensors/qmlsensorgestures/qmlsensorgestures.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += plugin -SUBDIRS += qml_app - diff --git a/examples/QtSensors/sensorgestures/gesture.png b/examples/QtSensors/sensorgestures/gesture.png deleted file mode 100644 index 707d5c4..0000000 Binary files a/examples/QtSensors/sensorgestures/gesture.png and /dev/null differ diff --git a/examples/QtSensors/sensorgestures/main.cpp b/examples/QtSensors/sensorgestures/main.cpp deleted file mode 100644 index 49594d4..0000000 --- a/examples/QtSensors/sensorgestures/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** 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 -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/examples/QtSensors/sensorgestures/mainwindow.cpp b/examples/QtSensors/sensorgestures/mainwindow.cpp deleted file mode 100644 index 9dd8a61..0000000 --- a/examples/QtSensors/sensorgestures/mainwindow.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -#include "mainwindow.h" -#include "ui_mainwindow.h" - -#include -#include - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - //! [0] - - QSensorGestureManager manager; - - Q_FOREACH (const QString &gesture, manager.gestureIds()) { - - QTreeWidgetItem *gestureId = new QTreeWidgetItem(ui->treeWidget); - QStringList recognizerSignals = manager.recognizerSignals(gesture); - gestureId->setText(0,gesture); - - for (int i = 0; i < recognizerSignals.count(); i++) { - QTreeWidgetItem *oneSignal = new QTreeWidgetItem(gestureId); - oneSignal->setText(0,recognizerSignals.at(i)); - } - ui->treeWidget->insertTopLevelItem(0,gestureId); - } - //! [0] - - - ui->textEdit->setReadOnly(true); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::detectedShake(const QString &name) -{ - QString str = ""+name+"
"; - ui->textEdit->insertHtml(str); - ui->textEdit->ensureCursorVisible(); -} - -void MainWindow::on_pushButton_clicked() -{ - ui->textEdit->clear(); -} - -void MainWindow::onShake() -{ - QString str = "onShake()
"; - ui->textEdit->insertHtml(str); - ui->textEdit->ensureCursorVisible(); -} - -void MainWindow::on_startPushButton_clicked() -{ - if (ui->treeWidget->currentItem() == 0) - return; - QString currentRecognizer; - - if (ui->treeWidget->currentItem()->childCount() == 0) { - currentRecognizer = ui->treeWidget->currentItem()->parent()->text(0); - } else { - currentRecognizer = ui->treeWidget->currentItem()->text(0); - } - - if (recognizerMap.contains(currentRecognizer)) - return; - //! [1] - QSensorGestureManager manager; - QSensorGesture *thisGesture = new QSensorGesture(QStringList() << currentRecognizer, this); - - if (currentRecognizer.contains("QtSensors.shake")) { - connect(thisGesture,SIGNAL(shake()), - this,SLOT(onShake())); - } - - connect(thisGesture,SIGNAL(detected(QString)), - this,SLOT(detectedShake(QString))); - thisGesture->startDetection(); - - //! [1] - - recognizerMap.insert(currentRecognizer,thisGesture); - - QString str = QString("Started %1
").arg(currentRecognizer); - ui->textEdit->insertHtml(str); - ui->textEdit->ensureCursorVisible(); -} - -void MainWindow::on_stopPushButton_clicked() -{ - if (ui->treeWidget->currentItem() == 0) - return; - QString currentRecognizer; - - if (ui->treeWidget->currentItem()->childCount() == 0) { - currentRecognizer = ui->treeWidget->currentItem()->parent()->text(0); - } else { - currentRecognizer = ui->treeWidget->currentItem()->text(0); - } - - if (!recognizerMap.contains(currentRecognizer)) - return; - //! [2] - - recognizerMap[currentRecognizer]->stopDetection(); - - if (currentRecognizer == "QtSensors.shake") { - disconnect(recognizerMap[currentRecognizer],SIGNAL(shake()), - this,SLOT(onShake())); - } - disconnect(recognizerMap[currentRecognizer],SIGNAL(detected(QString)), - this,SLOT(detectedShake(QString))); - //! [2] - - recognizerMap.take(currentRecognizer); - - QString str = QString("Stopped %1
").arg(currentRecognizer); - ui->textEdit->insertHtml(str); - ui->textEdit->ensureCursorVisible(); -} diff --git a/examples/QtSensors/sensorgestures/mainwindow.h b/examples/QtSensors/sensorgestures/mainwindow.h deleted file mode 100644 index 1e38f1b..0000000 --- a/examples/QtSensors/sensorgestures/mainwindow.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** 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 MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -QT_BEGIN_NAMESPACE -namespace Ui { - class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = 0); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - QMap recognizerMap; - -private slots: - void detectedShake(const QString&); - void onShake(); - - void on_pushButton_clicked(); - - void on_startPushButton_clicked(); - void on_stopPushButton_clicked(); -}; - - -QT_END_NAMESPACE - -#endif // MAINWINDOW_H diff --git a/examples/QtSensors/sensorgestures/mainwindow.ui b/examples/QtSensors/sensorgestures/mainwindow.ui deleted file mode 100644 index baccf98..0000000 --- a/examples/QtSensors/sensorgestures/mainwindow.ui +++ /dev/null @@ -1,84 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 423 - 474 - - - - MainWindow - - - - - - - - Gesture Recognizer Id - - - - - - - - Start - - - - - - - Stop - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"></p></body></html> - - - - - - - Clear - - - - - - - - - 0 - 0 - 423 - 22 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/examples/QtSensors/sensorgestures/sensorgestures.pro b/examples/QtSensors/sensorgestures/sensorgestures.pro deleted file mode 100644 index 295db94..0000000 --- a/examples/QtSensors/sensorgestures/sensorgestures.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = app -TARGET = gesture -QT += core gui sensors widgets - -SOURCES += main.cpp\ - mainwindow.cpp - -HEADERS += mainwindow.h - -FORMS += mainwindow.ui - -OTHER_FILES += \ - gesture.png -- cgit v1.2.1