From 9d4d08421acb628e0115b140e54656fc779d13db Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Thu, 4 Oct 2012 13:48:23 +0200 Subject: Doc: Modularized the Qt Sensor Docs Change-Id: Ie8636ec443f43b1f238342e0f6f7d321e13dce09 Reviewed-by: Jerome Pasion --- examples/sensors/accel/accel.pro | 9 -- examples/sensors/accel/main.cpp | 77 ---------- .../sensors/accelbubble/doc/src/accelbubble.qdoc | 54 +++++++ examples/sensors/cubehouse/doc/src/cubehouse.qdoc | 60 ++++++++ examples/sensors/grue/doc/src/grue.qdoc | 162 +++++++++++++++++++++ examples/sensors/maze/doc/src/maze.qdoc | 67 +++++++++ .../sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc | 70 +++++++++ .../doc/src/qmlsensorgtestures.qdoc | 63 ++++++++ .../sensor_explorer/doc/src/sensor_explorer.qdoc | 91 ++++++++++++ .../sensorgestures/doc/images/sensorgesturecpp.png | Bin 0 -> 33013 bytes .../sensorgestures/doc/src/sensorgestures.qdoc | 67 +++++++++ examples/sensors/sensors.pro | 2 +- examples/sensors/shakeit/doc/images/shakeit.png | Bin 0 -> 29380 bytes examples/sensors/shakeit/doc/src/shakeit.qdoc | 64 ++++++++ 14 files changed, 699 insertions(+), 87 deletions(-) delete mode 100644 examples/sensors/accel/accel.pro delete mode 100644 examples/sensors/accel/main.cpp create mode 100644 examples/sensors/accelbubble/doc/src/accelbubble.qdoc create mode 100644 examples/sensors/cubehouse/doc/src/cubehouse.qdoc create mode 100644 examples/sensors/grue/doc/src/grue.qdoc create mode 100644 examples/sensors/maze/doc/src/maze.qdoc create mode 100644 examples/sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc create mode 100644 examples/sensors/qmlsensorgestures/doc/src/qmlsensorgtestures.qdoc create mode 100644 examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc create mode 100644 examples/sensors/sensorgestures/doc/images/sensorgesturecpp.png create mode 100644 examples/sensors/sensorgestures/doc/src/sensorgestures.qdoc create mode 100644 examples/sensors/shakeit/doc/images/shakeit.png create mode 100644 examples/sensors/shakeit/doc/src/shakeit.qdoc (limited to 'examples') diff --git a/examples/sensors/accel/accel.pro b/examples/sensors/accel/accel.pro deleted file mode 100644 index 82fa706b..00000000 --- a/examples/sensors/accel/accel.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE=app -TARGET=accel - -QT=core sensors - -SOURCES=main.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/qtsensors/accel -INSTALLS += target diff --git a/examples/sensors/accel/main.cpp b/examples/sensors/accel/main.cpp deleted file mode 100644 index 29855363..00000000 --- a/examples/sensors/accel/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -QAccelerometer *accelerometer; - -class AccelerometerFilter : public QAccelerometerFilter -{ -public: - bool filter(QAccelerometerReading *reading) - { - qDebug() << "acceleration: " - << QString().sprintf("%0.2f %0.2f %0.2f", - reading->x(), - reading->y(), - reading->z()); - return false; // don't store the reading in the sensor - } -}; - -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - - QAccelerometer sensor; - accelerometer = &sensor; - AccelerometerFilter filter; - sensor.addFilter(&filter); - sensor.start(); - - if (!sensor.isActive()) { - qWarning("Accelerometer didn't start!"); - return 1; - } - - return app.exec(); -} - diff --git a/examples/sensors/accelbubble/doc/src/accelbubble.qdoc b/examples/sensors/accelbubble/doc/src/accelbubble.qdoc new file mode 100644 index 00000000..83c5d3dc --- /dev/null +++ b/examples/sensors/accelbubble/doc/src/accelbubble.qdoc @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example accelbubble + \title Qt Sensors - Accel Bubble + \brief The AccelBubble example demonstrates the Legacy Accelerometer QML type. + \ingroup qtsensors-examples + +\section1 Overview + Writing a QML application that uses the Legacy Accelerometer QML sensors type requires the following steps: + + Import the Legacy Sensors Declarative module. + +\snippet accelbubble/accelbubble.qml 0 + + Add an Accelerometer QML type. + +\snippet accelbubble/accelbubble.qml 1 + + Use the 'active' property to start the sensor + +\snippet accelbubble/accelbubble.qml 2 + + Move the bubble according to a factor of the accelerator sensor + +\snippet accelbubble/accelbubble.qml 3 + +*/ + diff --git a/examples/sensors/cubehouse/doc/src/cubehouse.qdoc b/examples/sensors/cubehouse/doc/src/cubehouse.qdoc new file mode 100644 index 00000000..e286e32e --- /dev/null +++ b/examples/sensors/cubehouse/doc/src/cubehouse.qdoc @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example cubehouse + \title Qt Sensors - Cube House QML Accelerometer example + \ingroup qtsensors-examples + \brief The Cube House example demonstrates the use of the accelerometer to drive a camera to create a pseudo-3D effect. + \image cubehouse.png + +\section1 Overview + To write a QML application that will use the QML Accelerometer type from the QtSensors import you need to to the following steps: + + Import the QtSensors declarative plugin: + +\snippet cubehouse/cubehouse.qml 0 + + Add the Accelerometer QML types into your qml file. + +\snippet cubehouse/cubehouse.qml 1 + + In additional two properties are added to save the calculated pitch and roll values: + +\snippet cubehouse/cubehouse.qml 2 + + Reading out the Accelerometer data can be done by implementing the 'onReadingChanged' slot and + accessing the 'reading' property from the Accelerometer type: + +\snippet cubehouse/cubehouse.qml 3 + + By using a timer the view can be rotated using the pitch and roll properties from the Accelerometer type: + +\snippet cubehouse/cubehouse.qml 4 + +*/ + diff --git a/examples/sensors/grue/doc/src/grue.qdoc b/examples/sensors/grue/doc/src/grue.qdoc new file mode 100644 index 00000000..9a0d4472 --- /dev/null +++ b/examples/sensors/grue/doc/src/grue.qdoc @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page gruesensorexample.html + \title Qt Sensors - Grue Sensor Example + \brief The Qt Sensors - Grue sensor example demonstrates all the steps from creating a new sensor to using it. + \ingroup qtsensors-examples + + The Qt Sensors - Grue sensor example demonstrates all the steps from creating a new sensor to using it. + + The sensor definition is placed in a library where client apps can access it. The actual implementation + lives in a plugin. + + \list + \li \l{Grue Sensor Definition} + \li \l{Grue Sensor Implementation} + \endlist + + The sensor can now be used by a C++ application, even if the application does not have access to the + definition. + + \list + \li \l{Grue Sensor Console Application} + \endlist + + To make the sensor available to a QML application an import must be created. + + \list + \li \l{Grue Sensor QML Import} + \li \l{Grue Sensor QML Application} + \endlist +*/ + +/*! + \example grue/lib + \title Grue Sensor Definition + \brief The Grue sensor is defined in a library so that applications can use it. + + First up is the sensor type. This is the interface for sensors that report + on your likelihood of being eaten by a Grue. Such sensors are very important + to adventurers, particularly if they are going into dark places as this is + where Grues live. + + The interface is a simple one. It provides only 1 piece of information, your + chance of being eaten. For the details on how this is property should be + interpreted please see the documentation in gruesensor.cpp. + + This example was created using the make_sensor.pl script which can be found in + src/sensors. As such, it contains some generated code that defines the convenience + classes GrueFilter and GrueSensor. + + \sa {Qt Sensors - Grue Sensor Example} +*/ + +/*! + \example grue/plugin + \title Grue Sensor Implementation + \brief The Grue sensor implementation lives in a plugin that is loaded by the Qt Sensors library. + + The Grue sensor needs a backend before it can be used. The backend provided + is rather basic and it relies on some kind of light sensor to work but it + gets the job done. If new hardware that can detect the actual presence of Grues + becomes available a backend could be created that supports this hardware and + applications using the Grue sensor would be able to use it without any changes. + + There are a few mandatory parts to a backend. They are the start and stop methods + and the setReading call. The start and stop methods are used to start and stop + any underlying hardware. In the case of this backend they start and stop a + light sensor. In the start method, the backend should be sure to call the + sensorStopped() or sensorBusy() methods if it cannot start. + + \snippet grue/plugin/gruesensorimpl.cpp start + + The setReading method is needed so that the sensors library knows where the + readings are coming from. This backend has a local copy of the reading so + it passes a pointer to the function. + + \snippet grue/plugin/gruesensorimpl.cpp setReading + + However it is also possible to pass null to the setReading method in which + case the sensors library will create an instance and return a pointer. + + \code + // Create a reading instance for us to use + m_reading = setReading(0); + \endcode + + The Grue sensor backend also supplies some metadata. + + The backend checks 2 things, how dark it is and how long you have been in the dark. + It uses the readingChanged() signal to know when to check the light sensor's + value. Once it is dark, it uses a timer to increase your chance of being eaten. + + The Grue sensor backend is delivered as a plugin. The plugin has a factory object + that registers the types available and does the actual instantiation of the backend. + + \sa {Qt Sensors - Grue Sensor Example} +*/ + +/*! + \example grue/console_app + \title Grue Sensor Console Application + \brief The Grue sensor console application demonstrates use of the Grue sensor. + + This is a simple commandline application. It demonstrates how to use the generic + access feature of Qt Sensors to avoid a link-time dependency on the Grue Sensor + library. + + \sa {Qt Sensors - Grue Sensor Example} +*/ + +/*! + \example grue/import + \title Grue Sensor QML Import + \brief The Grue sensor QML import exports the GrueSensor class as a QML type. + + This example creates the \e {Grue 1.0} import. + + \sa {Qt Sensors - Grue Sensor Example} +*/ + +/*! + \example grue + \title Grue Sensor QML Application + \brief The Grue sensor QML application demonstrates use of the GrueSensor QML type. + + This is a pure QML application that can be run from Qt Creator or directly using the + \c qmlscene binary. You should install the other projects before trying to run + this example or it will not be able to find its dependencies. + + \code + qmlscene grue.qml + \endcode + + \sa {Qt Sensors - Grue Sensor Example} +*/ + diff --git a/examples/sensors/maze/doc/src/maze.qdoc b/examples/sensors/maze/doc/src/maze.qdoc new file mode 100644 index 00000000..d9b50beb --- /dev/null +++ b/examples/sensors/maze/doc/src/maze.qdoc @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example maze + \title Qt Sensors - Maze QML Example + \ingroup qtsensors-examples + \image maze.png + + \section2 Maze in QML + \brief The Maze example demonstrates the TiltSensor QML type. + + + To write a QML application that will use the TiltSensor QML sensors type you need to do the following steps: + + Import the QtSensors 5.x declarative plugin: + + \snippet maze/maze.qml 0 + + Add the Sensor QML types into your qml file. + + In this example we use the TiltSensor with values based in degrees and an accuracy of 5 degree: + + \snippet maze/maze.qml 1 + + Starting the sensor can be done by setting the 'enabled' property to true: + + \snippet maze/maze.qml 2 + + The mouse should move by a factor of the tilt value: + + \snippet maze/maze.qml 3 + + The walk direction of the mouse takes into account some collision detection: + + \snippet maze/maze.qml 4 + + The rotation of the mouse image is determined according to the angle that the mouse is moving. + + \snippet maze/Mouse.qml 0 + +*/ + diff --git a/examples/sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc b/examples/sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc new file mode 100644 index 00000000..f6b4738c --- /dev/null +++ b/examples/sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example qmlqtsensors + \title Qt Sensors - QML example + \ingroup qtsensors-examples + \image qmlqtsensors.png + + \section2 Qt Sensors in QML + \brief The QtSensors - QML example demonstrates the QML sensors types in the QtSensors 5 import. + + + To write a QML application that will use the QML sensors types in the QtSensors 5 import you need to to the following steps: + + Import the QtSensors 5.x declarative plugin: + + \snippet qmlqtsensors/qmlqtsensors.qml 0 + + Add the Sensor QML types into your qml file. + + In this example we use the TiltSensor: + + \snippet qmlqtsensors/qmlqtsensors.qml 1 + + The Tilt-, AmbientLight- and the Proximity QML sensor types have the 'enabled' property in common. + To start or stop the sensor set this property to true or false. + + \snippet qmlqtsensors/qmlqtsensors.qml 2 + + Reading the data can be done for each sensor type like following: + + \l {QtSensors::TiltSensor} {TiltSensor} + + \snippet qmlqtsensors/qmlqtsensors.qml 3 + \snippet qmlqtsensors/qmlqtsensors.qml 4 + + \l {QtSensors::AmbientLightSensor} {AmbientLightSensor} + + \snippet qmlqtsensors/qmlqtsensors.qml 5 + + \l {QtSensors::ProximitySensor} {ProximitySensor} + + \snippet qmlqtsensors/qmlqtsensors.qml 6 +*/ + diff --git a/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgtestures.qdoc b/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgtestures.qdoc new file mode 100644 index 00000000..83f3171d --- /dev/null +++ b/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgtestures.qdoc @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example qmlsensorgestures + \title Qt Sensors - SensorGesture QML Type example + \ingroup qtsensors-examples + + \brief This example demonstrates use of the SensorGesture QML type. + +\section1 Overview + To write a QML application that will use the gesture plugin you need to to the following steps: + + Import the QtSensors 5.x declarative plugin: + +\snippet qmlsensorgestures/GestureView.qml 0 + + Add the SensorGesture QML type into your qml file. + +\snippet qmlsensorgestures/GestureView.qml 1 + + Each SensorGesture QML type contains a property called gestures. + + In this example an alias 'gestureid' for this property is used. + +\snippet qmlsensorgestures/GestureView.qml 2 + + By using this alias property you define which gestures should be used: + +\snippet qmlsensorgestures/qmlsensorgestures.qml 3 + + A list of all available gestures can be created by calling the 'availableGestures' property: + +\snippet qmlsensorgestures/GestureList.qml 4 + +\sa {Qt Sensors - ShakeIt QML Example} +\sa {Qt Sensor Gestures} +*/ + diff --git a/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc b/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc new file mode 100644 index 00000000..be042156 --- /dev/null +++ b/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example sensor_explorer + \title Qt Sensors - Explorer QML example + \ingroup qtsensors-examples + + \section2 Sensor Explorer in QML + \brief The Sensor Explorer example demonstrates how to read the meta-data of available sensors. + + + This example is divided into two parts: + + \list + \li A \l{Sensor Explorer QML Import}{C++ plug-in} that provides QML alternatives for QSensorExplorer, QPropertyInfo and the QSensorItem classes. + \li A QML Application that uses the QML alternatives to read the sensors meta-data and present it. + \endlist + + + This is a pure QML application that can be run from Qt Creator or directly using the + \c qmlscene binary. You should install the other C++ plug-in before trying to run + this example, otherwise it will not find its dependencies. + + \code + qmlscene main.qml + \endcode + + To write a QML application that will use the Explorer QML type you need to do the following steps: + + Import the Explorer 1.0 declarative plugin: + + \snippet sensor_explorer/sensor_explorer.qml 0 + + Create a SensorExplorer QML item: + + \snippet sensor_explorer/sensor_explorer.qml 1 + + You can retrieve a list of all available sensors using the SensorExplorer: + + \snippet sensor_explorer/sensor_explorer.qml 2 + + To retrieve the properties of a SensorItem use: + + \snippet sensor_explorer/sensor_explorer.qml 3 + + Changing a property value can be done like: + + \snippet sensor_explorer/sensor_explorer.qml 4 + + Starting and stopping a sensor can be done like: + + \snippet sensor_explorer/sensor_explorer.qml 5 +*/ + +/*! + \example sensor_explorer/import + \title Sensor Explorer QML Import + + \section2 Sensor Explorer Declarative Plugin + \brief The Sensor Explorer QML import exports the QSensorExplorer, QPropertyInfo and the QSensorItem class as a QML type. + + This example creates the \e {Explorer 1.0} import. + + \sa {Qt Sensors - Explorer QML example} +*/ + diff --git a/examples/sensors/sensorgestures/doc/images/sensorgesturecpp.png b/examples/sensors/sensorgestures/doc/images/sensorgesturecpp.png new file mode 100644 index 00000000..4d453cf2 Binary files /dev/null and b/examples/sensors/sensorgestures/doc/images/sensorgesturecpp.png differ diff --git a/examples/sensors/sensorgestures/doc/src/sensorgestures.qdoc b/examples/sensors/sensorgestures/doc/src/sensorgestures.qdoc new file mode 100644 index 00000000..a5c96cb5 --- /dev/null +++ b/examples/sensors/sensorgestures/doc/src/sensorgestures.qdoc @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example sensorgestures + \title Qt Sensors - C++ Sensor Gestures Example + \ingroup qtsensors-examples + \brief The sensor gesture example demonstrates the steps for creating a C++ application + that uses sensor gestures and the included shake sensor. + \image sensorgesturecpp.png + + QSensorGestures class defines one predefined signal, \c { void detected(const QString &) } + + As well, Sensor Gesture Recognizers may implement any number of their own custom signals. + + Our shake recognizer defines one custom signal, \c {void shake()}, as well as the predefined + detected signal. + + \section1 SensorGestures Class Implementation + + In order to know about custom signals that may be available, we need to ask the QSensorGestureManager about them, + + Using the QSensorGesture::gestureIds() function, the manager will return a QStringList of known and valid gesture Ids. + \snippet sensorgestures/mainwindow.cpp 0 + + We can then use this to create a QSensorGesture object that we can use to connect signals to, + and start the detection process. A QSensorGesture object will take a list of one or more + recognizer ids in it's constructor. + + \snippet sensorgestures/mainwindow.cpp 1 + + and later stop the detection process. + + \snippet sensorgestures/mainwindow.cpp 2 + + The QSensorGesture object will contain all the signals of the valid requested recognizers found on the system. + + You can discover which of the requested recognizer ID's that were not found by using QSensorGesture::invalidIds(); + + By using QSensorGesture::gestureSignals(), you can get a QStringList of usable signals. + + +*/ diff --git a/examples/sensors/sensors.pro b/examples/sensors/sensors.pro index 7fe9a092..f98b4c15 100644 --- a/examples/sensors/sensors.pro +++ b/examples/sensors/sensors.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -SUBDIRS += accel grue +SUBDIRS += grue !isEmpty(QT.quick.name) { SUBDIRS += \ diff --git a/examples/sensors/shakeit/doc/images/shakeit.png b/examples/sensors/shakeit/doc/images/shakeit.png new file mode 100644 index 00000000..5ca1b58c Binary files /dev/null and b/examples/sensors/shakeit/doc/images/shakeit.png differ diff --git a/examples/sensors/shakeit/doc/src/shakeit.qdoc b/examples/sensors/shakeit/doc/src/shakeit.qdoc new file mode 100644 index 00000000..8f5931fd --- /dev/null +++ b/examples/sensors/shakeit/doc/src/shakeit.qdoc @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example shakeit + \title Qt Sensors - ShakeIt QML Example + \ingroup qtsensors-examples + \image shakeit.png + + \section2 ShakeIt in QML + \brief The sensor gesture example demonstrates the steps for creating a QML application + that uses sensor gestures and the included shake sensor. + + Writing a QML application that uses the Shake QML sensorgestures type requires the following steps: + + Import the Sensors Declarative module. + + \snippet shakeit/shakeit.qml 0 + + Add a SensorGesture QML type. + + \snippet shakeit/shakeit.qml 1 + + In the SensorGesture type, specify which gesture to be used. + Note that this can be a comma separated list. Here we are only interested in one + gesture recognizer. + + \snippet shakeit/shakeit.qml 2 + + Use the 'enabled' property to start the sensor gesture. + + \snippet shakeit/shakeit.qml 3 + + Use the onDetected signal to do stuff. + + \snippet shakeit/shakeit.qml 4 + + There are additional gestures to shake which are supported: + whip, twistRight, hover, cover, turnover and pickup. +*/ -- cgit v1.2.3