diff options
Diffstat (limited to 'examples/sensors/grue')
23 files changed, 0 insertions, 1043 deletions
diff --git a/examples/sensors/grue/console_app/console_app.pro b/examples/sensors/grue/console_app/console_app.pro deleted file mode 100644 index 33d43176..00000000 --- a/examples/sensors/grue/console_app/console_app.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE=app -TARGET=detect_grue -CONFIG += console -QT=core sensors -SOURCES=main.cpp - diff --git a/examples/sensors/grue/console_app/main.cpp b/examples/sensors/grue/console_app/main.cpp deleted file mode 100644 index dc62e4de..00000000 --- a/examples/sensors/grue/console_app/main.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <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.pro b/examples/sensors/grue/grue.pro deleted file mode 100644 index 0405286d..00000000 --- a/examples/sensors/grue/grue.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += lib plugin console_app -SUBDIRS += import qml_app - -plugin.depends = lib -import.depends = lib - diff --git a/examples/sensors/grue/import/import.pro b/examples/sensors/grue/import/import.pro deleted file mode 100644 index 753e1ef8..00000000 --- a/examples/sensors/grue/import/import.pro +++ /dev/null @@ -1,33 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin - -TARGET = $$qtLibraryTarget(declarative_grue) -TARGETPATH = Grue - -QT = core gui qml sensors - -INCLUDEPATH += $$PWD/../lib -LIBS += -L$$OUT_PWD/../lib -lgruesensor - -SOURCES = main.cpp - -MT_SYSROOT=$$(MT_SYSROOT) -!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications -!isEmpty(EXAMPLES_PREFIX):DESTPATH=$$EXAMPLES_PREFIX/com.nokia.mt.grue/imports/Grue -else:DESTPATH=$$[QT_INSTALL_IMPORTS]/Grue - -target.path=$$DESTPATH -INSTALLS += target - -qmldir.files=$$PWD/qmldir -qmldir.path=$$DESTPATH -INSTALLS += qmldir - -OTHER_FILES += \ - plugin.json qmldir - -!isEmpty(EXAMPLES_PREFIX) { - QMAKE_LFLAGS += -Wl,-rpath,$$EXAMPLES_PREFIX/com.nokia.mt.grue/lib - DEFINES += "BUNDLED_PLUGIN=\\\"$$EXAMPLES_PREFIX/com.nokia.mt.grue/plugins/sensors/libqtsensors_grue.so\\\"" -} - diff --git a/examples/sensors/grue/import/main.cpp b/examples/sensors/grue/import/main.cpp deleted file mode 100644 index 6c327032..00000000 --- a/examples/sensors/grue/import/main.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <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/sensors/grue/import/plugin.json b/examples/sensors/grue/import/plugin.json deleted file mode 100644 index 0967ef42..00000000 --- a/examples/sensors/grue/import/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/sensors/grue/import/qmldir b/examples/sensors/grue/import/qmldir deleted file mode 100644 index 266b7c11..00000000 --- a/examples/sensors/grue/import/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin declarative_grue diff --git a/examples/sensors/grue/lib/gruesensor.cpp b/examples/sensors/grue/lib/gruesensor.cpp deleted file mode 100644 index b1f00ede..00000000 --- a/examples/sensors/grue/lib/gruesensor.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "gruesensor.h" -#include "gruesensor_p.h" - -IMPLEMENT_READING(GrueSensorReading) - -/* - \class GrueSensorReading - - \brief The GrueSensorReading class holds readings from the Grue sensor. - - The Grue Sensor informs you of your chance of being eaten by a Grue. - - Grues love the dark so as long as your surroundings are relatively light - you are safe. However the more time you spend in the dark, the higher - your chances are of being eaten by a Grue. -*/ - -/* - \property GrueSensorReading::chanceOfBeingEaten - \brief holds your chance of being eaten. - - The value is the probability (from 0 to 100) that a Grue will eat you. - A probability of 100 means you are currently being eaten. The darker - it is, the more likely you are to be eaten by a Grue. The longer you - stay in a dark area, the more likely you are to be eaten by a Grue. - If you are in a lit room, the probability will be 0 as Grues fear light. -*/ - -int GrueSensorReading::chanceOfBeingEaten() const -{ - return d->chanceOfBeingEaten; -} - -void GrueSensorReading::setChanceOfBeingEaten(int chanceOfBeingEaten) -{ - d->chanceOfBeingEaten = chanceOfBeingEaten; -} - -// ===================================================================== - -// begin generated code - -/* - \class GrueFilter - - \brief The GrueFilter class is a convenience wrapper around QSensorFilter. - - The only difference is that the filter() method features a pointer to GrueSensorReading - instead of QSensorReading. -*/ - -/* - \fn GrueFilter::filter(GrueSensorReading *reading) - - Called when \a reading changes. Returns false to prevent the reading from propagating. - - \sa QSensorFilter::filter() -*/ - -char const * const GrueSensor::type("GrueSensor"); - -/* - \class GrueSensor - - \brief The GrueSensor class is a convenience wrapper around QSensor. - - The only behavioural difference is that this class sets the type properly. - - This class also features a reading() function that returns a GrueSensorReading instead of a QSensorReading. - - For details about how the sensor works, see \l GrueSensorReading. - - \sa GrueSensorReading -*/ - -/* - \fn GrueSensor::GrueSensor(QObject *parent) - - Construct the sensor as a child of \a parent. -*/ - -/* - \fn GrueSensor::~GrueSensor() - - Destroy the sensor. Stops the sensor if it has not already been stopped. -*/ - -/* - \fn GrueSensor::reading() const - - Returns the reading class for this sensor. - - \sa QSensor::reading() -*/ -// end generated code - -#include "moc_gruesensor.cpp" diff --git a/examples/sensors/grue/lib/gruesensor.h b/examples/sensors/grue/lib/gruesensor.h deleted file mode 100644 index 8088988d..00000000 --- a/examples/sensors/grue/lib/gruesensor.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRUESENSOR_H -#define GRUESENSOR_H - -#include <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 deleted file mode 100644 index 4996e868..00000000 --- a/examples/sensors/grue/lib/gruesensor_p.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRUESENSOR_P_H -#define GRUESENSOR_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -class GrueSensorReadingPrivate -{ -public: - GrueSensorReadingPrivate() - : chanceOfBeingEaten(-1) - { - } - - int chanceOfBeingEaten; -}; - -#endif diff --git a/examples/sensors/grue/lib/lib.pro b/examples/sensors/grue/lib/lib.pro deleted file mode 100644 index e048e607..00000000 --- a/examples/sensors/grue/lib/lib.pro +++ /dev/null @@ -1,27 +0,0 @@ -TEMPLATE = lib -TARGET = gruesensor - -# avoid going to release/debug subdirectory -win32:DESTDIR = $$OUT_PWD - -DEFINES *= QT_BUILD_GRUE_LIB -QT = core sensors - -HEADERS += gruesensor.h\ - gruesensor_p.h\ - -SOURCES += gruesensor.cpp\ - -target.path=$$[QT_INSTALL_LIBS] -INSTALLS += target - -MT_SYSROOT=$$(MT_SYSROOT) -!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications -!isEmpty(EXAMPLES_PREFIX) { - target.path = $$EXAMPLES_PREFIX/com.nokia.mt.grue/lib - remove_so.commands = "rm $(INSTALL_ROOT)$${target.path}/lib$${TARGET}.so" - remove_so.CONFIG = no_path - remove_so.depends = install_target - INSTALLS += remove_so -} - diff --git a/examples/sensors/grue/plugin/gruesensorimpl.cpp b/examples/sensors/grue/plugin/gruesensorimpl.cpp deleted file mode 100644 index e7152a67..00000000 --- a/examples/sensors/grue/plugin/gruesensorimpl.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "gruesensorimpl.h" -#include <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 deleted file mode 100644 index ed89711d..00000000 --- a/examples/sensors/grue/plugin/gruesensorimpl.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRUESENSORIMPL_H -#define GRUESENSORIMPL_H - -#include <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 deleted file mode 100644 index 36aec298..00000000 --- a/examples/sensors/grue/plugin/main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "gruesensorimpl.h" -#include <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 deleted file mode 100644 index 8a55b3ae..00000000 --- a/examples/sensors/grue/plugin/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "notused" ] } diff --git a/examples/sensors/grue/plugin/plugin.pro b/examples/sensors/grue/plugin/plugin.pro deleted file mode 100644 index 32e127f1..00000000 --- a/examples/sensors/grue/plugin/plugin.pro +++ /dev/null @@ -1,27 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin -TARGET = $$qtLibraryTarget(qtsensors_grue) -PLUGIN_TYPE = sensors - -QT = core sensors - -INCLUDEPATH += $$PWD/../lib -LIBS += -L$$OUT_PWD/../lib -lgruesensor - -HEADERS += gruesensorimpl.h\ - -SOURCES += gruesensorimpl.cpp\ - main.cpp\ - -target.path=$$[QT_INSTALL_PLUGINS]/sensors -INSTALLS += target - -OTHER_FILES += \ - plugin.json - -MT_SYSROOT=$$(MT_SYSROOT) -!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications -!isEmpty(EXAMPLES_PREFIX) { - target.path = $$EXAMPLES_PREFIX/com.nokia.mt.grue/plugins/sensors -} - diff --git a/examples/sensors/grue/qml_app/grue.png b/examples/sensors/grue/qml_app/grue.png Binary files differdeleted file mode 100644 index f0b070b4..00000000 --- a/examples/sensors/grue/qml_app/grue.png +++ /dev/null diff --git a/examples/sensors/grue/qml_app/grue.xcf b/examples/sensors/grue/qml_app/grue.xcf Binary files differdeleted file mode 100644 index 2837ed7e..00000000 --- a/examples/sensors/grue/qml_app/grue.xcf +++ /dev/null diff --git a/examples/sensors/grue/qml_app/icon.png b/examples/sensors/grue/qml_app/icon.png Binary files differdeleted file mode 100644 index f3f038c7..00000000 --- a/examples/sensors/grue/qml_app/icon.png +++ /dev/null diff --git a/examples/sensors/grue/qml_app/icon.xcf b/examples/sensors/grue/qml_app/icon.xcf Binary files differdeleted file mode 100644 index 8416c49f..00000000 --- a/examples/sensors/grue/qml_app/icon.xcf +++ /dev/null diff --git a/examples/sensors/grue/qml_app/info.json b/examples/sensors/grue/qml_app/info.json deleted file mode 100644 index 2e14fc79..00000000 --- a/examples/sensors/grue/qml_app/info.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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/sensors/grue/qml_app/main.qml b/examples/sensors/grue/qml_app/main.qml deleted file mode 100644 index 05d267c7..00000000 --- a/examples/sensors/grue/qml_app/main.qml +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtMobility.sensors 1.3 -import Grue 1.0 - -Rectangle { - width: 240 - height: 320 - color: "black" - - GrueSensor { - id: sensor - active: true - onReadingChanged: { - var percent = reading.chanceOfBeingEaten; - var thetext = ""; - var theopacity = 0; - if (percent === 0) { - thetext = "It is light. You are safe from Grues."; - } - else if (percent === 100) { - thetext = "You have been eaten by a Grue!"; - sensor.active = false; - theopacity = 1; - } - else if (percent > 0) { - thetext = "It is dark. You are likely to be eaten by a Grue. " - + "Your chance of being eaten by a Grue: "+percent+" percent."; - theopacity = 0.05 + (percent * 0.001); - } - text.font.pixelSize = 30; - text.text = "<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/qml_app/qml_app.pro b/examples/sensors/grue/qml_app/qml_app.pro deleted file mode 100644 index c017dcc4..00000000 --- a/examples/sensors/grue/qml_app/qml_app.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = aux - -app.files = \ - icon.png \ - info.json \ - main.qml \ - grue.png - -MT_SYSROOT=$$(MT_SYSROOT) -!isEmpty(MT_SYSROOT):EXAMPLES_PREFIX=/opt/mt/applications -!isEmpty(EXAMPLES_PREFIX) { - app.path = $$EXAMPLES_PREFIX/com.nokia.mt.grue - INSTALLS = app -} - |