summaryrefslogtreecommitdiffstats
path: root/examples/sensors/grue
diff options
context:
space:
mode:
authorLincoln Ramsay <lincoln.ramsay@nokia.com>2012-06-19 15:47:09 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-20 01:56:15 +0200
commitb2e97817684f40ab9353fa279a4c02ef9c12e13d (patch)
treeb7c7114b555539de9e1bc5a1bd1ed5afeed777bb /examples/sensors/grue
parent5e89b386f4aae5a4953c725b6aab565b21a3330f (diff)
Remove the 'special' naming of examples.
Just go back to the naming convention we had before. Change-Id: Iefecb7a5e0ab3aa4d22267b4f475a8e9c1c96058 Reviewed-by: Lorn Potter <lorn.potter@nokia.com>
Diffstat (limited to 'examples/sensors/grue')
-rw-r--r--examples/sensors/grue/console_app/console_app.pro6
-rw-r--r--examples/sensors/grue/console_app/main.cpp89
-rw-r--r--examples/sensors/grue/grue.pngbin0 -> 11207 bytes
-rw-r--r--examples/sensors/grue/grue.pro8
-rw-r--r--examples/sensors/grue/grue.qml95
-rw-r--r--examples/sensors/grue/grue.xcfbin0 -> 23704 bytes
-rw-r--r--examples/sensors/grue/icon.pngbin0 -> 7951 bytes
-rw-r--r--examples/sensors/grue/icon.xcfbin0 -> 22397 bytes
-rw-r--r--examples/sensors/grue/import/import.pro33
-rw-r--r--examples/sensors/grue/import/main.cpp142
-rw-r--r--examples/sensors/grue/import/plugin.json1
-rw-r--r--examples/sensors/grue/import/qmldir1
-rw-r--r--examples/sensors/grue/info.json14
-rw-r--r--examples/sensors/grue/lib/gruesensor.cpp137
-rw-r--r--examples/sensors/grue/lib/gruesensor.h85
-rw-r--r--examples/sensors/grue/lib/gruesensor_p.h66
-rw-r--r--examples/sensors/grue/lib/lib.pro27
-rw-r--r--examples/sensors/grue/plugin/gruesensorimpl.cpp140
-rw-r--r--examples/sensors/grue/plugin/gruesensorimpl.h77
-rw-r--r--examples/sensors/grue/plugin/main.cpp81
-rw-r--r--examples/sensors/grue/plugin/plugin.json1
-rw-r--r--examples/sensors/grue/plugin/plugin.pro27
-rw-r--r--examples/sensors/grue/qml.pro15
23 files changed, 1045 insertions, 0 deletions
diff --git a/examples/sensors/grue/console_app/console_app.pro b/examples/sensors/grue/console_app/console_app.pro
new file mode 100644
index 00000000..33d43176
--- /dev/null
+++ b/examples/sensors/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/sensors/grue/console_app/main.cpp b/examples/sensors/grue/console_app/main.cpp
new file mode 100644
index 00000000..dc62e4de
--- /dev/null
+++ b/examples/sensors/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/sensors/grue/grue.png b/examples/sensors/grue/grue.png
new file mode 100644
index 00000000..f0b070b4
--- /dev/null
+++ b/examples/sensors/grue/grue.png
Binary files differ
diff --git a/examples/sensors/grue/grue.pro b/examples/sensors/grue/grue.pro
new file mode 100644
index 00000000..de917bf7
--- /dev/null
+++ b/examples/sensors/grue/grue.pro
@@ -0,0 +1,8 @@
+TEMPLATE = subdirs
+
+SUBDIRS += lib plugin console_app
+SUBDIRS += import qml.pro
+
+plugin.depends = lib
+import.depends = lib
+
diff --git a/examples/sensors/grue/grue.qml b/examples/sensors/grue/grue.qml
new file mode 100644
index 00000000..05d267c7
--- /dev/null
+++ b/examples/sensors/grue/grue.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtSensors module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtMobility.sensors 1.3
+import Grue 1.0
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "black"
+
+ GrueSensor {
+ id: sensor
+ active: true
+ onReadingChanged: {
+ var percent = reading.chanceOfBeingEaten;
+ var thetext = "";
+ var theopacity = 0;
+ if (percent === 0) {
+ thetext = "It is light. You are safe from Grues.";
+ }
+ else if (percent === 100) {
+ thetext = "You have been eaten by a Grue!";
+ sensor.active = false;
+ theopacity = 1;
+ }
+ else if (percent > 0) {
+ thetext = "It is dark. You are likely to be eaten by a Grue. "
+ + "Your chance of being eaten by a Grue: "+percent+" percent.";
+ theopacity = 0.05 + (percent * 0.001);
+ }
+ text.font.pixelSize = 30;
+ text.text = "<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/sensors/grue/grue.xcf b/examples/sensors/grue/grue.xcf
new file mode 100644
index 00000000..2837ed7e
--- /dev/null
+++ b/examples/sensors/grue/grue.xcf
Binary files differ
diff --git a/examples/sensors/grue/icon.png b/examples/sensors/grue/icon.png
new file mode 100644
index 00000000..f3f038c7
--- /dev/null
+++ b/examples/sensors/grue/icon.png
Binary files differ
diff --git a/examples/sensors/grue/icon.xcf b/examples/sensors/grue/icon.xcf
new file mode 100644
index 00000000..8416c49f
--- /dev/null
+++ b/examples/sensors/grue/icon.xcf
Binary files differ
diff --git a/examples/sensors/grue/import/import.pro b/examples/sensors/grue/import/import.pro
new file mode 100644
index 00000000..753e1ef8
--- /dev/null
+++ b/examples/sensors/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/sensors/grue/import/main.cpp b/examples/sensors/grue/import/main.cpp
new file mode 100644
index 00000000..d8a6d5ab
--- /dev/null
+++ b/examples/sensors/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 type reports on your chance of being eaten by a Grue.
+
+ The GrueSensor type reports on your chance of being eaten by a Grue.
+
+ This type 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 type holds the most recent GrueSensor reading.
+
+ The GrueSensorReading type holds the most recent GrueSensor reading.
+
+ This type wraps the GrueSensorReading class. Please see the documentation for
+ GrueSensorReading for details.
+
+ This type cannot be directly created.
+*/
+
+/*
+ \qmlproperty qreal Grue1::GrueSensorReading::chanceOfBeingEaten
+ Please see GrueSensorReading::chanceOfBeingEaten for information about this property.
+*/
diff --git a/examples/sensors/grue/import/plugin.json b/examples/sensors/grue/import/plugin.json
new file mode 100644
index 00000000..0967ef42
--- /dev/null
+++ b/examples/sensors/grue/import/plugin.json
@@ -0,0 +1 @@
+{}
diff --git a/examples/sensors/grue/import/qmldir b/examples/sensors/grue/import/qmldir
new file mode 100644
index 00000000..266b7c11
--- /dev/null
+++ b/examples/sensors/grue/import/qmldir
@@ -0,0 +1 @@
+plugin declarative_grue
diff --git a/examples/sensors/grue/info.json b/examples/sensors/grue/info.json
new file mode 100644
index 00000000..75129054
--- /dev/null
+++ b/examples/sensors/grue/info.json
@@ -0,0 +1,14 @@
+{
+ "info-version": "1.0",
+ "dict": {
+ "displayName": {
+ "en_US": "Grue Sensor"
+ },
+ "identifier": "com.nokia.mt.grue",
+ "runtime": "qml",
+ "main": "QtSensors_grue.qml",
+ "version": "1.0.0",
+ "category": "application",
+ "subcategory": "utility"
+ }
+}
diff --git a/examples/sensors/grue/lib/gruesensor.cpp b/examples/sensors/grue/lib/gruesensor.cpp
new file mode 100644
index 00000000..b1f00ede
--- /dev/null
+++ b/examples/sensors/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/sensors/grue/lib/gruesensor.h b/examples/sensors/grue/lib/gruesensor.h
new file mode 100644
index 00000000..8088988d
--- /dev/null
+++ b/examples/sensors/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/sensors/grue/lib/gruesensor_p.h b/examples/sensors/grue/lib/gruesensor_p.h
new file mode 100644
index 00000000..4996e868
--- /dev/null
+++ b/examples/sensors/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/sensors/grue/lib/lib.pro b/examples/sensors/grue/lib/lib.pro
new file mode 100644
index 00000000..e048e607
--- /dev/null
+++ b/examples/sensors/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/sensors/grue/plugin/gruesensorimpl.cpp b/examples/sensors/grue/plugin/gruesensorimpl.cpp
new file mode 100644
index 00000000..e7152a67
--- /dev/null
+++ b/examples/sensors/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/sensors/grue/plugin/gruesensorimpl.h b/examples/sensors/grue/plugin/gruesensorimpl.h
new file mode 100644
index 00000000..ed89711d
--- /dev/null
+++ b/examples/sensors/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/sensors/grue/plugin/main.cpp b/examples/sensors/grue/plugin/main.cpp
new file mode 100644
index 00000000..36aec298
--- /dev/null
+++ b/examples/sensors/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/sensors/grue/plugin/plugin.json b/examples/sensors/grue/plugin/plugin.json
new file mode 100644
index 00000000..8a55b3ae
--- /dev/null
+++ b/examples/sensors/grue/plugin/plugin.json
@@ -0,0 +1 @@
+{ "Keys": [ "notused" ] }
diff --git a/examples/sensors/grue/plugin/plugin.pro b/examples/sensors/grue/plugin/plugin.pro
new file mode 100644
index 00000000..32e127f1
--- /dev/null
+++ b/examples/sensors/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/sensors/grue/qml.pro b/examples/sensors/grue/qml.pro
new file mode 100644
index 00000000..e3d021e0
--- /dev/null
+++ b/examples/sensors/grue/qml.pro
@@ -0,0 +1,15 @@
+TEMPLATE = aux
+
+app.files = \
+ icon.png \
+ info.json \
+ $$files(*.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
+}
+