summaryrefslogtreecommitdiffstats
path: root/examples/QtSensors
diff options
context:
space:
mode:
authorWolfgang Beck <wolfgang.beck@nokia.com>2012-05-17 12:27:18 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-24 03:06:56 +0200
commit17d908ba5205513e9ed0be33aebeb3736bda0326 (patch)
treeda04213540ee61853aab6b4260721f1badd703b2 /examples/QtSensors
parent32e2d98ea438041e7e0c4df7e67053c5ee7527a7 (diff)
Unfork the examples.
Some examples were forked off and updated. Unfork by bringing these changes back (a later update will bring the other examples in line with this new style). The changes are primarily made up of file renaming. Also, JPG files have been converted to PNG. Some documentation updates have been done. Change-Id: Ib090abb5ebea2003d479d2336a23317f52b8c4d8 Reviewed-by: Lincoln Ramsay <lincoln.ramsay@nokia.com>
Diffstat (limited to 'examples/QtSensors')
-rw-r--r--examples/QtSensors/QtSensors.pro16
-rw-r--r--examples/QtSensors/QtSensors_maze/Congratulation.qml61
-rw-r--r--examples/QtSensors/QtSensors_maze/LabyrinthSquare.qml80
-rw-r--r--examples/QtSensors/QtSensors_maze/Mouse.qml116
-rw-r--r--examples/QtSensors/QtSensors_maze/QtSensors_maze.pro4
-rw-r--r--examples/QtSensors/QtSensors_maze/QtSensors_maze.qml294
-rw-r--r--examples/QtSensors/QtSensors_maze/components/ApplicationWindow.qml51
-rw-r--r--examples/QtSensors/QtSensors_maze/components/Button.qml75
-rw-r--r--examples/QtSensors/QtSensors_maze/components/images/button_background_disabled.pngbin0 -> 579 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/components/images/button_background_normal.pngbin0 -> 901 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/components/images/button_background_pressed.pngbin0 -> 334 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/00.pngbin0 -> 186 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/01.pngbin0 -> 708 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/cheese.pngbin0 -> 317 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/cheeseeating.gifbin0 -> 650 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/congratulations.gifbin0 -> 10811 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/mouse_down.gifbin0 -> 974 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/mouse_left.gifbin0 -> 970 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/mouse_leftdown.gifbin0 -> 976 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/mouse_leftup.gifbin0 -> 976 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/mouse_right.gifbin0 -> 971 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/mouse_rightdown.gifbin0 -> 977 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/mouse_rightup.gifbin0 -> 975 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/mouse_up.gifbin0 -> 970 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/content/start.pngbin0 -> 677 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/icon.pngbin0 -> 4693 bytes
-rw-r--r--examples/QtSensors/QtSensors_maze/info.json15
-rw-r--r--examples/QtSensors/QtSensors_maze/lib.js264
-rw-r--r--examples/QtSensors/QtSensors_maze/qml.pro20
-rw-r--r--examples/QtSensors/QtSensors_qmlqtsensors/QtSensors_qmlqtsensors.pro4
-rw-r--r--examples/QtSensors/QtSensors_qmlqtsensors/QtSensors_qmlqtsensors.qml493
-rw-r--r--examples/QtSensors/QtSensors_qmlqtsensors/components/ApplicationWindow.qml51
-rw-r--r--examples/QtSensors/QtSensors_qmlqtsensors/components/Button.qml75
-rw-r--r--examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_disabled.pngbin0 -> 579 bytes
-rw-r--r--examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_normal.pngbin0 -> 901 bytes
-rw-r--r--examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_pressed.pngbin0 -> 334 bytes
-rw-r--r--examples/QtSensors/QtSensors_qmlqtsensors/icon.pngbin0 -> 2122 bytes
-rw-r--r--examples/QtSensors/QtSensors_qmlqtsensors/info.json15
-rw-r--r--examples/QtSensors/QtSensors_qmlqtsensors/qml.pro15
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/PropertyList.qml130
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/QtSensors_sensor_explorer.pro6
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/QtSensors_sensor_explorer.qml196
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/SensorList.qml149
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/components/ApplicationWindow.qml51
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/components/Button.qml75
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/components/TextField.qml109
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_disabled.pngbin0 -> 579 bytes
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_normal.pngbin0 -> 901 bytes
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_pressed.pngbin0 -> 334 bytes
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/components/images/textfield_background_disabled.pngbin0 -> 936 bytes
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/components/images/textfield_background_normal.pngbin0 -> 767 bytes
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/content/listitem_select.pngbin0 -> 156 bytes
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/icon.pngbin0 -> 2205 bytes
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/import/explorer.cpp143
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/import/explorer.h79
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/import/import.pro25
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/import/main.cpp66
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/import/plugin.json1
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/import/propertyinfo.cpp140
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/import/propertyinfo.h83
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/import/qmldir1
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/import/sensoritem.cpp322
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/import/sensoritem.h96
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/info.json15
-rw-r--r--examples/QtSensors/QtSensors_sensor_explorer/qml.pro18
-rw-r--r--examples/QtSensors/QtSensors_shakeit/QtSensors_shakeit.pro3
-rw-r--r--examples/QtSensors/QtSensors_shakeit/QtSensors_shakeit.qml324
-rw-r--r--examples/QtSensors/QtSensors_shakeit/audio/loopy2a_mono.wavbin0 -> 67772 bytes
-rw-r--r--examples/QtSensors/QtSensors_shakeit/audio/phone.wavbin0 -> 22094 bytes
-rw-r--r--examples/QtSensors/QtSensors_shakeit/content/triangle.pngbin0 -> 7251 bytes
-rw-r--r--examples/QtSensors/QtSensors_shakeit/content/triangle2.pngbin0 -> 5633 bytes
-rw-r--r--examples/QtSensors/QtSensors_shakeit/content/triangle3.pngbin0 -> 5101 bytes
-rw-r--r--examples/QtSensors/QtSensors_shakeit/icon.pngbin0 -> 10695 bytes
-rw-r--r--examples/QtSensors/QtSensors_shakeit/info.json14
-rw-r--r--examples/QtSensors/QtSensors_shakeit/qml.pro16
-rw-r--r--examples/QtSensors/accel/accel.pro7
-rw-r--r--examples/QtSensors/accel/main.cpp77
-rw-r--r--examples/QtSensors/accelbubble/accelbubble.pro15
-rw-r--r--examples/QtSensors/accelbubble/icon.pngbin0 -> 2034 bytes
-rw-r--r--examples/QtSensors/accelbubble/images/Bluebubble2.pngbin0 -> 12815 bytes
-rw-r--r--examples/QtSensors/accelbubble/info.json14
-rw-r--r--examples/QtSensors/accelbubble/main.qml132
-rw-r--r--examples/QtSensors/cubehouse/Cube.qml81
-rw-r--r--examples/QtSensors/cubehouse/Cubehouse.qml113
-rw-r--r--examples/QtSensors/cubehouse/Room.qml288
-rw-r--r--examples/QtSensors/cubehouse/Table.qml50
-rw-r--r--examples/QtSensors/cubehouse/cubehouse.pro19
-rw-r--r--examples/QtSensors/cubehouse/icon.pngbin0 -> 7607 bytes
-rw-r--r--examples/QtSensors/cubehouse/images/ground.jpgbin0 -> 3077 bytes
-rw-r--r--examples/QtSensors/cubehouse/images/qtlogo.pngbin0 -> 13923 bytes
-rw-r--r--examples/QtSensors/cubehouse/images/roof.jpgbin0 -> 3866 bytes
-rw-r--r--examples/QtSensors/cubehouse/images/wall.jpgbin0 -> 6195 bytes
-rw-r--r--examples/QtSensors/cubehouse/info.json14
-rw-r--r--examples/QtSensors/cubehouse/mesh/table.3dsbin0 -> 9149 bytes
-rw-r--r--examples/QtSensors/grue/console_app/console_app.pro6
-rw-r--r--examples/QtSensors/grue/console_app/main.cpp89
-rw-r--r--examples/QtSensors/grue/grue.pro8
-rw-r--r--examples/QtSensors/grue/import/import.pro33
-rw-r--r--examples/QtSensors/grue/import/main.cpp142
-rw-r--r--examples/QtSensors/grue/import/plugin.json1
-rw-r--r--examples/QtSensors/grue/import/qmldir1
-rw-r--r--examples/QtSensors/grue/lib/gruesensor.cpp137
-rw-r--r--examples/QtSensors/grue/lib/gruesensor.h85
-rw-r--r--examples/QtSensors/grue/lib/gruesensor_p.h66
-rw-r--r--examples/QtSensors/grue/lib/lib.pro27
-rw-r--r--examples/QtSensors/grue/plugin/gruesensorimpl.cpp140
-rw-r--r--examples/QtSensors/grue/plugin/gruesensorimpl.h77
-rw-r--r--examples/QtSensors/grue/plugin/main.cpp81
-rw-r--r--examples/QtSensors/grue/plugin/plugin.json1
-rw-r--r--examples/QtSensors/grue/plugin/plugin.pro27
-rw-r--r--examples/QtSensors/grue/qml_app/grue.pngbin0 -> 11207 bytes
-rw-r--r--examples/QtSensors/grue/qml_app/grue.xcfbin0 -> 23704 bytes
-rw-r--r--examples/QtSensors/grue/qml_app/icon.pngbin0 -> 7951 bytes
-rw-r--r--examples/QtSensors/grue/qml_app/icon.xcfbin0 -> 22397 bytes
-rw-r--r--examples/QtSensors/grue/qml_app/info.json12
-rw-r--r--examples/QtSensors/grue/qml_app/main.qml95
-rw-r--r--examples/QtSensors/grue/qml_app/qml_app.pro15
-rw-r--r--examples/QtSensors/qmlsensorgestures/plugin/plugin.json1
-rw-r--r--examples/QtSensors/qmlsensorgestures/plugin/plugin.pro21
-rw-r--r--examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp75
-rw-r--r--examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.h66
-rw-r--r--examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp89
-rw-r--r--examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.h70
-rw-r--r--examples/QtSensors/qmlsensorgestures/qml_app/Button.qml129
-rw-r--r--examples/QtSensors/qmlsensorgestures/qml_app/Gesture.qml115
-rw-r--r--examples/QtSensors/qmlsensorgestures/qml_app/GestureList.qml132
-rw-r--r--examples/QtSensors/qmlsensorgestures/qml_app/GestureView.qml153
-rw-r--r--examples/QtSensors/qmlsensorgestures/qml_app/GesturesView.qml156
-rw-r--r--examples/QtSensors/qmlsensorgestures/qml_app/icon.pngbin0 -> 2298 bytes
-rw-r--r--examples/QtSensors/qmlsensorgestures/qml_app/info.json14
-rw-r--r--examples/QtSensors/qmlsensorgestures/qml_app/qml_app.pro18
-rw-r--r--examples/QtSensors/qmlsensorgestures/qmlsensorgestures.pro5
-rw-r--r--examples/QtSensors/sensorgestures/gesture.pngbin0 -> 3400 bytes
-rw-r--r--examples/QtSensors/sensorgestures/main.cpp51
-rw-r--r--examples/QtSensors/sensorgestures/mainwindow.cpp168
-rw-r--r--examples/QtSensors/sensorgestures/mainwindow.h76
-rw-r--r--examples/QtSensors/sensorgestures/mainwindow.ui84
-rw-r--r--examples/QtSensors/sensorgestures/sensorgestures.pro13
138 files changed, 7000 insertions, 0 deletions
diff --git a/examples/QtSensors/QtSensors.pro b/examples/QtSensors/QtSensors.pro
new file mode 100644
index 00000000..3e649918
--- /dev/null
+++ b/examples/QtSensors/QtSensors.pro
@@ -0,0 +1,16 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ accel \
+ accelbubble \
+ cubehouse \
+ grue \
+ qmlsensorgestures \
+ QtSensors_maze \
+ QtSensors_qmlqtsensors \
+ QtSensors_sensor_explorer \
+ QtSensors_shakeit
+
+!isEmpty(QT.widgets.name):SUBDIRS += \
+ sensorgestures
+
diff --git a/examples/QtSensors/QtSensors_maze/Congratulation.qml b/examples/QtSensors/QtSensors_maze/Congratulation.qml
new file mode 100644
index 00000000..a8d6c41c
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/Congratulation.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** 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 the javascript functions for this game
+import "lib.js" as Lib
+
+//Implementation of the Congratulation control
+Item {
+ x: Lib.cellDimension
+ y: Lib.cellDimension
+ width: Lib.cellDimension * (Lib.dimension - 2)
+ height: Lib.cellDimension * (Lib.dimension - 2)
+
+ //Containing a animated gif image
+ AnimatedImage {
+ id: img
+ anchors.fill: parent
+ visible: true
+ source: "content/congratulations.gif"
+ }
+}
diff --git a/examples/QtSensors/QtSensors_maze/LabyrinthSquare.qml b/examples/QtSensors/QtSensors_maze/LabyrinthSquare.qml
new file mode 100644
index 00000000..e5aacfcd
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/LabyrinthSquare.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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 the javascript functions for this game
+import "lib.js" as Lib
+
+//Implementation of the Labyrinth square control.
+Rectangle {
+ id: sq
+ x: 0
+ y: 0
+ width: Lib.cellDimension
+ height: Lib.cellDimension
+ color: "white"
+ property int val: 0
+ property AnimatedImage picture: img
+
+ //Dependend of its position and the labyrinth value a square can be the start, cheese, empty or a wall
+ AnimatedImage {
+ id: img
+ anchors.fill: parent
+ source: ""
+ }
+
+ function updateImage()
+ {
+ if (sq.val == -1)
+ sq.picture.source = "content/start.png";
+ else if (sq.val == 3)
+ sq.picture.source = "content/cheese.png";
+ else if (sq.val == 4){
+ sq.picture.source = "content/cheeseeating.gif";
+ sq.picture.playing = true;
+ }
+ else if (sq.val == 1)
+ sq.picture.source = "content/01.png";
+ else
+ sq.picture.source = "content/00.png";
+ }
+}
diff --git a/examples/QtSensors/QtSensors_maze/Mouse.qml b/examples/QtSensors/QtSensors_maze/Mouse.qml
new file mode 100644
index 00000000..55dac18d
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/Mouse.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//Import the declarative plugins
+import QtQuick 2.0
+
+//Import the javascript functions for this game
+import "lib.js" as Lib
+
+//Implementation of the Mouse control.
+Item {
+ id: mouse
+ x: 0
+ y: 0
+ width: Lib.cellDimension
+ height: Lib.cellDimension
+ state: 'right'
+
+ AnimatedImage {
+ id: img
+ anchors.fill: parent
+ visible: true
+ }
+
+ //for different moves we have different gif animations
+ states: [
+ State {
+ name: "up"
+ PropertyChanges { target: img; source: "content/mouse_up.gif" }
+ },
+ State {
+ name: "down"
+ PropertyChanges { target: img; source: "content/mouse_down.gif" }
+ },
+ State {
+ name: "left"
+ PropertyChanges { target: img; source: "content/mouse_left.gif" }
+ },
+ State {
+ name: "right"
+ PropertyChanges { target: img; source: "content/mouse_right.gif" }
+ },
+
+ State {
+ name: "rightup"
+ PropertyChanges { target: img; source: "content/mouse_rightup.gif" }
+ },
+ State {
+ name: "rightdown"
+ PropertyChanges { target: img; source: "content/mouse_rightdown.gif" }
+ },
+ State {
+ name: "leftup"
+ PropertyChanges { target: img; source: "content/mouse_leftup.gif" }
+ },
+ State {
+ name: "leftdown"
+ PropertyChanges { target: img; source: "content/mouse_leftdown.gif" }
+ }
+
+ ]
+
+ //Function for moving the mouse
+ function move(newx, newy)
+ {
+ var newstatus = "";
+ if (mouse.x < newx)
+ newstatus += "right";
+ else if (mouse.x > newx)
+ newstatus += "left";
+ if (mouse.y < newy)
+ newstatus += "down";
+ else if (mouse.y > newy)
+ newstatus += "up";
+ mouse.state = newstatus;
+ mouse.x = newx;
+ mouse.y = newy;
+ }
+}
diff --git a/examples/QtSensors/QtSensors_maze/QtSensors_maze.pro b/examples/QtSensors/QtSensors_maze/QtSensors_maze.pro
new file mode 100644
index 00000000..a15e39ef
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/QtSensors_maze.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS = qml.pro
+
diff --git a/examples/QtSensors/QtSensors_maze/QtSensors_maze.qml b/examples/QtSensors/QtSensors_maze/QtSensors_maze.qml
new file mode 100644
index 00000000..f52c00f2
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/QtSensors_maze.qml
@@ -0,0 +1,294 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/* Layout
+ mainWnd
+ /
+------------------------------/ gameRect
+| /
+|-----------------------------/
+||---------------------------|
+||||M| ||
+||| \ ||
+||| mouseCtrl ||
+||| ||
+||| ||
+||| Labyrinth ||
+||| ||
+||| ||
+||| cheeseSquare ||
+||| \ ||
+||| |C|||
+||---------------------------|
+|-----------------------------
+|
+|-----------------------------
+|| || |
+|-----------------------------
+| \ \
+| \ timePlayingLabel
+| newGameButton
+------------------------------
+
+*/
+//Import the declarative plugins
+import QtQuick 2.0
+import "components"
+
+//! [0]
+import QtSensors 5.0
+//! [0]
+
+//Import the javascript functions for this game
+import "lib.js" as Lib
+
+ApplicationWindow {
+ id: mainWnd
+
+ property Mouse mouseCtrl;
+ property LabyrinthSquare cheeseSquare;
+ property Congratulation congratulation;
+
+ Rectangle {
+ id: gameRect
+ x: (mainWnd.width - width) / 2
+ y: 25
+ width: Lib.dimension * Lib.cellDimension
+ height: Lib.dimension * Lib.cellDimension
+ color: "transparent"
+ border.width: 2
+
+ //timer for starting the labyrinth game
+ Timer {
+ id: startTimer
+ interval: 50; running: true; repeat: false
+ onTriggered: {
+
+ //reset game time
+ timePlayingLabel.text = "--";
+ Lib.sec = 0.0;
+ Lib.createLabyrinth();
+
+ //create labyrinth elements (only at the first time)
+ var needloadcomponent = false;
+ if (Lib.objectArray === null){
+ needloadcomponent = true;
+ Lib.objectArray = new Array(Lib.dimension * Lib.dimension);
+ }
+ var idx = 0;
+ for (var y = 0; y < Lib.dimension; y++ ){
+ for (var x = 0; x < Lib.dimension; x++ ){
+ var component = null;
+
+ //create labyrinth components (only at the first time)
+ if (needloadcomponent){
+ component = Qt.createComponent("LabyrinthSquare.qml");
+ if (component.status == Component.Ready) {
+ var square = component.createObject(parent);
+ square.x = x * square.width;
+ square.y = y * square.height;
+ square.val = Lib.labyrinth[x][y];
+ square.updateImage();
+ Lib.objectArray[idx] = square;
+ if (x == (Lib.dimension - 1) && y == (Lib.dimension - 1)){
+ cheeseSquare = square;
+ var component1 = Qt.createComponent("Congratulation.qml");
+ if (component1.status == Component.Ready) {
+ congratulation = component1.createObject(parent);
+ congratulation.visible = false;
+ }
+ }
+ }
+ }
+ else{
+ Lib.objectArray[idx].val = Lib.labyrinth[x][y];
+ Lib.objectArray[idx].updateImage();
+ if (x == (Lib.dimension - 1) && y == (Lib.dimension - 1)){
+ cheeseSquare = Lib.objectArray[idx];
+ congratulation.visible = false;
+ }
+ }
+ idx++;
+ }
+ }
+
+ //Lib.printLab(); //this is for debug. Labyrinth will be printed out in the console
+
+ //Create the mouse control (only at the first time)
+ if (mouseCtrl === null){
+ var component = Qt.createComponent("Mouse.qml");
+ if (component.status == Component.Ready) {
+ mouseCtrl = component.createObject(parent);
+ }
+ }
+ mouseCtrl.x = 0;
+ mouseCtrl.y = 0;
+ newGameButton.enabled = true;
+
+ //Start the Tilt reader timer
+ tiltTimer.running = true;
+ tiltSensor.calibrate();
+ }
+ }
+ }
+
+//! [1]
+ TiltSensor{
+ id: tiltSensor
+ unit: TiltSensor.Degrees
+ enabled: true
+ accuracy: 5.0
+ }
+//! [1]
+
+ //Timer to read out the x and y rotation of the TiltSensor
+ Timer {
+ id: tiltTimer
+ interval: 50; running: false; repeat: true
+
+//! [2]
+ onTriggered: {
+ if (!tiltSensor.enabled)
+ tiltSensor.enabled = true;
+//! [2]
+
+ if (mouseCtrl === null)
+ return;
+
+ //check if already solved
+ if (Lib.won !== true){
+ Lib.sec += 0.05;
+ timePlayingLabel.text = Math.floor(Lib.sec) + " seconds";
+
+ //check if we can move the mouse
+ var xval = -1;
+ var yval = -1;
+
+//! [3]
+ var xstep = 0;
+ if (tiltSensor.yRotation > 0)
+ xstep = 1;
+ else if (tiltSensor.yRotation < 0)
+ xstep = -1;
+ var ystep = 0;
+ if (tiltSensor.xRotation > 0)
+ ystep = 1;
+ else if (tiltSensor.xRotation < 0)
+ ystep = -1;
+//! [3]
+
+ if (xstep < 0){
+ if (mouseCtrl.x > 0){
+ if (Lib.canMove(mouseCtrl.x + xstep, mouseCtrl.y)){
+ xval = mouseCtrl.x + xstep;
+ }
+ }
+ }
+ else if (xstep > 0){
+ if (mouseCtrl.x < (Lib.cellDimension * (Lib.dimension - 1))){
+ if (Lib.canMove(mouseCtrl.x + xstep, mouseCtrl.y)){
+ xval = mouseCtrl.x + xstep;
+ }
+ }
+ }
+ if (ystep < 0){
+ if (mouseCtrl.y > 0){
+ if (Lib.canMove(mouseCtrl.x, mouseCtrl.y + ystep)){
+ yval = mouseCtrl.y + ystep;
+ }
+ }
+ }
+ else if (ystep > 0){
+ if (mouseCtrl.y < (Lib.cellDimension * (Lib.dimension - 1))){
+ if (Lib.canMove(mouseCtrl.x, mouseCtrl.y + ystep)){
+ yval = mouseCtrl.y + ystep;
+ }
+ }
+ }
+ if (xval >= 0 && yval >= 0)
+ mouseCtrl.move(xval, yval);
+
+ //move the mouse in the allwed position
+ else{
+ if (xval >= 0){
+ mouseCtrl.move(xval, mouseCtrl.y);
+ }
+ if (yval >= 0){
+ mouseCtrl.move(mouseCtrl.x, yval);
+ }
+ }
+ }
+ else{
+
+ //game won, stop the tilt meter
+ mainWnd.cheeseSquare.val = 4;
+ mainWnd.cheeseSquare.updateImage();
+ mainWnd.congratulation.visible = true;
+ newGameButton.enabled = true;
+ tiltTimer.running = false;
+ }
+ }
+ }
+
+ //Button to start a new Game
+ Button{
+ id: newGameButton
+ anchors.left: gameRect.left
+ anchors.top: gameRect.bottom
+ anchors.topMargin: 5
+ height: 30
+ width: 100
+ text: "new game"
+ enabled: false;
+ onClicked: {
+ newGameButton.enabled = false;
+ startTimer.start();
+ }
+ }
+
+ //Label to print out the game time
+ Text{
+ id: timePlayingLabel
+ anchors.right: gameRect.right
+ anchors.top: gameRect.bottom
+ anchors.topMargin: 5
+ }
+}
+
diff --git a/examples/QtSensors/QtSensors_maze/components/ApplicationWindow.qml b/examples/QtSensors/QtSensors_maze/components/ApplicationWindow.qml
new file mode 100644
index 00000000..cab5e94c
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/components/ApplicationWindow.qml
@@ -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$
+**
+****************************************************************************/
+
+//Import the declarative plugins
+import QtQuick 2.0
+
+Rectangle {
+ id: appWnd
+ x: 0
+ y: 0
+ width: 320
+ height: 480
+ color: "#ececec"
+}
diff --git a/examples/QtSensors/QtSensors_maze/components/Button.qml b/examples/QtSensors/QtSensors_maze/components/Button.qml
new file mode 100644
index 00000000..537a8bce
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/components/Button.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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: 100
+ property alias text: innerText.text
+ signal clicked
+
+ Image {
+ id: backgroundImage
+ anchors.fill: parent
+ source: (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
+ }
+
+ Text {
+ id: innerText
+ anchors.centerIn: parent
+ color: "white"
+ font.bold: true
+ }
+
+ //Mouse area to react on click events
+ MouseArea {
+ anchors.fill: button
+ onClicked: { button.clicked();}
+ onPressed: {
+ backgroundImage.source = "images/button_background_pressed.png" }
+ onReleased: {
+ backgroundImage.source = (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
+ }
+ }
+}
diff --git a/examples/QtSensors/QtSensors_maze/components/images/button_background_disabled.png b/examples/QtSensors/QtSensors_maze/components/images/button_background_disabled.png
new file mode 100644
index 00000000..62a00b9a
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/components/images/button_background_disabled.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/components/images/button_background_normal.png b/examples/QtSensors/QtSensors_maze/components/images/button_background_normal.png
new file mode 100644
index 00000000..1fecad5b
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/components/images/button_background_normal.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/components/images/button_background_pressed.png b/examples/QtSensors/QtSensors_maze/components/images/button_background_pressed.png
new file mode 100644
index 00000000..149529e1
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/components/images/button_background_pressed.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/00.png b/examples/QtSensors/QtSensors_maze/content/00.png
new file mode 100644
index 00000000..ab29a622
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/00.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/01.png b/examples/QtSensors/QtSensors_maze/content/01.png
new file mode 100644
index 00000000..0e70d1b2
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/01.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/cheese.png b/examples/QtSensors/QtSensors_maze/content/cheese.png
new file mode 100644
index 00000000..ecef4503
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/cheese.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/cheeseeating.gif b/examples/QtSensors/QtSensors_maze/content/cheeseeating.gif
new file mode 100644
index 00000000..6b2cb47f
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/cheeseeating.gif
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/congratulations.gif b/examples/QtSensors/QtSensors_maze/content/congratulations.gif
new file mode 100644
index 00000000..70204176
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/congratulations.gif
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/mouse_down.gif b/examples/QtSensors/QtSensors_maze/content/mouse_down.gif
new file mode 100644
index 00000000..5491c18f
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/mouse_down.gif
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/mouse_left.gif b/examples/QtSensors/QtSensors_maze/content/mouse_left.gif
new file mode 100644
index 00000000..265d2bab
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/mouse_left.gif
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/mouse_leftdown.gif b/examples/QtSensors/QtSensors_maze/content/mouse_leftdown.gif
new file mode 100644
index 00000000..bdcd708f
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/mouse_leftdown.gif
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/mouse_leftup.gif b/examples/QtSensors/QtSensors_maze/content/mouse_leftup.gif
new file mode 100644
index 00000000..a8b1e8f6
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/mouse_leftup.gif
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/mouse_right.gif b/examples/QtSensors/QtSensors_maze/content/mouse_right.gif
new file mode 100644
index 00000000..a95d02cc
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/mouse_right.gif
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/mouse_rightdown.gif b/examples/QtSensors/QtSensors_maze/content/mouse_rightdown.gif
new file mode 100644
index 00000000..00bc3e18
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/mouse_rightdown.gif
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/mouse_rightup.gif b/examples/QtSensors/QtSensors_maze/content/mouse_rightup.gif
new file mode 100644
index 00000000..e0153eb4
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/mouse_rightup.gif
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/mouse_up.gif b/examples/QtSensors/QtSensors_maze/content/mouse_up.gif
new file mode 100644
index 00000000..19220ebe
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/mouse_up.gif
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/content/start.png b/examples/QtSensors/QtSensors_maze/content/start.png
new file mode 100644
index 00000000..698c0b1c
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/content/start.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/icon.png b/examples/QtSensors/QtSensors_maze/icon.png
new file mode 100644
index 00000000..1e7ff8d8
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/icon.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_maze/info.json b/examples/QtSensors/QtSensors_maze/info.json
new file mode 100644
index 00000000..8e2ad1a8
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/info.json
@@ -0,0 +1,15 @@
+{
+ "info-version": "1.0",
+ "dict": {
+ "category": "application",
+ "runtime": "qml",
+ "displayName": {
+ "en_US": "Maze"
+ },
+ "subcategory": "utility",
+ "main": "QtSensors_maze.qml",
+ "version": "1.0.0",
+ "identifier": "com.nokia.mt.maze",
+ "author": "Qt"
+ }
+}
diff --git a/examples/QtSensors/QtSensors_maze/lib.js b/examples/QtSensors/QtSensors_maze/lib.js
new file mode 100644
index 00000000..fccce18f
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/lib.js
@@ -0,0 +1,264 @@
+//global variables
+var labyrinth = null;
+var dimension = 24;
+var cellDimension = 13;
+var won;
+var objectArray = null;
+var sec = 0.0
+
+//Allocate labyrinth arrays and create labyrinth and way reflected in the labyrinth array
+function createLabyrinth()
+{
+ won = false;
+ //create the labyrinth matrix
+ labyrinth = null;
+ labyrinth = new Array(dimension);
+ for (var x = 0; x < dimension; x++ ){
+ labyrinth[x] = new Array(dimension);
+ for (var y = 0; y < dimension; y++ ){
+ labyrinth[x][y] = 0;
+ }
+ }
+ createWay();
+ createLab();
+}
+
+//Create a way where the mouse can reach the cheese
+function createWay()
+{
+ //Create rnd way to have at least one solution
+ //A way square is marked as a 2 in the labyrinth array
+ var x = 0;
+ var y = 0;
+ var ox = x;
+ var oy = y;
+ labyrinth[0][0] = 2;
+ while (x < dimension && y < dimension){
+ var rnd = Math.floor(Math.random()*5);
+ if (Math.floor(Math.random()*2) == 1){
+ if (rnd == 0) x--;
+ if (rnd >= 1) x++;
+ if (x < 0) x++;
+ if (x >= dimension){
+ x = ox;
+ break;
+ }
+ }
+ else {
+ if (rnd == 0) y--;
+ if (rnd >= 1) y++;
+ if (y < 0) y++;
+ if (y >= dimension){
+ y = oy;
+ break;
+ }
+ }
+
+ /*avoid to have [2]2|
+ |2|2|*/
+ if (x < (dimension - 1) && y < (dimension - 1)){
+ if (labyrinth[x + 1][y] == 2
+ && labyrinth[x][y + 1] == 2
+ && labyrinth[x + 1][y + 1] == 2){
+ y = oy;
+ x = ox;
+ continue;
+ }
+ }
+ /*avoid to have |2[2]
+ |2|2|*/
+ if (x > 0 && y < (dimension - 1)){
+ if (labyrinth[x - 1][y] == 2
+ && labyrinth[x][y + 1] == 2
+ && labyrinth[x - 1][y + 1] == 2){
+ y = oy;
+ x = ox;
+ continue;
+ }
+ }
+ /*avoid to have |2|2|
+ [2]2|*/
+ if (x < (dimension - 1) && y > 0){
+ if (labyrinth[x + 1][y] == 2
+ && labyrinth[x][y - 1] == 2
+ && labyrinth[x + 1][y - 1] == 2){
+ y = oy;
+ x = ox;
+ continue;
+ }
+ }
+ /*avoid to have |2|2|
+ |2[2]*/
+ if (x > 0 && y > 0){
+ if (labyrinth[x - 1][y] == 2
+ && labyrinth[x][y - 1] == 2
+ && labyrinth[x - 1][y - 1] == 2){
+ y = oy;
+ x = ox;
+ continue;
+ }
+ }
+
+ labyrinth[x][y] = 2;
+ ox = x;
+ oy = y;
+ }
+ //finish way
+ while (x < (dimension - 1)){
+ labyrinth[x][y] = 2;
+ x++;
+ }
+ while (y < (dimension - 1)){
+ labyrinth[x][y] = 2;
+ y++;
+ }
+}
+
+//Create the labyrinth with rnd values
+function createLab()
+{
+ //A wall square is marked as a 1 in the labyrinth array
+ //Not a wall square is marked as a 0 in the labyrinth array
+ //The Cheese square is marked as a 3 in the labyrinth array
+ //The start is marked as a -1 in the labyrinth array
+ for (var x = 0; x < dimension; x++ ){
+ var rnd = 0;
+ for (var y = 0; y < dimension; y++){
+ //But don't overwrite the way
+ if (labyrinth[x][y] != 2){
+ var rnd = Math.floor(Math.random()*2);
+ var xy = 0;
+ var xxy = 0;
+ var xyy = 0;
+ var xxyy = 0;
+
+ if (x > 0 && y > 0){
+ xy = labyrinth[x - 1][y - 1];
+ if (xy == 2)
+ xy = 0;
+
+ xyy = labyrinth[x - 1][y];
+ if (xyy == 2)
+ xyy = 0;
+
+ xxy = labyrinth[x][y - 1];
+ if (xxy == 2)
+ xxy = 0;
+
+ xxyy = rnd;
+ if (xxyy == 2)
+ xxyy = 0;
+
+ //avoid to have to many |0|1| or |1|0| [xy ][xxy ]
+ // |1[0] |0[1] [xyy ][xxyy]
+ if (xyy == xxy && xy == xxyy && xy != xxy){
+ if (rnd == 1)
+ rnd = 0;
+ else rnd = 1;
+ }
+
+ //avoid to have to many |1|1| or |0|0|
+ // |1[1] |0[0]
+ if (xy == xxy && xxy == xxyy && xxyy == xyy){
+ if (rnd == 1)
+ rnd = 0;
+ else rnd = 1;
+ }
+ }
+ else if (x == 0 && y > 0){
+ xy = labyrinth[x][y - 1];
+ if (xy == 2)
+ xy = 0;
+
+ xyy = rnd;
+ if (xyy == 2)
+ xyy = 0;
+
+ xxy = labyrinth[x + 1][y - 1];
+ if (xxy == 2)
+ xxy = 0;
+
+ xxyy = labyrinth[x + 1][y];
+ if (xxyy == 2)
+ xxyy = 0;
+
+ //avoid to have to many |1|1| or |0|0|
+ // |1[1] |0[0]
+ if (xy == xxy && xxy == xxyy && xxyy == xyy){
+ if (rnd == 1)
+ rnd = 0;
+ else rnd = 1;
+ }
+
+ //avoid to have to many |0|1| or |1|0| [xy ][xxy ]
+ // |1[0] |0[1] [xyy ][xxyy]
+ if (xyy == xxy && xy == xxyy && xy != xxy){
+ if (rnd == 1)
+ rnd = 0;
+ else rnd = 1;
+ }
+ }
+ labyrinth[x][y] = rnd;
+ }
+
+ }
+ }
+ //set start and end
+ labyrinth[0][0] = -1;
+ labyrinth[0][1] = 0;
+ labyrinth[1][0] = 0;
+ labyrinth[1][1] = 0;
+
+ labyrinth[dimension - 2][dimension - 2] = 0;
+ labyrinth[dimension - 2][dimension - 1] = 0;
+ labyrinth[dimension - 1][dimension - 2] = 0;
+ labyrinth[dimension - 1][dimension - 1] = 3;
+}
+
+//Function that checks if the mouse can be moved in x and y
+function canMove(x, y)
+{
+ //Check if movement is allowed
+ var xcenter = x + (cellDimension / 2);
+ var ycenter = y + (cellDimension / 2);
+ //try to get the index
+ var idx = Math.floor(xcenter / cellDimension);
+ var idy = Math.floor(ycenter / cellDimension);
+ var dx = xcenter - (idx * cellDimension + ( cellDimension / 2 ));
+ var dy = ycenter - (idy * cellDimension + ( cellDimension / 2 ));
+
+ if (dx > 0){
+ if (labyrinth[idx + 1][idy] == 1)
+ return false;
+ }
+ if (dx < 0){
+ if (labyrinth[idx - 1][idy] == 1)
+ return false;
+ }
+ if (dy > 0){
+ if (labyrinth[idx][idy + 1] == 1)
+ return false;
+ }
+ if (dy < 0){
+ if (labyrinth[idx][idy - 1] == 1)
+ return false;
+ }
+ //check if won
+ if (idx == (dimension - 1) && idy == (dimension - 1))
+ won = true;
+ return true;
+}
+
+//Function that prints out the labyrith array values in the console
+function printLab()
+{
+ //for debug purposes print out lab n console
+ var iy = 0;
+ for (var y = 0; y < dimension; y++ ){
+ var line = "";
+ for (var x = 0; x < dimension; x++ ){
+ line += labyrinth[x][y];
+ }
+ console.log(line);
+ }
+}
diff --git a/examples/QtSensors/QtSensors_maze/qml.pro b/examples/QtSensors/QtSensors_maze/qml.pro
new file mode 100644
index 00000000..765b9d0d
--- /dev/null
+++ b/examples/QtSensors/QtSensors_maze/qml.pro
@@ -0,0 +1,20 @@
+TEMPLATE = aux
+
+app.files = \
+ components \
+ info.json \
+ Congratulation.qml \
+ LabyrinthSquare.qml \
+ lib.js \
+ QtSensors_maze.qml \
+ Mouse.qml \
+ icon.png \
+ content
+
+MT_SYSROOT=$$(MT_SYSROOT)
+!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications
+!isEmpty(EXAMPLES_PREFIX) {
+ app.path = $$EXAMPLES_PREFIX/com.nokia.mt.maze
+ INSTALLS = app
+}
+
diff --git a/examples/QtSensors/QtSensors_qmlqtsensors/QtSensors_qmlqtsensors.pro b/examples/QtSensors/QtSensors_qmlqtsensors/QtSensors_qmlqtsensors.pro
new file mode 100644
index 00000000..a15e39ef
--- /dev/null
+++ b/examples/QtSensors/QtSensors_qmlqtsensors/QtSensors_qmlqtsensors.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS = qml.pro
+
diff --git a/examples/QtSensors/QtSensors_qmlqtsensors/QtSensors_qmlqtsensors.qml b/examples/QtSensors/QtSensors_qmlqtsensors/QtSensors_qmlqtsensors.qml
new file mode 100644
index 00000000..44be63aa
--- /dev/null
+++ b/examples/QtSensors/QtSensors_qmlqtsensors/QtSensors_qmlqtsensors.qml
@@ -0,0 +1,493 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/* Layout
+ mainWnd
+ /
+---------------------------------------------------------------------------------
+|--------------------------------------------------------------------------------
+|| labelTitle |
+|--------------------------------------------------------------------------------
+|-------------------------------------------------------------------------------- <---- tiltLine
+|--------------------------------------------------------------------------------
+|| labelTilt |
+|--------------------------------------------------------------------------------
+| / accuracyRect / speedRect
+|-------------------------------------------||----------------------------------|
+|| Accuracy <----- textAccuracy || Speed <-----textSpeed |
+|| value <- textAccuracyValue || value <- textSpeedValue |
+|| ----------------- ------------------ || --------------- ---------------- |
+|| | accuracyLower | | accuracyHigher | || | speedLower | | speedHigher | |
+|| ----------------- ------------------ || --------------- ---------------- |
+|------------------------------------------ ||----------------------------------|
+| -----------
+| |Calibrate| <------------------ calibrate
+| -----------
+| ---------
+| |Degree | <-------------------- useRadian X Rotation: 0 <------------------ xrottext
+| ---------
+| ---------
+| |Start | <-------------------- tiltStart Y Rotation: 0 <------------------ yrottext
+| ---------
+|-------------------------------------------------------------------------------- <---- ambientlightLine
+|--------------------------------------------------------------------------------
+|| labelAmbientLight |
+|--------------------------------------------------------------------------------
+| ---------
+| |Start | <-------------------- ablStart Ambient light: - <--------------- abltext
+| ---------
+|-------------------------------------------------------------------------------- <---- proximityLine
+|--------------------------------------------------------------------------------
+|| labelProximityLight |
+|--------------------------------------------------------------------------------
+| ---------
+| |Start | <-------------------- proxiStart Proximity: - <--------------- proxitext
+| ---------
+------------------------------------------------------------------------------
+*/
+
+//Import the declarative plugins
+import QtQuick 2.0
+import "components"
+
+//! [0]
+import QtSensors 5.0
+//! [0]
+
+ApplicationWindow {
+ id: appWnd
+
+ Rectangle {
+ id: mainWnd
+ x: 0
+ y: 0
+ width: 320
+ height: 480
+ color: "transparent"
+
+ property int accuracy: 1
+ property string speed: "Slow"
+
+ Text {
+ id: labelTitle
+ anchors.top: mainWnd.top
+ anchors.topMargin: 25
+ anchors.left: mainWnd.left
+ anchors.right: mainWnd.right
+
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 30
+ font.bold: true
+ text: "QML QtSensors"
+ }
+
+ //Tile region
+
+ Rectangle {
+ id: tiltLine
+ anchors.top: labelTitle.bottom
+ anchors.topMargin: 5
+ anchors.left: mainWnd.left
+ anchors.leftMargin: 5
+ anchors.right: mainWnd.right
+ anchors.rightMargin: 5
+ border.width: 1
+ height: 1
+ border.color: "#888888"
+ }
+
+ Text {
+ id: labelTilt
+ anchors.top: tiltLine.bottom
+ anchors.topMargin: 5
+ anchors.left: mainWnd.left
+ anchors.right: mainWnd.right
+
+ horizontalAlignment: Text.AlignHCenter
+ font.bold: true
+ text: "TiltSensor"
+ }
+
+//! [1]
+ TiltSensor {
+ id: tilt
+ unit: TiltSensor.Degrees
+ enabled: false
+ accuracy: 1.0
+ speed: TiltSensor.Slow
+ }
+//! [1]
+
+ Rectangle{
+ id: accuracyRect
+ anchors.top: labelTilt.bottom
+ anchors.topMargin: 5
+ anchors.left: mainWnd.left
+ anchors.leftMargin: 5
+ anchors.right: mainWnd.right
+ anchors.rightMargin: mainWnd.width / 2
+ height: 110
+ color: "transparent"
+
+ Text{
+ id: textAccuracy
+ anchors.top: accuracyRect.top
+ anchors.left: accuracyRect.left
+ text: "Accuracy"
+ font.bold: true
+ }
+
+ Text{
+ id: textAccuracyValue
+ anchors.top: textAccuracy.bottom
+ anchors.topMargin: 5
+ anchors.left: accuracyHigher.left
+ anchors.right: accuracyHigher.right
+ text: mainWnd.accuracy
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ Button{
+ id: accuracyLower
+ anchors.top: textAccuracyValue.bottom
+ anchors.left: accuracyRect.left
+ height: 30
+ width: 40
+ text: "-"
+
+ onClicked:{
+ if (mainWnd.accuracy > 1){
+ mainWnd.accuracy--;
+ tilt.accuracy = mainWnd.accuracy;
+ }
+ }
+ }
+
+ Button{
+ id: accuracyHigher
+ anchors.top: textAccuracyValue.bottom
+ anchors.left: accuracyLower.right
+ height: 30
+ width: 40
+ text: "+"
+
+ onClicked:{
+ if (mainWnd.accuracy < 10){
+ mainWnd.accuracy++;
+ tilt.accuracy = mainWnd.accuracy;
+ }
+ }
+ }
+ }
+
+ Rectangle{
+ id: speedRect
+ anchors.top: labelTilt.bottom
+ anchors.topMargin: 5
+ anchors.left: mainWnd.left
+ anchors.leftMargin: mainWnd.width / 2
+ anchors.right: mainWnd.right
+ anchors.rightMargin: 5
+ height: 110
+ color: "transparent"
+
+ Text{
+ id: textSpeed
+ anchors.top: speedRect.top
+ anchors.left: speedRect.left
+ text: "Speed"
+ font.bold: true
+ }
+
+ Text{
+ id: textSpeedValue
+ anchors.top: textSpeed.bottom
+ anchors.topMargin: 5
+ anchors.left: speedLower.left
+ anchors.right: speedHigher.right
+ text: mainWnd.speed
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ Button{
+ id: speedLower
+ anchors.top: textSpeedValue.bottom
+ anchors.left: speedRect.left
+ height: 30
+ width: 40
+ text: "-"
+
+ onClicked:{
+ if (tilt.speed === TiltSensor.Fast) {
+ mainWnd.speed = "Medium";
+ tilt.speed = TiltSensor.Medium;
+ }
+ else if (tilt.speed === TiltSensor.Medium) {
+ mainWnd.speed = "Slow";
+ tilt.speed = TiltSensor.Slow;
+ }
+ }
+ }
+
+ Button{
+ id: speedHigher
+ anchors.top: textSpeedValue.bottom
+ anchors.left: speedLower.right
+ height: 30
+ width: 40
+ text: "+"
+
+ onClicked:{
+ if (tilt.speed === TiltSensor.Slow) {
+ mainWnd.speed = "Medium";
+ tilt.speed = TiltSensor.Medium;
+ }
+ else if (tilt.speed === TiltSensor.Medium) {
+ mainWnd.speed = "Fast";
+ tilt.speed = TiltSensor.Fast;
+ }
+ }
+ }
+ }
+
+ Button{
+ id: calibrate
+ anchors.left: mainWnd.left
+ anchors.leftMargin: 5
+ anchors.top: accuracyRect.bottom
+ height: 30
+ width: 80
+ text: "Calibrate"
+
+ onClicked:{
+ tilt.calibrate();
+ }
+ }
+
+ Button{
+ id: useRadian
+ anchors.top: calibrate.bottom
+ anchors.left: mainWnd.left
+ anchors.leftMargin: 5
+ height: 30
+ width: 80
+ text: (tilt !== null ? tilt.unit === TiltSensor.Radians ? "Degree" : "Radians" : "Degree")
+
+ onClicked:{
+ tilt.unit = (useRadian.text === "Radians" ? TiltSensor.Radians : TiltSensor.Degrees);
+ }
+ }
+
+ Button{
+ id: tiltStart
+ anchors.top: useRadian.bottom
+ anchors.left: mainWnd.left
+ anchors.leftMargin: 5
+ height: 30
+ width: 80
+ text: tilt.enabled ? "Stop" : "Start"
+
+ onClicked:{
+//! [2]
+ tilt.enabled = (tiltStart.text === "Start" ? true: false);
+//! [2]
+ }
+ }
+
+ Text {
+ id: xrottext
+ anchors.right: mainWnd.right
+ anchors.rightMargin: 5
+ anchors.left: useRadian.right
+ anchors.leftMargin: 15
+ anchors.top: useRadian.top
+ anchors.bottom: useRadian.bottom
+ verticalAlignment: Text.AlignVCenter
+//! [3]
+ text: "X Rotation: " + tilt.xRotation + (tilt.unit === TiltSensor.Radians ? " rad" : "°")
+//! [3]
+ }
+
+ Text {
+ id: yrottext
+ anchors.right: mainWnd.right
+ anchors.rightMargin: 5
+ anchors.left: tiltStart.right
+ anchors.leftMargin: 15
+ anchors.top: tiltStart.top
+ anchors.bottom: tiltStart.bottom
+ verticalAlignment: Text.AlignVCenter
+//! [4]
+ text: "Y Rotation: " + tilt.yRotation + (tilt.unit === TiltSensor.Radians ? " rad" : "°")
+//! [4]
+ }
+
+ //Ambient Light region
+
+ Rectangle {
+ id: ambientlightLine
+ anchors.top: tiltStart.bottom
+ anchors.topMargin: 5
+ anchors.left: mainWnd.left
+ anchors.leftMargin: 5
+ anchors.right: mainWnd.right
+ anchors.rightMargin: 5
+ border.width: 1
+ height: 1
+ border.color: "#888888"
+ }
+
+ Text {
+ id: labelAmbientLight
+ anchors.top: ambientlightLine.bottom
+ anchors.topMargin: 5
+ anchors.left: mainWnd.left
+ anchors.right: mainWnd.right
+
+ horizontalAlignment: Text.AlignHCenter
+ font.bold: true
+ text: "AmbientLightSensor"
+ }
+
+ AmbientLightSensor {
+ id: ambientlight
+ enabled: false
+//! [5]
+ onLightLevelChanged:{
+ if (ambientlight.lightLevel == AmbientLightSensor.Unknown)
+ ambientlighttext.text = "Ambient light: Unknown";
+ else if (ambientlight.lightLevel == AmbientLightSensor.Dark)
+ ambientlighttext.text = "Ambient light: Dark";
+ else if (ambientlight.lightLevel == AmbientLightSensor.Twilight)
+ ambientlighttext.text = "Ambient light: Twilight";
+ else if (ambientlight.lightLevel == AmbientLightSensor.Light)
+ ambientlighttext.text = "Ambient light: Light";
+ else if (ambientlight.lightLevel == AmbientLightSensor.Bright)
+ ambientlighttext.text = "Ambient light: Bright";
+ else if (ambientlight.lightLevel == AmbientLightSensor.Sunny)
+ ambientlighttext.text = "Ambient light: Sunny";
+ }
+//! [5]
+ }
+
+ Button{
+ id: ambientlightStart
+ anchors.top: labelAmbientLight.bottom
+ anchors.topMargin: 5
+ anchors.left: mainWnd.left
+ anchors.leftMargin: 5
+ height: 30
+ width: 80
+ text: ambientlight.enabled ? "Stop" : "Start"
+
+ onClicked:{
+ ambientlight.enabled = (ambientlightStart.text === "Start" ? true: false);
+ }
+ }
+
+ Text {
+ id: ambientlighttext
+ anchors.left: ambientlightStart.right
+ anchors.leftMargin: 15
+ anchors.top: ambientlightStart.top
+ anchors.bottom: ambientlightStart.bottom
+ verticalAlignment: Text.AlignVCenter
+ text: "Ambient light: -"
+ }
+
+ //Proximity region
+
+ Rectangle {
+ id: proximityLine
+ anchors.top: ambientlightStart.bottom
+ anchors.topMargin: 5
+ anchors.left: mainWnd.left
+ anchors.leftMargin: 5
+ anchors.right: mainWnd.right
+ anchors.rightMargin: 5
+ border.width: 1
+ height: 1
+ border.color: "#888888"
+ }
+
+ Text {
+ id: labelProximityLight
+ anchors.top: proximityLine.bottom
+ anchors.topMargin: 5
+ anchors.left: mainWnd.left
+ anchors.right: mainWnd.right
+ horizontalAlignment: Text.AlignHCenter
+ font.bold: true
+ text: "ProximitySensor"
+ }
+
+ ProximitySensor {
+ id: proxi
+ enabled: false
+ }
+
+ Button{
+ id: proxiStart
+ anchors.top: labelProximityLight.bottom
+ anchors.topMargin: 5
+ anchors.left: mainWnd.left
+ anchors.leftMargin: 5
+ height: 30
+ width: 80
+ text: proxi.enabled ? "Stop" : "Start"
+
+ onClicked:{
+ proxi.enabled = (proxiStart.text === "Start" ? true: false);
+ }
+ }
+
+ Text {
+ id: proxitext
+ anchors.left: proxiStart.right
+ anchors.leftMargin: 15
+ anchors.top: proxiStart.top
+ anchors.bottom: proxiStart.bottom
+ verticalAlignment: Text.AlignVCenter
+//! [6]
+ text: "Proximity: " + (proxi.near ? "near" : "far")
+//! [6]
+ }
+ }
+}
diff --git a/examples/QtSensors/QtSensors_qmlqtsensors/components/ApplicationWindow.qml b/examples/QtSensors/QtSensors_qmlqtsensors/components/ApplicationWindow.qml
new file mode 100644
index 00000000..cab5e94c
--- /dev/null
+++ b/examples/QtSensors/QtSensors_qmlqtsensors/components/ApplicationWindow.qml
@@ -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$
+**
+****************************************************************************/
+
+//Import the declarative plugins
+import QtQuick 2.0
+
+Rectangle {
+ id: appWnd
+ x: 0
+ y: 0
+ width: 320
+ height: 480
+ color: "#ececec"
+}
diff --git a/examples/QtSensors/QtSensors_qmlqtsensors/components/Button.qml b/examples/QtSensors/QtSensors_qmlqtsensors/components/Button.qml
new file mode 100644
index 00000000..537a8bce
--- /dev/null
+++ b/examples/QtSensors/QtSensors_qmlqtsensors/components/Button.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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: 100
+ property alias text: innerText.text
+ signal clicked
+
+ Image {
+ id: backgroundImage
+ anchors.fill: parent
+ source: (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
+ }
+
+ Text {
+ id: innerText
+ anchors.centerIn: parent
+ color: "white"
+ font.bold: true
+ }
+
+ //Mouse area to react on click events
+ MouseArea {
+ anchors.fill: button
+ onClicked: { button.clicked();}
+ onPressed: {
+ backgroundImage.source = "images/button_background_pressed.png" }
+ onReleased: {
+ backgroundImage.source = (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
+ }
+ }
+}
diff --git a/examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_disabled.png b/examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_disabled.png
new file mode 100644
index 00000000..62a00b9a
--- /dev/null
+++ b/examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_disabled.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_normal.png b/examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_normal.png
new file mode 100644
index 00000000..1fecad5b
--- /dev/null
+++ b/examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_normal.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_pressed.png b/examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_pressed.png
new file mode 100644
index 00000000..149529e1
--- /dev/null
+++ b/examples/QtSensors/QtSensors_qmlqtsensors/components/images/button_background_pressed.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_qmlqtsensors/icon.png b/examples/QtSensors/QtSensors_qmlqtsensors/icon.png
new file mode 100644
index 00000000..d3243c5b
--- /dev/null
+++ b/examples/QtSensors/QtSensors_qmlqtsensors/icon.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_qmlqtsensors/info.json b/examples/QtSensors/QtSensors_qmlqtsensors/info.json
new file mode 100644
index 00000000..e5484028
--- /dev/null
+++ b/examples/QtSensors/QtSensors_qmlqtsensors/info.json
@@ -0,0 +1,15 @@
+{
+ "info-version": "1.0",
+ "dict": {
+ "category": "application",
+ "runtime": "qml",
+ "displayName": {
+ "en_US": "QML QtSensors"
+ },
+ "subcategory": "utility",
+ "main": "QtSensors_qmlqtsensors.qml",
+ "version": "1.0.0",
+ "identifier": "com.nokia.mt.qmlqtsensors",
+ "author": "Qt"
+ }
+}
diff --git a/examples/QtSensors/QtSensors_qmlqtsensors/qml.pro b/examples/QtSensors/QtSensors_qmlqtsensors/qml.pro
new file mode 100644
index 00000000..e1ec8724
--- /dev/null
+++ b/examples/QtSensors/QtSensors_qmlqtsensors/qml.pro
@@ -0,0 +1,15 @@
+TEMPLATE = aux
+
+app.files = \
+ info.json \
+ QtSensors_qmlqtsensors.qml \
+ icon.png \
+ components
+
+MT_SYSROOT=$$(MT_SYSROOT)
+!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications
+!isEmpty(EXAMPLES_PREFIX) {
+ app.path = $$EXAMPLES_PREFIX/com.nokia.mt.qmlqtsensors
+ INSTALLS = app
+}
+
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/PropertyList.qml b/examples/QtSensors/QtSensors_sensor_explorer/PropertyList.qml
new file mode 100644
index 00000000..846c4cca
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/PropertyList.qml
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 Explorer 1.0
+
+Rectangle {
+ id: controlrect
+ anchors.margins: 5
+ color: "transparent"
+
+ property PropertyInfo selectedItem: null;
+ signal selectedItemChanged();
+ property alias listmodel: itemList.model
+
+ onListmodelChanged: {
+ itemList.currentIndex = -1;
+ selectedItem = null;
+ selectedItemChanged();
+ }
+
+ Rectangle {
+ id: itemListRect
+ anchors.fill: parent
+ color: "transparent"
+
+ ListView {
+ id: itemList
+ anchors.fill: itemListRect
+ anchors.leftMargin: 5
+ anchors.rightMargin: 5
+ focus: true
+ currentIndex: -1
+ delegate: itemListDelegate
+ clip: true
+
+ Rectangle {
+ id: scrollbar
+ anchors.right: itemList.right
+ y: itemList.visibleArea.yPosition * itemList.height
+ width: 2
+ height: itemList.visibleArea.heightRatio * itemList.height
+ color: "black"
+ }
+ }
+
+ Component {
+ id: itemListDelegate
+
+ Rectangle {
+ width: itemList.width
+ height: itemNameText.font.pixelSize + 3
+ color: "transparent"
+
+ Image {
+ id: backgroundImage
+ anchors.fill: parent
+ source: "content/listitem_select.png"
+ visible: itemList.currentIndex === index
+ }
+
+ Text {
+ id: itemNameText
+ text: model.modelData.name
+ font.pixelSize: 15
+ color: (itemList.currentIndex === index ? "#1c94ff" : "black")
+ }
+
+ Text {
+ id: itemValueText
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ font.pixelSize: 15
+ horizontalAlignment: Text.AlignRight
+ text: model.modelData.value
+ color: (itemList.currentIndex === index ? "#1c94ff" : "black")
+ }
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: {
+ itemList.currentIndex = index;
+ selectedItem = model.modelData;
+ selectedItemChanged();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/QtSensors_sensor_explorer.pro b/examples/QtSensors/QtSensors_sensor_explorer/QtSensors_sensor_explorer.pro
new file mode 100644
index 00000000..85ba45ef
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/QtSensors_sensor_explorer.pro
@@ -0,0 +1,6 @@
+TEMPLATE = subdirs
+CONFIG += ordered
+
+SUBDIRS = \
+ import \
+ qml.pro
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/QtSensors_sensor_explorer.qml b/examples/QtSensors/QtSensors_sensor_explorer/QtSensors_sensor_explorer.qml
new file mode 100644
index 00000000..88641604
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/QtSensors_sensor_explorer.qml
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "components"
+
+//! [0]
+import Explorer 1.0
+//! [0]
+
+ApplicationWindow {
+ id: mainWnd
+
+//! [1]
+ SensorExplorer {
+ id: explorer
+ }
+//! [1]
+
+ SensorList {
+ id: sensorList
+ anchors.top: parent.top
+ anchors.topMargin: 20
+ anchors.left: parent.left
+ anchors.right: parent.right
+ height: 170
+ title: "sensor explorer"
+
+//! [2]
+ listmodel: explorer.availableSensors
+//! [2]
+
+ onSelectedItemChanged: {
+ explorer.selectedSensorItem = sensorList.selectedItem;
+ startstopButton.text=(explorer.selectedSensorItem !== null ?
+ (explorer.selectedSensorItem.start === true ? "Stop" : "Start") : "Start")
+ if (sensorList.selectedItem !== null)
+
+//! [3]
+ propertyList.listmodel = sensorList.selectedItem.properties;
+//! [3]
+ }
+ }
+
+ Rectangle {
+ id: listSplitLine
+ anchors.top: sensorList.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.leftMargin: 5
+ anchors.rightMargin: 5
+ height: 1
+ border.width: 1
+ border.color: "#999999"
+ }
+
+ PropertyList {
+ id: propertyList
+ anchors.top: listSplitLine.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: listPropertyEndLine.top
+ anchors.bottomMargin: 5
+
+ onSelectedItemChanged: {
+ textfield.enabled = (propertyList.selectedItem === null ?
+ false : propertyList.selectedItem.isWriteable);
+ }
+ }
+
+ Rectangle {
+ id: listPropertyEndLine
+ anchors.bottom: startstopButton.top
+ anchors.bottomMargin: 5
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.leftMargin: 5
+ anchors.rightMargin: 5
+ height: 1
+ border.width: 1
+ border.color: "#999999"
+ }
+
+
+ Button {
+ id: startstopButton
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.margins: 5
+ text: (explorer.selectedSensorItem !== null ?
+ (explorer.selectedSensorItem.start === true ? "Stop" : "Start") : "Start")
+ enabled: true
+ height: 30
+ width: 80
+
+ onClicked: {
+ if (explorer.selectedSensorItem !== null) {
+//! [5]
+ if (text === "Start") {
+ explorer.selectedSensorItem.start = true;
+ text = "Stop";
+ }
+ else {
+ explorer.selectedSensorItem.start = false;
+ text = "Start";
+ }
+//! [5]
+ }
+
+ textfield.text = "";
+ }
+ }
+
+ TextField {
+ id: textfield
+ anchors.top: parent.bottom
+ anchors.topMargin: -35
+ anchors.left: startstopButton.right
+ anchors.right: parent.right
+ anchors.margins: 5
+ height: 30
+ enabled: false
+
+ onEnabledChanged: {
+ if (!textfield.enabled) {
+ textfield.closeSoftwareInputPanel();
+ textfield.anchors.top= parent.bottom;
+ textfield.anchors.topMargin= -35;
+ textfield.text = "";
+ }
+ }
+
+ onFocusChanged: {
+ if (textfield.focus) {
+ textfield.anchors.top= sensorList.bottom
+ textfield.anchors.topMargin= -15
+ }
+ else {
+ textfield.closeSoftwareInputPanel();
+ textfield.anchors.top= parent.bottom;
+ textfield.anchors.topMargin= -35;
+ }
+ }
+
+ onAccepted: {
+
+ if (explorer.selectedSensorItem !== null
+ && propertyList.selectedItem !== null) {
+//! [4]
+ explorer.selectedSensorItem.changePropertyValue(propertyList.selectedItem, textfield.text);
+//! [4]
+ propertyList.focus=true;
+ }
+ textfield.text = "";
+ }
+ }
+}
+
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/SensorList.qml b/examples/QtSensors/QtSensors_sensor_explorer/SensorList.qml
new file mode 100644
index 00000000..da157378
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/SensorList.qml
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 Explorer 1.0
+
+Rectangle {
+ id: controlrect
+ anchors.margins: 5
+ color: "transparent"
+
+ property SensorItem selectedItem: null;
+ signal selectedItemChanged();
+ property alias title: labelTitle.text
+ property alias listmodel: itemList.model
+
+ onListmodelChanged: {
+ itemList.currentIndex = -1;
+ selectedItem = null;
+ selectedItemChanged();
+ }
+
+ Text {
+ id: labelTitle
+ anchors.top: controlrect.top
+ anchors.left: controlrect.left
+ anchors.right: controlrect.right
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 30
+ font.bold: true
+ text: ""
+ }
+
+ Rectangle {
+ id: titleLine
+ anchors.top: labelTitle.bottom
+ anchors.left: controlrect.left
+ anchors.right: controlrect.right
+ height: 1
+ border.width: 1
+ border.color: "#999999"
+ }
+
+ Rectangle {
+ id: itemListRect
+ anchors.top: titleLine.bottom
+ anchors.left: controlrect.left
+ anchors.right: controlrect.right
+ anchors.bottom: controlrect.bottom
+ color: "transparent"
+
+ ListView {
+ id: itemList
+ anchors.fill: itemListRect
+ anchors.leftMargin: 5
+ anchors.rightMargin: 5
+ focus: true
+ currentIndex: -1
+ delegate: itemListDelegate
+ clip: true
+
+ Rectangle {
+ id: scrollbar
+ anchors.right: itemList.right
+ y: itemList.visibleArea.yPosition * itemList.height
+ width: 2
+ height: itemList.visibleArea.heightRatio * itemList.height
+ color: "black"
+ }
+ }
+
+ Component {
+ id: itemListDelegate
+
+ Rectangle {
+ width: itemList.width
+ height: 30
+ color: "transparent"
+
+ Image {
+ id: backgroundImage
+ anchors.fill: parent
+ source: "content/listitem_select.png"
+ visible: itemList.currentIndex === index
+ }
+
+ Text {
+ id: itemText
+ height: 30
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ text: model.modelData.id
+ color: (itemList.currentIndex === index ? "#1c94ff" : "black")
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 15
+ }
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: {
+ itemList.currentIndex = index;
+ selectedItem = model.modelData;
+ selectedItemChanged();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/components/ApplicationWindow.qml b/examples/QtSensors/QtSensors_sensor_explorer/components/ApplicationWindow.qml
new file mode 100644
index 00000000..cab5e94c
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/components/ApplicationWindow.qml
@@ -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$
+**
+****************************************************************************/
+
+//Import the declarative plugins
+import QtQuick 2.0
+
+Rectangle {
+ id: appWnd
+ x: 0
+ y: 0
+ width: 320
+ height: 480
+ color: "#ececec"
+}
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/components/Button.qml b/examples/QtSensors/QtSensors_sensor_explorer/components/Button.qml
new file mode 100644
index 00000000..537a8bce
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/components/Button.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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: 100
+ property alias text: innerText.text
+ signal clicked
+
+ Image {
+ id: backgroundImage
+ anchors.fill: parent
+ source: (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
+ }
+
+ Text {
+ id: innerText
+ anchors.centerIn: parent
+ color: "white"
+ font.bold: true
+ }
+
+ //Mouse area to react on click events
+ MouseArea {
+ anchors.fill: button
+ onClicked: { button.clicked();}
+ onPressed: {
+ backgroundImage.source = "images/button_background_pressed.png" }
+ onReleased: {
+ backgroundImage.source = (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
+ }
+ }
+}
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/components/TextField.qml b/examples/QtSensors/QtSensors_sensor_explorer/components/TextField.qml
new file mode 100644
index 00000000..c1feaf21
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/components/TextField.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** 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
+
+Item {
+ id: textInputFrame
+ property alias text: textInput.text
+ signal accepted
+
+ resources: [
+ Component{
+ id: cursorA
+ Rectangle {
+ id: cursor_rect
+ width: 2
+ height: 20
+ color: "#1c94ff"
+ visible: textInput.cursorVisible
+
+ PropertyAnimation on opacity {
+ easing.type: Easing.OutSine
+ loops: Animation.Infinite
+ from: 0
+ to: 1.0
+ duration: 750
+ }
+ }
+ }
+ ]
+
+ Image {
+ id: backgroundImage
+ anchors.fill: parent
+ source: (textInputFrame.enabled ? "images/textfield_background_normal.png" : "images/textfield_background_disabled.png")
+ }
+
+ TextInput {
+ id: textInput
+ anchors.fill: parent
+ anchors.topMargin: 5
+ anchors.leftMargin: 5
+ anchors.rightMargin: 5
+ activeFocusOnPress: false
+
+ cursorDelegate: cursorA
+
+ onEnabledChanged: {
+ textInput.focus = false;
+ }
+
+ onAccepted: {
+ textInputFrame.accepted();
+ }
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: {
+ if (!textInput.activeFocus) {
+ textInput.forceActiveFocus()
+ textInput.openSoftwareInputPanel();
+ } else {
+ textInput.focus = false;
+ }
+ }
+
+ onPressAndHold: textInput.closeSoftwareInputPanel();
+ }
+ }
+}
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_disabled.png b/examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_disabled.png
new file mode 100644
index 00000000..62a00b9a
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_disabled.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_normal.png b/examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_normal.png
new file mode 100644
index 00000000..1fecad5b
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_normal.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_pressed.png b/examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_pressed.png
new file mode 100644
index 00000000..149529e1
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/components/images/button_background_pressed.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/components/images/textfield_background_disabled.png b/examples/QtSensors/QtSensors_sensor_explorer/components/images/textfield_background_disabled.png
new file mode 100644
index 00000000..98bc601f
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/components/images/textfield_background_disabled.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/components/images/textfield_background_normal.png b/examples/QtSensors/QtSensors_sensor_explorer/components/images/textfield_background_normal.png
new file mode 100644
index 00000000..b90b50cd
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/components/images/textfield_background_normal.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/content/listitem_select.png b/examples/QtSensors/QtSensors_sensor_explorer/content/listitem_select.png
new file mode 100644
index 00000000..def234f1
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/content/listitem_select.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/icon.png b/examples/QtSensors/QtSensors_sensor_explorer/icon.png
new file mode 100644
index 00000000..c48b6095
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/icon.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/import/explorer.cpp b/examples/QtSensors/QtSensors_sensor_explorer/import/explorer.cpp
new file mode 100644
index 00000000..0c296192
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/import/explorer.cpp
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "explorer.h"
+#include <QtCore/QDebug>
+#include <qsensor.h>
+#include <QMetaObject>
+#include <QMetaProperty>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ \class QSensorExplorer
+ \brief The QSensorExplorer element provides an easy access for reading all avalaible sensors installed on the system.
+*/
+
+/*
+ Construct a QSensorExplorer object with parent \a parent
+*/
+QSensorExplorer::QSensorExplorer(QObject* parent)
+ : QObject(parent)
+ , _selectedSensorItem(0)
+{
+ loadSensors();
+}
+
+/*
+ Destructor of a QSensorExplorer
+*/
+QSensorExplorer::~QSensorExplorer()
+{
+}
+
+/*
+ Load all available sensors and store it in a list.
+*/
+void QSensorExplorer::loadSensors()
+{
+ //! [0]
+ _availableSensors.clear();
+
+ foreach (const QByteArray &type, QSensor::sensorTypes()) {
+ qDebug() << "Found type" << type;
+ foreach (const QByteArray &identifier, QSensor::sensorsForType(type)) {
+ qDebug() << "Found identifier" << identifier;
+ // Don't put in sensors we can't connect to
+ QSensor* sensor = new QSensor(type, this);
+ sensor->setIdentifier(identifier);
+ if (!sensor->connectToBackend()) {
+ qDebug() << "Couldn't connect to" << identifier;
+ continue;
+ }
+
+ qDebug() << "Adding identifier" << identifier;
+ _availableSensors.append(new QSensorItem(sensor, this));
+ }
+ }
+ emit availableSensorsChanged();
+ //! [0]
+}
+
+/*
+ \fn QSensorExplorer::availableSensorsChanged()
+ Notifies the client if the list of the available sensors was changed
+*/
+
+/*
+ \property QSensorExplorer::availableSensors
+ Returns a list of all available sensor.
+*/
+QQmlListProperty<QSensorItem> QSensorExplorer::availableSensors()
+{
+ return QQmlListProperty<QSensorItem>(this,_availableSensors);
+}
+
+/*
+ \fn QSensorExplorer::selectedSensorItemChanged()
+ Notifies the client if the selected sensor has been changed
+*/
+
+/*
+ \property QSensorExplorer::selectedSensorItem
+ Returns the current selected sensor item.
+*/
+QSensorItem* QSensorExplorer::selectedSensorItem()
+{
+ return _selectedSensorItem;
+}
+
+/*
+ \fn QSensorExplorer::setSelectedSensorItem(QSensorItem* selitem)
+ Sets the QSensorItem \a selitem as the current selected QSensorItem.
+*/
+void QSensorExplorer::setSelectedSensorItem(QSensorItem* selitem)
+{
+ if (selitem && _selectedSensorItem != selitem) {
+ if (_selectedSensorItem)
+ _selectedSensorItem->unSelect();
+ _selectedSensorItem = selitem;
+ _selectedSensorItem->select();
+ emit selectedSensorItemChanged();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/import/explorer.h b/examples/QtSensors/QtSensors_sensor_explorer/import/explorer.h
new file mode 100644
index 00000000..eaac8104
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/import/explorer.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSEONSOREXPLORER_H
+#define QSEONSOREXPLORER_H
+
+#include <QtQml/QtQml>
+#include <QtQml/QQmlListProperty>
+#include "sensoritem.h"
+
+QT_BEGIN_NAMESPACE
+
+class QSensorExplorer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<QSensorItem> availableSensors READ availableSensors NOTIFY availableSensorsChanged)
+ Q_PROPERTY(QSensorItem* selectedSensorItem READ selectedSensorItem WRITE setSelectedSensorItem NOTIFY selectedSensorItemChanged)
+public:
+ QSensorExplorer(QObject* parent = 0);
+ virtual ~QSensorExplorer();
+
+private:
+ QQmlListProperty<QSensorItem> availableSensors();
+ void loadSensors();
+ void setSelectedSensorItem(QSensorItem* selitem);
+ QSensorItem* selectedSensorItem();
+
+Q_SIGNALS:
+ void availableSensorsChanged();
+ void selectedSensorItemChanged();
+
+private:
+ QList<QSensorItem*> _availableSensors;
+ QSensorItem* _selectedSensorItem;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QSensorExplorer)
+
+#endif // QSEONSOREXPLORER_H
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/import/import.pro b/examples/QtSensors/QtSensors_sensor_explorer/import/import.pro
new file mode 100644
index 00000000..1f97b67e
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/import/import.pro
@@ -0,0 +1,25 @@
+TEMPLATE = lib
+CONFIG += plugin
+
+TARGET = $$qtLibraryTarget(declarative_explorer)
+TARGETPATH = Explorer
+
+QT += qml sensors
+
+SOURCES = main.cpp explorer.cpp sensoritem.cpp propertyinfo.cpp
+HEADERS = explorer.h sensoritem.h propertyinfo.h
+
+MT_SYSROOT=$$(MT_SYSROOT)
+!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications
+!isEmpty(EXAMPLES_PREFIX):DESTPATH=$$EXAMPLES_PREFIX/com.nokia.mt.sensor_explorer/imports/Explorer
+else:DESTPATH=$$[QT_INSTALL_IMPORTS]/Explorer
+
+target.path=$$DESTPATH
+INSTALLS += target
+
+qmldir.files=$$PWD/qmldir
+qmldir.path=$$DESTPATH
+INSTALLS += qmldir
+
+OTHER_FILES += \
+ plugin.json qmldir
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/import/main.cpp b/examples/QtSensors/QtSensors_sensor_explorer/import/main.cpp
new file mode 100644
index 00000000..80e2510d
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/import/main.cpp
@@ -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$
+**
+****************************************************************************/
+
+#include <QtQml/QQmlExtensionPlugin>
+#include <QtQml/QtQml>
+#include "explorer.h"
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+class SensorExplorerDeclarativeModule : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json")
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ qDebug() << "SensorExplorerDeclarativeModule::registerTypes(const char *uri)";
+
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("Explorer"));
+ qmlRegisterType<QSensorExplorer>(uri, 1, 0, "SensorExplorer");
+ qmlRegisterType<QSensorItem>(uri, 1, 0, "SensorItem");
+ qmlRegisterType<QPropertyInfo>(uri, 1, 0, "PropertyInfo");
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/import/plugin.json b/examples/QtSensors/QtSensors_sensor_explorer/import/plugin.json
new file mode 100644
index 00000000..0967ef42
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/import/plugin.json
@@ -0,0 +1 @@
+{}
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/import/propertyinfo.cpp b/examples/QtSensors/QtSensors_sensor_explorer/import/propertyinfo.cpp
new file mode 100644
index 00000000..0360e0d2
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/import/propertyinfo.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensoritem.h"
+#include <QtCore/QDebug>
+#include <QtSensors>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ \class QPropertyInfo
+ \brief The QPropertyInfo element provides an easy access for reading and writing the property values.
+*/
+
+/*
+ Construct a QPropertyInfo object with parent \a parent
+*/
+QPropertyInfo::QPropertyInfo(QObject* parent)
+ : QObject(parent)
+ , _index(0)
+ , _isWriteable(false)
+ , _name("")
+ , _typeName("")
+ , _value("")
+{}
+
+/*
+ Construct a QPropertyInfo object with parent \a parent, property name \a name, property index \a index,
+ property write access \a writeable, property type \a typeName and property value \a value
+*/
+QPropertyInfo::QPropertyInfo(const QString& name, int index, bool writeable, const QString& typeName, const QString& value, QObject* parent)
+ : QObject(parent)
+ , _index(index)
+ , _isWriteable(writeable)
+ , _name(name)
+ , _typeName(typeName)
+ , _value(value)
+{}
+
+/*
+ \property QPropertyInfo::name
+ Returns the name of the property
+*/
+QString QPropertyInfo::name()
+{
+ return _name;
+}
+
+/*
+ \property QPropertyInfo::typeName
+ Returns the type of the property
+*/
+QString QPropertyInfo::typeName()
+{
+ return _typeName;
+}
+
+/*
+ \property QPropertyInfo::value
+ Returns the current value of the property
+*/
+QString QPropertyInfo::value()
+{
+ return _value;
+}
+
+/*
+ \fn void QPropertyInfo::valueChanged()
+ Signal that notifies the client if the property value was changed.
+*/
+
+/*
+ \fn QPropertyInfo::setValue(const QString& value)
+ Sets the value \a value of the property
+*/
+void QPropertyInfo::setValue(const QString& value)
+{
+ if (value != _value){
+ _value = value;
+ emit valueChanged();
+ }
+}
+
+/*
+ \fn QPropertyInfo::index()
+ Returns the meta-data index of the property
+*/
+int QPropertyInfo::index()
+{
+ return _index;
+}
+
+/*
+ \property QPropertyInfo::isWriteable
+ Returns true if the property is writeable false if property is read only
+*/
+bool QPropertyInfo::isWriteable()
+{
+ return _isWriteable;
+}
+
+QT_END_NAMESPACE
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/import/propertyinfo.h b/examples/QtSensors/QtSensors_sensor_explorer/import/propertyinfo.h
new file mode 100644
index 00000000..b3ebe4c0
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/import/propertyinfo.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPROPERTYINFO_H
+#define QPROPERTYINFO_H
+
+#include <QtQml/QtQml>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+class QPropertyInfo : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name CONSTANT)
+ Q_PROPERTY(QString typeName READ typeName CONSTANT)
+ Q_PROPERTY(QString value READ value NOTIFY valueChanged)
+ Q_PROPERTY(bool isWriteable READ isWriteable CONSTANT)
+
+public:
+ QPropertyInfo(QObject* parent = 0);
+ QPropertyInfo(const QString& name, int index, bool writeable, const QString& typeName, const QString& value, QObject* parent=0);
+ QString name();
+ QString typeName();
+ QString value();
+ void setValue(const QString& value);
+ int index();
+ bool isWriteable();
+
+Q_SIGNALS:
+ void valueChanged();
+
+private:
+ int _index;
+ bool _isWriteable;
+ QString _name;
+ QString _typeName;
+ QString _value;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QPropertyInfo)
+
+#endif // QPROPERTYINFO_H
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/import/qmldir b/examples/QtSensors/QtSensors_sensor_explorer/import/qmldir
new file mode 100644
index 00000000..60d8f883
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/import/qmldir
@@ -0,0 +1 @@
+plugin declarative_explorer
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/import/sensoritem.cpp b/examples/QtSensors/QtSensors_sensor_explorer/import/sensoritem.cpp
new file mode 100644
index 00000000..68dccf46
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/import/sensoritem.cpp
@@ -0,0 +1,322 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sensoritem.h"
+#include <QtCore/QDebug>
+#include <QtSensors>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ \class QSensorItem
+ \brief The QSensorItem element provides information about the meta-datas from a sensors installed on the system.
+*/
+
+/*
+ Construct a QSensorItem object with parent \a parent
+*/
+QSensorItem::QSensorItem(QObject* parent)
+ : QObject(parent)
+ , _qsensor(0)
+{
+}
+
+/*
+ Construct a QSensorItem object with QSensor \a sensor and parent \a parent
+*/
+QSensorItem::QSensorItem(QSensor* sensor, QObject* parent)
+ : QObject(parent)
+ , _qsensor(sensor)
+{
+}
+
+/*
+ Destructor of a QSensorItem
+*/
+QSensorItem::~QSensorItem()
+{
+}
+
+/*
+ \fn QSensorItem::startChanged()
+ Notifies the client if the sensors has changed its start active status
+*/
+
+/*
+ \property QSensorItem::start
+ This property starts or stops the sensor
+*/
+bool QSensorItem::start()
+{
+ return (_qsensor ? _qsensor->isActive() : false);
+}
+
+void QSensorItem::setStart(bool run)
+{
+ if (_qsensor)
+ _qsensor->setActive(run);
+}
+
+/*
+ \property QSensorItem::id
+ Returns the sensor id of the sensor item
+*/
+QString QSensorItem::id()
+{
+ return (_qsensor ? _qsensor->identifier() : "");
+}
+
+/*
+ Set the new value \a val to the QPropertyInfo object \a property
+*/
+void QSensorItem::changePropertyValue(QPropertyInfo* property, const QString& val)
+{
+ if (_qsensor && _sensorProperties.contains(property)){
+ if ( _qsensor->setProperty(property->name().toLatin1().constData(), QVariant(val)))
+ updateSensorPropertyValues();
+ else
+ qWarning() << "new property value couldn't be set";
+ }
+}
+
+/*
+ Reading the meta-datas and activates the sensor.
+*/
+void QSensorItem::select()
+{
+ if (_sensorProperties.isEmpty()) {
+ // Probe the reading using Qt's meta-object facilities
+ //Read properties from reader
+ QSensorReading *reading = _qsensor->reading();
+ const QMetaObject *mo = reading->metaObject();
+ int firstProperty = QSensorReading::staticMetaObject.propertyOffset();
+
+ for (int i = firstProperty; i < mo->propertyCount(); ++i) {
+ QString typeName = QLatin1String(mo->property(i).typeName());
+ int crap = typeName.lastIndexOf("::");
+ if (crap != -1)
+ typeName = typeName.mid(crap + 2);
+
+ QPropertyInfo* pi = new QPropertyInfo(mo->property(i).name()
+ , i
+ , isWriteable(mo->property(i).name())
+ , typeName
+ , "-"
+ , this);
+ _readerProperties.append(pi);
+ }
+
+ //Read properties from sensor
+ const QMetaObject *mo1 = _qsensor->metaObject();
+ firstProperty = QSensorReading::staticMetaObject.propertyOffset();
+
+ for (int i = firstProperty; i < mo1->propertyCount(); ++i) {
+ QString propertyname = mo1->property(i).name();
+ if (ignoreProperty(propertyname))
+ continue;
+
+ QString typeName = QLatin1String(mo1->property(i).typeName());
+ int crap = typeName.lastIndexOf("::");
+ if (crap != -1)
+ typeName = typeName.mid(crap + 2);
+
+ QPropertyInfo* pi = new QPropertyInfo(propertyname
+ , i
+ , isWriteable(propertyname)
+ , typeName
+ , "-"
+ , this);
+ _sensorProperties.append(pi);
+ }
+ updateSensorPropertyValues();
+ connect(_qsensor, SIGNAL(readingChanged()), this, SLOT(sensorReadingChanged()));
+ }
+ connect(_qsensor, SIGNAL(activeChanged()), SIGNAL(startChanged()));
+}
+
+/*
+ Unselect the sensor by stopping the sensor.
+*/
+void QSensorItem::unSelect()
+{
+ _qsensor->stop();
+ disconnect(_qsensor, SIGNAL(activeChanged()), this , SIGNAL(startChanged()));
+}
+
+/*
+ Updates the property values from QSensor
+*/
+void QSensorItem::updateSensorPropertyValues()
+{
+ if (_qsensor){
+ const QMetaObject *mo = _qsensor->metaObject();
+ for (int i = 0; i < _sensorProperties.count(); i++){
+ QVariant val = mo->property(_sensorProperties[i]->index()).read(_qsensor);
+ _sensorProperties[i]->setValue(convertValue(_sensorProperties[i]->typeName(), val));
+ }
+ }
+}
+
+/*
+ \fn QSensorItem::propertiesChanged()
+ Notifies the client if the list of the properties was changed
+*/
+
+/*
+ Updates the property values from the QSensorReader
+*/
+void QSensorItem::sensorReadingChanged()
+{
+ QSensorReading *reading = _qsensor->reading();
+ const QMetaObject *mo = reading->metaObject();
+ for (int i = 0; i < _readerProperties.count(); i++){
+ QVariant val = mo->property(_readerProperties[i]->index()).read(reading);
+ _readerProperties[i]->setValue(convertValue(_readerProperties[i]->typeName(), val));
+ }
+}
+
+/*
+ Returns true if the property with the name \a propertyname should be ignored
+*/
+bool QSensorItem::ignoreProperty(const QString& propertyname)
+{
+ if (propertyname == "reading" ||
+ propertyname == "active" ||
+ propertyname == "sensorid" ||
+ propertyname == "connectedToBackend" ||
+ propertyname == "busy")
+ return true;
+
+ return false;
+}
+
+/*
+ Returns true if the property with the name \a propertyname is writeable
+*/
+bool QSensorItem::isWriteable(const QString& propertyname)
+{
+ if (_qsensor){
+ const QMetaObject *mo = _qsensor->metaObject();
+ int propertyindex = mo->indexOfProperty(propertyname.toLocal8Bit().constData());
+ if (propertyindex >= 0){
+ QMetaProperty prop = mo->property(propertyindex);
+ return prop.isWritable();
+ }
+ else {
+ QSensorReading *reading = _qsensor->reading();
+ const QMetaObject *moreader = reading->metaObject();
+ propertyindex = moreader->indexOfProperty(propertyname.toLocal8Bit().constData());
+ if (propertyindex >= 0){
+ QMetaProperty prop = mo->property(propertyindex);
+ return prop.isWritable();
+ }
+ }
+ }
+
+ return false;
+}
+
+/*
+ Convert the variant \a val dependend on the type \a type and returns the converted value as a QString
+*/
+QString QSensorItem::convertValue(const QString& type, const QVariant& val)
+{
+ if (type == "LightLevel"){
+ switch (val.toInt()) {
+ case 1: return "Dark";
+ case 2: return "Twilight";
+ case 3: return "Light";
+ case 4: return "Bright";
+ case 5: return "Sunny";
+ default: return "Undefined";
+ }
+ }
+ else if (type == "Orientation"){
+ switch (val.toInt()) {
+ case 1: return "TopUp";
+ case 2: return "TopDown";
+ case 3: return "LeftUp";
+ case 4: return "RightUp";
+ case 5: return "FaceUp";
+ case 6: return "FaceDown";
+ default: return "Undefined";
+ }
+ }
+ else if (type == "qrangelist"){
+ qrangelist rangelist = val.value<qrangelist>();
+ QStringList ranges;
+ foreach (const qrange &r, rangelist) {
+ if (r.first == r.second)
+ ranges << QString("%1 Hz").arg(r.first);
+ else
+ ranges << QString("%1-%2 Hz").arg(r.first).arg(r.second);
+ }
+ if (ranges.count() > 0)
+ return ranges.join(", ");
+ return "-";
+ }
+ else if (type == "qoutputrangelist") {
+ qoutputrangelist rangelist = val.value<qoutputrangelist>();
+ QStringList ranges;
+ foreach (const qoutputrange &r, rangelist) {
+ ranges << QString("(%1, %2) += %3").arg(r.minimum).arg(r.maximum).arg(r.accuracy);
+ }
+ if (ranges.count() > 0)
+ return ranges.join(", ");
+ return "-";
+ }
+
+ return val.toString();
+}
+
+/*
+ \property QSensorItem::properties
+ Returns a list of all properties from the sensor
+*/
+QQmlListProperty<QPropertyInfo> QSensorItem::properties()
+{
+ _properties.clear();
+ _properties.append(_sensorProperties);
+ _properties.append(_readerProperties);
+ return QQmlListProperty<QPropertyInfo> (this, _properties);
+}
+
+QT_END_NAMESPACE
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/import/sensoritem.h b/examples/QtSensors/QtSensors_sensor_explorer/import/sensoritem.h
new file mode 100644
index 00000000..b937687f
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/import/sensoritem.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSENSORITEM_H
+#define QSENSORITEM_H
+
+#include <QtQml/QtQml>
+#include <QtCore/QString>
+#include "propertyinfo.h"
+
+QT_BEGIN_NAMESPACE
+
+class QSensor;
+class QSensorItem : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool start READ start WRITE setStart NOTIFY startChanged)
+ Q_PROPERTY(QString id READ id CONSTANT)
+ Q_PROPERTY(QQmlListProperty<QPropertyInfo> properties READ properties NOTIFY propertiesChanged)
+public:
+ QSensorItem(QObject* parent = 0);
+ QSensorItem(QSensor* sensor, QObject* parent = 0);
+ virtual ~QSensorItem();
+
+public slots:
+ void select();
+ void unSelect();
+ void changePropertyValue(QPropertyInfo* property, const QString& val);
+
+private slots:
+ void sensorReadingChanged();
+
+private:
+ QString id();
+ bool start();
+ void setStart(bool run);
+ QQmlListProperty<QPropertyInfo> properties();
+ QString convertValue(const QString& type, const QVariant& val);
+ bool isWriteable(const QString& propertyname);
+ bool ignoreProperty(const QString& propertyname);
+ void updateSensorPropertyValues();
+
+Q_SIGNALS:
+ void propertiesChanged();
+ void startChanged();
+
+private:
+ QSensor* _qsensor;
+ QList<QPropertyInfo*> _properties;
+ QList<QPropertyInfo*> _readerProperties;
+ QList<QPropertyInfo*> _sensorProperties;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QSensorItem)
+
+#endif // QSENSORITEM_H
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/info.json b/examples/QtSensors/QtSensors_sensor_explorer/info.json
new file mode 100644
index 00000000..18f3e8d5
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/info.json
@@ -0,0 +1,15 @@
+{
+ "info-version": "1.0",
+ "dict": {
+ "category": "application",
+ "runtime": "qml",
+ "displayName": {
+ "en_US": "Sensors Explorer"
+ },
+ "subcategory": "utility",
+ "main": "QtSensors_sensor_explorer.qml",
+ "version": "1.0.0",
+ "identifier": "com.nokia.mt.sensorexplorer",
+ "author": "Qt"
+ }
+}
diff --git a/examples/QtSensors/QtSensors_sensor_explorer/qml.pro b/examples/QtSensors/QtSensors_sensor_explorer/qml.pro
new file mode 100644
index 00000000..bc4f8588
--- /dev/null
+++ b/examples/QtSensors/QtSensors_sensor_explorer/qml.pro
@@ -0,0 +1,18 @@
+TEMPLATE = aux
+
+app.files = \
+ info.json \
+ QtSensors_sensor_explorer.qml \
+ PropertyList.qml \
+ SensorList.qml \
+ icon.png \
+ components \
+ content
+
+MT_SYSROOT=$$(MT_SYSROOT)
+!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications
+!isEmpty(EXAMPLES_PREFIX) {
+ app.path = $$EXAMPLES_PREFIX/com.nokia.mt.sensor_explorer
+ INSTALLS = app
+}
+
diff --git a/examples/QtSensors/QtSensors_shakeit/QtSensors_shakeit.pro b/examples/QtSensors/QtSensors_shakeit/QtSensors_shakeit.pro
new file mode 100644
index 00000000..6dc685b9
--- /dev/null
+++ b/examples/QtSensors/QtSensors_shakeit/QtSensors_shakeit.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+
+SUBDIRS = qml.pro
diff --git a/examples/QtSensors/QtSensors_shakeit/QtSensors_shakeit.qml b/examples/QtSensors/QtSensors_shakeit/QtSensors_shakeit.qml
new file mode 100644
index 00000000..50ef8deb
--- /dev/null
+++ b/examples/QtSensors/QtSensors_shakeit/QtSensors_shakeit.qml
@@ -0,0 +1,324 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+//! [0]
+import QtSensors 5.0
+//! [0]
+//import QtMultimedia 4.0
+import Qt.multimediakit 4.0
+
+
+
+Rectangle {
+ id: window
+
+ state: "default"
+
+ Audio {
+ id :phone
+ source: "audio/phone.wav" //mono
+ }
+ Audio {
+ id :loopy2a_mono
+ source: "audio/loopy2a_mono.wav" //mono
+ }
+
+ Text {
+ id: label
+ text: qsTr("Shake to rotate triangles")
+ y: parent.height / 4
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Image {
+ id: triangle1
+ smooth: true
+ source: "content/triangle.png"
+ x: parent.width / 2 - (triangle1.width / 2)
+ y: parent.height / 2 - (triangle1.height);
+ Behavior on x { SmoothedAnimation { velocity: 200 } }
+ Behavior on y { SmoothedAnimation { velocity: 200 } }
+ transform: Rotation {
+ id: myRot
+ }
+ }
+ Image {
+ id: triangle2
+ smooth: true
+ source: "content/triangle2.png"
+ x: parent.width / 2 - (triangle1.width + triangle2.width / 2)
+ y: parent.height / 2 + (triangle2.height / 2);
+ Behavior on x { SmoothedAnimation { velocity: 200 } }
+ Behavior on y { SmoothedAnimation { velocity: 200 } }
+ }
+ Image {
+ id: triangle3
+ smooth: true
+ source: "content/triangle3.png"
+ x: parent.width / 2 + (triangle1.width / 2)
+ y: parent.height / 2 + (triangle3.height / 2);
+
+ Behavior on x { SmoothedAnimation { velocity: 200 } }
+ Behavior on y { SmoothedAnimation { velocity: 200 } }
+ }
+
+ states: [
+ State {
+ name: "rotated"
+ PropertyChanges { target: triangle1; rotation: 180 }
+ PropertyChanges { target: triangle2; rotation: 90 }
+ PropertyChanges { target: triangle3; rotation: 270 }
+ },
+ State {
+ name: "default"
+ PropertyChanges { target: triangle1; rotation: 0;
+ x: parent.width / 2 - (triangle1.width / 2)
+ y: parent.height / 2 - (triangle1.height);
+ }
+ PropertyChanges { target: triangle2; rotation: 0;
+ x: parent.width / 2 - (triangle1.width + triangle2.width / 2)
+ y: parent.height / 2 + (triangle2.height / 2);
+ }
+ PropertyChanges { target: triangle3; rotation: 0;
+ x: parent.width / 2 + (triangle1.width / 2)
+ y: parent.height / 2 + (triangle3.height / 2);
+ }
+ },
+ State {
+ name: "whipped"
+ PropertyChanges { target: triangle1; rotation: 0; x:0; }
+ PropertyChanges { target: triangle2; rotation: 0; x:0; y:triangle1.x + triangle1.height; }
+ PropertyChanges { target: triangle3; rotation: 0; x:0;
+ y: triangle2.y + triangle2.height; }
+ },
+ State {
+ name: "twistedR"
+ PropertyChanges { target: triangle1; rotation: 270;
+ x:window.width - triangle1.width;
+ }
+ PropertyChanges { target: triangle2; rotation: 180;
+ x:window.width - triangle2.width;
+ }
+ PropertyChanges { target: triangle3; rotation: 90;
+ x:window.width - triangle3.width;
+ y:triangle2.y + triangle2.height;
+ }
+ },
+ State {
+ name: "twistedL"
+ PropertyChanges { target: triangle1; rotation: 270;
+ x:0;
+ }
+ PropertyChanges { target: triangle2; rotation: 180;
+ x:0;
+ }
+ PropertyChanges { target: triangle3; rotation: 90;
+ x:0;
+ y:triangle2.y + triangle2.height;
+ }
+ },
+ State {
+ name: "covered"
+ PropertyChanges { target: triangle1; rotation: 0;
+ x: window.width / 3 - triangle1.width / 2;
+ y: window.height - triangle1.height;
+ }
+ PropertyChanges { target: triangle2; rotation: 0;
+ x: window.width / 2 - triangle2.width / 2; // middle
+ y: window.height - triangle2.height;
+ }
+ PropertyChanges { target: triangle3; rotation: 0;
+ x: (window.width / 3 + window.width / 3) - triangle3.width / 2;
+ y: window.height - triangle3.height;
+ }
+ },
+ State {
+ name: "hovered"
+ PropertyChanges { target: triangle1; rotation: 90;
+ x: window.width / 3 - triangle1.width / 2;
+ y: triangle1.height;
+ }
+ PropertyChanges { target: triangle2; rotation: 270;
+ x: window.width / 2 - triangle2.width / 2; // middle
+ y: triangle2.height;
+ }
+ PropertyChanges { target: triangle3; rotation: 195;
+ x: (window.width / 3 + window.width / 3) - triangle3.width / 2;
+ y: triangle3.height
+ }
+ },
+ State {
+ name :"slammed"
+ PropertyChanges { target: triangle1; rotation: 0;
+ x: 0;
+ y: 0 + 30
+ }
+ PropertyChanges { target: triangle2; rotation: 0;
+ x: window.width - triangle2.width;
+ y: 0 + 30
+ ;}
+ PropertyChanges { target: triangle3; rotation: 0;
+ x: window.width / 2 - triangle3.width / 2;
+ y:window.height - triangle3.height;
+ }
+ },
+ State {
+ name: "doubletapped"
+ PropertyChanges { target: triangle1; rotation: 114;
+ transformOrigin: Item.BottomLeft
+ }
+ PropertyChanges { target: triangle2; rotation: 120;
+ transformOrigin: Item.BottomLeft
+ }
+ }
+ ]
+
+
+ transitions: [
+ Transition {
+
+ ParallelAnimation {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce;duration: 2000; }
+ RotationAnimation { id: t1Rotation; target: triangle1; duration: 1000;
+ direction: RotationAnimation.Clockwise }
+ RotationAnimation { id: t2Rotation; target: triangle2; duration: 2000;
+ direction: RotationAnimation.Counterclockwise }
+ RotationAnimation { id: t3Rotation; target: triangle3; duration: 2000;
+ direction: RotationAnimation.Clockwise }
+ }
+
+ }, Transition {
+ to: "slammed"
+ SequentialAnimation {
+ NumberAnimation { properties: "x"; easing.type: Easing.OutBounce;duration: 500; }
+
+ }
+ }, Transition {
+ to: "doubletapped"
+ SequentialAnimation {
+ PropertyAction { target: triangle1; property: "transformOrigin" }
+ PropertyAction { target: triangle2; property: "transformOrigin" }
+ NumberAnimation { target: triangle1; properties: "rotation"; easing.type: Easing.OutBounce;duration: 500; }
+ NumberAnimation { target: triangle2; properties: "rotation"; easing.type: Easing.OutBounce;duration: 1500; }
+ }
+ }, Transition {
+ from: "doubletapped"
+ SequentialAnimation {
+ NumberAnimation { properties: "rotation"; easing.type: Easing.OutBounce;duration: 1500; }
+ PropertyAction { target: triangle1; property: "transformOrigin" }
+ PropertyAction { target: triangle2; property: "transformOrigin" }
+ }
+ }
+ ]
+
+//! [1]
+ SensorGesture {
+//! [1]
+ id: sensorGesture
+//! [3]
+ enabled: true
+//! [3]
+//! [2]
+ gestures : ["QtSensors.shake", "QtSensors.whip", "QtSensors.twist", "QtSensors.cover",
+ "QtSensors.hover", "QtSensors.turnover", "QtSensors.pickup", "QtSensors.slam" , "QtSensors.doubletap"]
+//! [2]
+//! [4]
+ onDetected:{
+ console.debug(gesture)
+ label.text = gesture
+
+ if (gesture == "shake") {
+ window.state == "rotated" ? window.state = "default" : window.state = "rotated"
+ timer.start()
+ }
+ if (gesture == "whip") {
+ window.state == "whipped" ? window.state = "default" : window.state = "whipped"
+ timer.start()
+ }
+ if (gesture == "twistRight") {
+ window.state == "twistedR" ? window.state = "default" : window.state = "twistedR"
+ timer.start()
+ }
+ if (gesture == "twistLeft") {
+ window.state == "twistedL" ? window.state = "default" : window.state = "twistedL"
+ timer.start()
+ }
+ if (gesture == "cover") {
+ window.state == "covered" ? window.state = "default" : window.state = "covered"
+ timer.start()
+ }
+ if (gesture == "hover") {
+ window.state == "hovered" ? window.state = "default" : window.state = "hovered"
+ timer.start()
+ }
+ if (gesture == "turnover") {
+ window.state = "default"
+ loopy2a_mono.play();
+ timer.start()
+ }
+ if (gesture == "pickup") {
+ window.state = "default"
+ phone.play()
+ timer.start()
+ }
+ if (gesture == "slam") {
+ window.state == "slammed" ? window.state = "default" : window.state = "slammed"
+ timer.start()
+ }
+ if (gesture == "doubletap") {
+ window.state == "doubletapped" ? window.state = "default" : window.state = "doubletapped"
+ timer.start()
+ }
+ }
+//! [4]
+ }
+ Timer {
+ id: timer
+ running: false
+ repeat: false
+ interval: 3000
+ onTriggered: {
+ console.log("timer triggered")
+ window.state = "default"
+ label.text = "Try another gesture"
+ }
+ }
+}
diff --git a/examples/QtSensors/QtSensors_shakeit/audio/loopy2a_mono.wav b/examples/QtSensors/QtSensors_shakeit/audio/loopy2a_mono.wav
new file mode 100644
index 00000000..7d76cb65
--- /dev/null
+++ b/examples/QtSensors/QtSensors_shakeit/audio/loopy2a_mono.wav
Binary files differ
diff --git a/examples/QtSensors/QtSensors_shakeit/audio/phone.wav b/examples/QtSensors/QtSensors_shakeit/audio/phone.wav
new file mode 100644
index 00000000..884e9ac2
--- /dev/null
+++ b/examples/QtSensors/QtSensors_shakeit/audio/phone.wav
Binary files differ
diff --git a/examples/QtSensors/QtSensors_shakeit/content/triangle.png b/examples/QtSensors/QtSensors_shakeit/content/triangle.png
new file mode 100644
index 00000000..f366537e
--- /dev/null
+++ b/examples/QtSensors/QtSensors_shakeit/content/triangle.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_shakeit/content/triangle2.png b/examples/QtSensors/QtSensors_shakeit/content/triangle2.png
new file mode 100644
index 00000000..9318d5a3
--- /dev/null
+++ b/examples/QtSensors/QtSensors_shakeit/content/triangle2.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_shakeit/content/triangle3.png b/examples/QtSensors/QtSensors_shakeit/content/triangle3.png
new file mode 100644
index 00000000..4cc5ccda
--- /dev/null
+++ b/examples/QtSensors/QtSensors_shakeit/content/triangle3.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_shakeit/icon.png b/examples/QtSensors/QtSensors_shakeit/icon.png
new file mode 100644
index 00000000..d8f21546
--- /dev/null
+++ b/examples/QtSensors/QtSensors_shakeit/icon.png
Binary files differ
diff --git a/examples/QtSensors/QtSensors_shakeit/info.json b/examples/QtSensors/QtSensors_shakeit/info.json
new file mode 100644
index 00000000..a98f6f2b
--- /dev/null
+++ b/examples/QtSensors/QtSensors_shakeit/info.json
@@ -0,0 +1,14 @@
+{
+ "info-version": "1.0",
+ "dict": {
+ "displayName": {
+ "en_US": "ShakeIt!"
+ },
+ "identifier": "com.nokia.mt.shakeit",
+ "runtime": "qml",
+ "main": "QtSensors_shakeit.qml",
+ "version": "1.0.0",
+ "category": "application",
+ "subcategory": "utility"
+ }
+}
diff --git a/examples/QtSensors/QtSensors_shakeit/qml.pro b/examples/QtSensors/QtSensors_shakeit/qml.pro
new file mode 100644
index 00000000..a56249de
--- /dev/null
+++ b/examples/QtSensors/QtSensors_shakeit/qml.pro
@@ -0,0 +1,16 @@
+TEMPLATE = aux
+
+app.files = \
+ info.json \
+ QtSensors_shakeit.qml \
+ icon.png \
+ audio \
+ content
+
+MT_SYSROOT=$$(MT_SYSROOT)
+!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications
+!isEmpty(EXAMPLES_PREFIX) {
+ app.path = $$EXAMPLES_PREFIX/com.nokia.mt.shakeit
+ INSTALLS = app
+}
+
diff --git a/examples/QtSensors/accel/accel.pro b/examples/QtSensors/accel/accel.pro
new file mode 100644
index 00000000..86303eca
--- /dev/null
+++ b/examples/QtSensors/accel/accel.pro
@@ -0,0 +1,7 @@
+TEMPLATE=app
+TARGET=accel
+
+QT=core sensors
+
+SOURCES=main.cpp
+
diff --git a/examples/QtSensors/accel/main.cpp b/examples/QtSensors/accel/main.cpp
new file mode 100644
index 00000000..012c8c61
--- /dev/null
+++ b/examples/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 <QtCore>
+#include <qaccelerometer.h>
+
+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
new file mode 100644
index 00000000..feeec685
--- /dev/null
+++ b/examples/QtSensors/accelbubble/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/accelbubble/icon.png b/examples/QtSensors/accelbubble/icon.png
new file mode 100644
index 00000000..d74f1111
--- /dev/null
+++ b/examples/QtSensors/accelbubble/icon.png
Binary files differ
diff --git a/examples/QtSensors/accelbubble/images/Bluebubble2.png b/examples/QtSensors/accelbubble/images/Bluebubble2.png
new file mode 100644
index 00000000..f96126eb
--- /dev/null
+++ b/examples/QtSensors/accelbubble/images/Bluebubble2.png
Binary files differ
diff --git a/examples/QtSensors/accelbubble/info.json b/examples/QtSensors/accelbubble/info.json
new file mode 100644
index 00000000..9a2ed709
--- /dev/null
+++ b/examples/QtSensors/accelbubble/info.json
@@ -0,0 +1,14 @@
+{
+ "info-version": "1.0",
+ "dict": {
+ "Category": "application",
+ "Runtime": "qml",
+ "DisplayName": "Accel Bubble",
+ "Subcategory": "utility",
+ "MainQML": "main.qml",
+ "Version": "1.0",
+ "Identifier": "com.nokia.mt.accelbubble",
+ "Summary": "QtSensors Accel Bubble",
+ "Author": "Qt"
+ }
+}
diff --git a/examples/QtSensors/accelbubble/main.qml b/examples/QtSensors/accelbubble/main.qml
new file mode 100644
index 00000000..487ee3f5
--- /dev/null
+++ b/examples/QtSensors/accelbubble/main.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: "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
new file mode 100644
index 00000000..c174b8fe
--- /dev/null
+++ b/examples/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: "images/qtlogo.png"
+ decal: true
+ }
+}
diff --git a/examples/QtSensors/cubehouse/Cubehouse.qml b/examples/QtSensors/cubehouse/Cubehouse.qml
new file mode 100644
index 00000000..5a1b91f8
--- /dev/null
+++ b/examples/QtSensors/cubehouse/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/cubehouse/Room.qml b/examples/QtSensors/cubehouse/Room.qml
new file mode 100644
index 00000000..43af3b12
--- /dev/null
+++ b/examples/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: "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
new file mode 100644
index 00000000..683d28de
--- /dev/null
+++ b/examples/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/cubehouse/cubehouse.pro b/examples/QtSensors/cubehouse/cubehouse.pro
new file mode 100644
index 00000000..075ec4ef
--- /dev/null
+++ b/examples/QtSensors/cubehouse/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/cubehouse/icon.png b/examples/QtSensors/cubehouse/icon.png
new file mode 100644
index 00000000..193ad561
--- /dev/null
+++ b/examples/QtSensors/cubehouse/icon.png
Binary files differ
diff --git a/examples/QtSensors/cubehouse/images/ground.jpg b/examples/QtSensors/cubehouse/images/ground.jpg
new file mode 100644
index 00000000..2664b99e
--- /dev/null
+++ b/examples/QtSensors/cubehouse/images/ground.jpg
Binary files differ
diff --git a/examples/QtSensors/cubehouse/images/qtlogo.png b/examples/QtSensors/cubehouse/images/qtlogo.png
new file mode 100644
index 00000000..7d3e97eb
--- /dev/null
+++ b/examples/QtSensors/cubehouse/images/qtlogo.png
Binary files differ
diff --git a/examples/QtSensors/cubehouse/images/roof.jpg b/examples/QtSensors/cubehouse/images/roof.jpg
new file mode 100644
index 00000000..53a35d64
--- /dev/null
+++ b/examples/QtSensors/cubehouse/images/roof.jpg
Binary files differ
diff --git a/examples/QtSensors/cubehouse/images/wall.jpg b/examples/QtSensors/cubehouse/images/wall.jpg
new file mode 100644
index 00000000..7c56e23f
--- /dev/null
+++ b/examples/QtSensors/cubehouse/images/wall.jpg
Binary files differ
diff --git a/examples/QtSensors/cubehouse/info.json b/examples/QtSensors/cubehouse/info.json
new file mode 100644
index 00000000..39e39a8b
--- /dev/null
+++ b/examples/QtSensors/cubehouse/info.json
@@ -0,0 +1,14 @@
+{
+ "info-version": "1.0",
+ "dict": {
+ "Category": "application",
+ "Runtime": "qml",
+ "DisplayName": "Cubehouse",
+ "Subcategory": "utility",
+ "MainQML": "Cubehouse.qml",
+ "Version": "1.0",
+ "Identifier": "com.nokia.mt.cubehouse",
+ "Summary": "Cubehouse using Accelerometer",
+ "Author": "Qt"
+ }
+}
diff --git a/examples/QtSensors/cubehouse/mesh/table.3ds b/examples/QtSensors/cubehouse/mesh/table.3ds
new file mode 100644
index 00000000..3e576bd1
--- /dev/null
+++ b/examples/QtSensors/cubehouse/mesh/table.3ds
Binary files differ
diff --git a/examples/QtSensors/grue/console_app/console_app.pro b/examples/QtSensors/grue/console_app/console_app.pro
new file mode 100644
index 00000000..33d43176
--- /dev/null
+++ b/examples/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/grue/console_app/main.cpp b/examples/QtSensors/grue/console_app/main.cpp
new file mode 100644
index 00000000..dc62e4de
--- /dev/null
+++ b/examples/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 <QtCore>
+#include <qsensor.h>
+
+class Filter : public QSensorFilter
+{
+ int lastPercent;
+public:
+ Filter()
+ : QSensorFilter()
+ , lastPercent(0)
+ {
+ }
+
+ bool filter(QSensorReading *reading)
+ {
+ int percent = reading->property("chanceOfBeingEaten").value<qreal>() * 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
new file mode 100644
index 00000000..0405286d
--- /dev/null
+++ b/examples/QtSensors/grue/grue.pro
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 00000000..753e1ef8
--- /dev/null
+++ b/examples/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/grue/import/main.cpp b/examples/QtSensors/grue/import/main.cpp
new file mode 100644
index 00000000..6c327032
--- /dev/null
+++ b/examples/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 <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+
+#include <gruesensor.h>
+#include <QDebug>
+
+#ifdef BUNDLED_PLUGIN
+#include <QPluginLoader>
+#include <QSensorPluginInterface>
+#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 <GrueSensor >(package, major, minor, "GrueSensor");
+ qmlRegisterUncreatableType<GrueSensorReading>(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<QSensorChangesInterface*>(instance);
+ if (m_changes) {
+ QSensor *sensor = new QSensor(QByteArray(), this);
+ connect(sensor, SIGNAL(availableSensorsChanged()), this, SLOT(sensorsChanged()));
+ m_changes->sensorsChanged();
+ }
+ QSensorPluginInterface *plugin = qobject_cast<QSensorPluginInterface*>(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
new file mode 100644
index 00000000..0967ef42
--- /dev/null
+++ b/examples/QtSensors/grue/import/plugin.json
@@ -0,0 +1 @@
+{}
diff --git a/examples/QtSensors/grue/import/qmldir b/examples/QtSensors/grue/import/qmldir
new file mode 100644
index 00000000..266b7c11
--- /dev/null
+++ b/examples/QtSensors/grue/import/qmldir
@@ -0,0 +1 @@
+plugin declarative_grue
diff --git a/examples/QtSensors/grue/lib/gruesensor.cpp b/examples/QtSensors/grue/lib/gruesensor.cpp
new file mode 100644
index 00000000..b1f00ede
--- /dev/null
+++ b/examples/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/grue/lib/gruesensor.h b/examples/QtSensors/grue/lib/gruesensor.h
new file mode 100644
index 00000000..8088988d
--- /dev/null
+++ b/examples/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 <qsensor.h>
+
+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<GrueSensorReading*>(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<GrueSensorReading*>(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
new file mode 100644
index 00000000..4996e868
--- /dev/null
+++ b/examples/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/grue/lib/lib.pro b/examples/QtSensors/grue/lib/lib.pro
new file mode 100644
index 00000000..e048e607
--- /dev/null
+++ b/examples/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/grue/plugin/gruesensorimpl.cpp b/examples/QtSensors/grue/plugin/gruesensorimpl.cpp
new file mode 100644
index 00000000..e7152a67
--- /dev/null
+++ b/examples/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 <QDebug>
+#include <QTimer>
+
+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<GrueSensorReading>(&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
new file mode 100644
index 00000000..ed89711d
--- /dev/null
+++ b/examples/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 <qsensorbackend.h>
+#include "gruesensor.h"
+#include <qambientlightsensor.h>
+#include <QTime>
+
+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
new file mode 100644
index 00000000..36aec298
--- /dev/null
+++ b/examples/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 <qsensorplugin.h>
+#include <qsensorbackend.h>
+#include <qsensormanager.h>
+#include <QFile>
+#include <QDebug>
+
+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
new file mode 100644
index 00000000..8a55b3ae
--- /dev/null
+++ b/examples/QtSensors/grue/plugin/plugin.json
@@ -0,0 +1 @@
+{ "Keys": [ "notused" ] }
diff --git a/examples/QtSensors/grue/plugin/plugin.pro b/examples/QtSensors/grue/plugin/plugin.pro
new file mode 100644
index 00000000..32e127f1
--- /dev/null
+++ b/examples/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/grue/qml_app/grue.png b/examples/QtSensors/grue/qml_app/grue.png
new file mode 100644
index 00000000..f0b070b4
--- /dev/null
+++ b/examples/QtSensors/grue/qml_app/grue.png
Binary files differ
diff --git a/examples/QtSensors/grue/qml_app/grue.xcf b/examples/QtSensors/grue/qml_app/grue.xcf
new file mode 100644
index 00000000..2837ed7e
--- /dev/null
+++ b/examples/QtSensors/grue/qml_app/grue.xcf
Binary files differ
diff --git a/examples/QtSensors/grue/qml_app/icon.png b/examples/QtSensors/grue/qml_app/icon.png
new file mode 100644
index 00000000..f3f038c7
--- /dev/null
+++ b/examples/QtSensors/grue/qml_app/icon.png
Binary files differ
diff --git a/examples/QtSensors/grue/qml_app/icon.xcf b/examples/QtSensors/grue/qml_app/icon.xcf
new file mode 100644
index 00000000..8416c49f
--- /dev/null
+++ b/examples/QtSensors/grue/qml_app/icon.xcf
Binary files differ
diff --git a/examples/QtSensors/grue/qml_app/info.json b/examples/QtSensors/grue/qml_app/info.json
new file mode 100644
index 00000000..2e14fc79
--- /dev/null
+++ b/examples/QtSensors/grue/qml_app/info.json
@@ -0,0 +1,12 @@
+{
+ "info-version": "1.0",
+ "dict": {
+ "DisplayName": "Grue Sensor",
+ "Identifier": "com.nokia.mt.grue",
+ "Runtime": "qml",
+ "MainQML": "main.qml",
+ "Version": "1.0.0",
+ "Category": "application",
+ "Summary": "The Grue sensor identifies your chance of being eaten by a Grue."
+ }
+}
diff --git a/examples/QtSensors/grue/qml_app/main.qml b/examples/QtSensors/grue/qml_app/main.qml
new file mode 100644
index 00000000..05d267c7
--- /dev/null
+++ b/examples/QtSensors/grue/qml_app/main.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 = "<p>" + thetext + "</p>";
+ 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
new file mode 100644
index 00000000..c017dcc4
--- /dev/null
+++ b/examples/QtSensors/grue/qml_app/qml_app.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/qmlsensorgestures/plugin/plugin.json b/examples/QtSensors/qmlsensorgestures/plugin/plugin.json
new file mode 100644
index 00000000..8a55b3ae
--- /dev/null
+++ b/examples/QtSensors/qmlsensorgestures/plugin/plugin.json
@@ -0,0 +1 @@
+{ "Keys": [ "notused" ] }
diff --git a/examples/QtSensors/qmlsensorgestures/plugin/plugin.pro b/examples/QtSensors/qmlsensorgestures/plugin/plugin.pro
new file mode 100644
index 00000000..2003e910
--- /dev/null
+++ b/examples/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/qmlsensorgestures/plugin/qcountergestureplugin.cpp b/examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp
new file mode 100644
index 00000000..1fda1879
--- /dev/null
+++ b/examples/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 <QtPlugin>
+#include <QStringList>
+#include <QObject>
+
+#include "qcountergestureplugin.h"
+#include <qsensorgestureplugininterface.h>
+#include <qsensorgesturemanager.h>
+#include "qcounterrecognizer.h"
+
+
+QCounterGesturePlugin::QCounterGesturePlugin()
+{
+}
+
+QCounterGesturePlugin::~QCounterGesturePlugin()
+{
+}
+
+QStringList QCounterGesturePlugin::supportedIds() const
+{
+ QStringList list;
+ list << "QtSensors.SecondCounter";
+ return list;
+}
+
+
+QList <QSensorGestureRecognizer *> QCounterGesturePlugin::createRecognizers()
+{
+ QList <QSensorGestureRecognizer *> recognizers;
+
+ QSensorGestureRecognizer *sRec = new QCounterGestureRecognizer(this);
+ recognizers.append(sRec);
+
+ return recognizers;
+}
diff --git a/examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.h b/examples/QtSensors/qmlsensorgestures/plugin/qcountergestureplugin.h
new file mode 100644
index 00000000..4755f96e
--- /dev/null
+++ b/examples/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 <QObject>
+#include <QStringList>
+
+#include <qsensorgestureplugininterface.h>
+
+class QCounterGesturePlugin : public QObject, public QSensorGesturePluginInterface
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "com.Nokia.QSensorGesturePluginInterface" FILE "plugin.json")
+ Q_INTERFACES(QSensorGesturePluginInterface)
+
+public:
+ explicit QCounterGesturePlugin();
+ ~QCounterGesturePlugin();
+
+ QList <QSensorGestureRecognizer *> createRecognizers();
+
+ QStringList gestureSignals() const;
+ QStringList supportedIds() const;
+ QString name() const { return "CounterGestures"; }
+};
+
+#endif // QCOUNTERGESTUREPLUGIN_H
diff --git a/examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp b/examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp
new file mode 100644
index 00000000..03319e81
--- /dev/null
+++ b/examples/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 <QDebug>
+#include <QTimer>
+
+#include "qcounterrecognizer.h"
+
+QCounterGestureRecognizer::QCounterGestureRecognizer(QObject *parent)
+ : QSensorGestureRecognizer(parent)
+{
+}
+
+QCounterGestureRecognizer::~QCounterGestureRecognizer()
+{
+
+}
+
+void QCounterGestureRecognizer::create()
+{
+ connect(&_timer,SIGNAL(timeout()),this,SLOT(timeout()));
+ _timer.setInterval(1000);
+}
+
+bool QCounterGestureRecognizer::start()
+{
+ Q_EMIT detected(id());
+ _timer.start();
+ return _timer.isActive();
+}
+
+bool QCounterGestureRecognizer::stop()
+{
+ _timer.stop();
+ return true;
+}
+
+
+bool QCounterGestureRecognizer::isActive()
+{
+ return _timer.isActive();
+}
+
+QString QCounterGestureRecognizer::id() const
+{
+ return QString("QtSensors.SecondCounter");
+}
+
+void QCounterGestureRecognizer::timeout()
+{
+ Q_EMIT detected(id());
+}
diff --git a/examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.h b/examples/QtSensors/qmlsensorgestures/plugin/qcounterrecognizer.h
new file mode 100644
index 00000000..37c16eb1
--- /dev/null
+++ b/examples/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 <QDebug>
+#include <QtCore/QTimer>
+#include <qsensorgesturerecognizer.h>
+
+class QCounterGestureRecognizer : public QSensorGestureRecognizer
+{
+ Q_OBJECT
+public:
+
+ QCounterGestureRecognizer(QObject *parent = 0);
+ ~QCounterGestureRecognizer();
+
+ void create();
+
+ QString id() const;
+ bool start();
+ bool stop();
+ bool isActive();
+
+private slots:
+ void timeout();
+
+private:
+ QTimer _timer;
+};
+
+#endif // QCOUNTERGESTURERECOGNIZER_H
diff --git a/examples/QtSensors/qmlsensorgestures/qml_app/Button.qml b/examples/QtSensors/qmlsensorgestures/qml_app/Button.qml
new file mode 100644
index 00000000..23fc0f66
--- /dev/null
+++ b/examples/QtSensors/qmlsensorgestures/qml_app/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/qmlsensorgestures/qml_app/Gesture.qml b/examples/QtSensors/qmlsensorgestures/qml_app/Gesture.qml
new file mode 100644
index 00000000..2982c097
--- /dev/null
+++ b/examples/QtSensors/qmlsensorgestures/qml_app/Gesture.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/qmlsensorgestures/qml_app/GestureList.qml b/examples/QtSensors/qmlsensorgestures/qml_app/GestureList.qml
new file mode 100644
index 00000000..c9b1f094
--- /dev/null
+++ b/examples/QtSensors/qmlsensorgestures/qml_app/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/qmlsensorgestures/qml_app/GestureView.qml b/examples/QtSensors/qmlsensorgestures/qml_app/GestureView.qml
new file mode 100644
index 00000000..07a9a5cc
--- /dev/null
+++ b/examples/QtSensors/qmlsensorgestures/qml_app/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/qmlsensorgestures/qml_app/GesturesView.qml b/examples/QtSensors/qmlsensorgestures/qml_app/GesturesView.qml
new file mode 100644
index 00000000..23924cad
--- /dev/null
+++ b/examples/QtSensors/qmlsensorgestures/qml_app/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/qmlsensorgestures/qml_app/icon.png b/examples/QtSensors/qmlsensorgestures/qml_app/icon.png
new file mode 100644
index 00000000..c445bd7f
--- /dev/null
+++ b/examples/QtSensors/qmlsensorgestures/qml_app/icon.png
Binary files differ
diff --git a/examples/QtSensors/qmlsensorgestures/qml_app/info.json b/examples/QtSensors/qmlsensorgestures/qml_app/info.json
new file mode 100644
index 00000000..063caaa0
--- /dev/null
+++ b/examples/QtSensors/qmlsensorgestures/qml_app/info.json
@@ -0,0 +1,14 @@
+{
+ "info-version": "1.0",
+ "dict": {
+ "Category": "application",
+ "Runtime": "qml",
+ "DisplayName": "Gesture",
+ "Subcategory": "utility",
+ "MainQML": "Gesture.qml",
+ "Version": "1.0",
+ "Identifier": "com.nokia.mt.qmlsensorsgesture",
+ "Summary": "QML Sensors Gesture demo",
+ "Author": "Qt"
+ }
+}
diff --git a/examples/QtSensors/qmlsensorgestures/qml_app/qml_app.pro b/examples/QtSensors/qmlsensorgestures/qml_app/qml_app.pro
new file mode 100644
index 00000000..6ad9a8bf
--- /dev/null
+++ b/examples/QtSensors/qmlsensorgestures/qml_app/qml_app.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/qmlsensorgestures/qmlsensorgestures.pro b/examples/QtSensors/qmlsensorgestures/qmlsensorgestures.pro
new file mode 100644
index 00000000..01677c19
--- /dev/null
+++ b/examples/QtSensors/qmlsensorgestures/qmlsensorgestures.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+
+SUBDIRS += plugin
+SUBDIRS += qml_app
+
diff --git a/examples/QtSensors/sensorgestures/gesture.png b/examples/QtSensors/sensorgestures/gesture.png
new file mode 100644
index 00000000..707d5c4e
--- /dev/null
+++ b/examples/QtSensors/sensorgestures/gesture.png
Binary files differ
diff --git a/examples/QtSensors/sensorgestures/main.cpp b/examples/QtSensors/sensorgestures/main.cpp
new file mode 100644
index 00000000..49594d4e
--- /dev/null
+++ b/examples/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 <QtWidgets/QApplication>
+#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
new file mode 100644
index 00000000..9dd8a611
--- /dev/null
+++ b/examples/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 <QtCore/QDebug>
+#include <QtWidgets/QTreeWidget>
+
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <qsensorgesture.h>
+#include <qsensorgesturemanager.h>
+
+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 = "<font size=+2><B>"+name+"</b></font><br>";
+ ui->textEdit->insertHtml(str);
+ ui->textEdit->ensureCursorVisible();
+}
+
+void MainWindow::on_pushButton_clicked()
+{
+ ui->textEdit->clear();
+}
+
+void MainWindow::onShake()
+{
+ QString str = "<font size=+2><B>onShake()</b></font><br>";
+ 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("<font size=+2><B>Started %1</b></font><br>").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("<font size=+2><B>Stopped %1</b></font><br>").arg(currentRecognizer);
+ ui->textEdit->insertHtml(str);
+ ui->textEdit->ensureCursorVisible();
+}
diff --git a/examples/QtSensors/sensorgestures/mainwindow.h b/examples/QtSensors/sensorgestures/mainwindow.h
new file mode 100644
index 00000000..1e38f1be
--- /dev/null
+++ b/examples/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 <QtWidgets/QMainWindow>
+#include <qsensorgesture.h>
+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 <QString, QSensorGesture *> 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
new file mode 100644
index 00000000..baccf98c
--- /dev/null
+++ b/examples/QtSensors/sensorgestures/mainwindow.ui
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>423</width>
+ <height>474</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QTreeWidget" name="treeWidget">
+ <column>
+ <property name="text">
+ <string>Gesture Recognizer Id</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="startPushButton">
+ <property name="text">
+ <string>Start</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="stopPushButton">
+ <property name="text">
+ <string>Stop</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QTextEdit" name="textEdit">
+ <property name="html">
+ <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot;-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;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QPushButton" name="pushButton">
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>423</width>
+ <height>22</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/QtSensors/sensorgestures/sensorgestures.pro b/examples/QtSensors/sensorgestures/sensorgestures.pro
new file mode 100644
index 00000000..295db944
--- /dev/null
+++ b/examples/QtSensors/sensorgestures/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