diff options
author | Lincoln Ramsay <lincoln.ramsay@nokia.com> | 2011-10-04 15:14:01 +1000 |
---|---|---|
committer | Lincoln Ramsay <lincoln.ramsay@nokia.com> | 2011-10-10 09:25:31 +1000 |
commit | 4e04cda0e600f4e3bb148956ba631647a5c1fa4c (patch) | |
tree | 5dd8a0f2e2a0b2cdc8075f05a66cb1f6689e51c4 | |
parent | 93be0e5c0fd1694b0868187ed3daa006dfa4bd79 (diff) | |
download | qtsensors-4e04cda0e600f4e3bb148956ba631647a5c1fa4c.tar.gz |
Grue Sensor example
Updated, documented as an example.
Now with a QML import and a QML app.
Fixes: MTMW-85
Change-Id: I06772cf4a07ea0d2ec7bfccda6e8f51b5d866c20
Reviewed-on: http://codereview.qt-project.org/6016
Reviewed-by: Lincoln Ramsay <lincoln.ramsay@nokia.com>
23 files changed, 482 insertions, 143 deletions
diff --git a/doc/src/examples/grue.qdoc b/doc/src/examples/grue.qdoc new file mode 100644 index 0000000..d4dc66f --- /dev/null +++ b/doc/src/examples/grue.qdoc @@ -0,0 +1,165 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page gruesensorexample.html + \title Grue Sensor Example + \brief The Grue sensor example demonstrates all the steps from creating a new sensor to using it. + \ingroup qtsensors-examples + + The 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 + \o \l{Grue Sensor Definition} + \o \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 + \o \l{Grue Sensor Console Application} + \endlist + + To make the sensor available to a QML application an import must be created. + + \list + \o \l{Grue Sensor QML Import} + \o \l{Grue Sensor QML Application} + \endlist +*/ + +/*! + \example sensors/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 {Grue Sensor Example} +*/ + +/*! + \example sensors/grue/plugin + \title Grue Sensor Implementation + \brief The Grue sensor implementation lives in a plugin that is loaded by the QtSensors 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 ../examples/sensors/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 ../examples/sensors/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<GrueSensorReading>(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 {Grue Sensor Example} +*/ + +/*! + \example sensors/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 QtSensors to avoid a link-time dependency on the Grue Sensor + library. + + \sa {Grue Sensor Example} +*/ + +/*! + \example sensors/grue/import + \title Grue Sensor QML Import + \brief The Grue sensor QML import exports the GrueSensor class as a QML element. + + This example creates the \l {Grue 1.0} import. + + \sa {Grue Sensor Example} +*/ + +/*! + \example sensors/grue/qml_app + \title Grue Sensor QML Application + \brief The Grue sensor QML application demonstrates use of the GrueSensor QML element. + + blah blah blah + + \sa {Grue Sensor Example} +*/ + +/*! + \qmlmodule Grue 1 + \title Grue 1.0 + \brief QML import for the Grue Sensor Example + + blah blah blah + +*/ + diff --git a/doc/src/examples/sensors.qdoc b/doc/src/examples/sensors.qdoc index db02d7d..6cb3ce7 100644 --- a/doc/src/examples/sensors.qdoc +++ b/doc/src/examples/sensors.qdoc @@ -37,115 +37,6 @@ */ /*! - \example sensors/grueplugin - \title Grue Plugin - \brief The Grue Plugin demonstrates creation of a new sensor backend. - \ingroup qtsensors-examples - - The Grue plugin example demonstrates the creation of a new sensor type, - a sensor backend and plugin for the sensors library. Related to this example - is the \l{sensors/grueapp}{Grue Application} example. - - \tableofcontents - - \section1 Grue Sensor Type - - The files for this are: - - \list - \o gruesensor.h - \o gruesensor_p.h - \o gruesensor.cpp - \endlist - - 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. - - \section1 Grue Sensor Backend - - The files for this are: - - \list - \o gruesensorimpl.h - \o gruesensorimpl.cpp - \endlist - - 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 ../examples/sensors/grueplugin/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 ../examples/sensors/grueplugin/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<GrueSensorReading>(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. - - \section1 Grue Sensor Plugin - - The files for this are: - - \list - \o main.cpp - \endlist - - 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 {sensors/grueapp}{Grue Application} -*/ - - -/*! - \example sensors/grueapp - \title Grue Application - \brief The Grue Application demonstrates use of a new sensor type. - \ingroup qtsensors-examples - - The Grue application example demonstrates the use of the Grue sensor which - was defined and implemented by the \l{sensors/grueplugin}{Grue Plugin} example. - The Grue application is a commandline application. It is significant to note that - there is no link-time dependency on the Grue plugin. The Grue application uses - the generic access feature of the Sensors API. - - \sa {sensors/grueplugin}{Grue Plugin} -*/ - - -/*! \example sensors/cubehouse \title Cube House \ingroup qtsensors-examples @@ -169,7 +60,6 @@ \snippet ../examples/sensors/cubehouse/view.cpp smoothed */ - /*! \example sensors/sensor_explorer \title Sensor Explorer diff --git a/examples/sensors/grueapp/grueapp.pro b/examples/sensors/grue/console_app/console_app.pro index 65d59be..fefc015 100644 --- a/examples/sensors/grueapp/grueapp.pro +++ b/examples/sensors/grue/console_app/console_app.pro @@ -1,5 +1,5 @@ TEMPLATE=app -TARGET=grueapp +TARGET=detect_grue QT=core sensors SOURCES=main.cpp diff --git a/examples/sensors/grueapp/main.cpp b/examples/sensors/grue/console_app/main.cpp index 789e645..789e645 100644 --- a/examples/sensors/grueapp/main.cpp +++ b/examples/sensors/grue/console_app/main.cpp diff --git a/examples/sensors/grue/grue.pro b/examples/sensors/grue/grue.pro new file mode 100644 index 0000000..5af352b --- /dev/null +++ b/examples/sensors/grue/grue.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs + +SUBDIRS += lib plugin console_app +SUBDIRS += import #qml_app + +plugin.depends = lib +import.depends = lib + diff --git a/examples/sensors/grue/import/import.pro b/examples/sensors/grue/import/import.pro new file mode 100644 index 0000000..fc163b6 --- /dev/null +++ b/examples/sensors/grue/import/import.pro @@ -0,0 +1,19 @@ +TARGET = declarative_grue +TARGETPATH = Grue + +include(qsensorsimport.pri) + +QT = declarative sensors + +DESTDIR = $$QT.sensors.imports/$$TARGETPATH + +INCLUDEPATH += $$PWD/../lib +LIBS += -L$$OUT_PWD/../lib -lgruesensor + +SOURCES = main.cpp + +symbian { + TARGET.EPOCALLOWDLLDATA = 1 + TARGET.CAPABILITY = ALL -TCB +} + diff --git a/examples/sensors/grue/import/main.cpp b/examples/sensors/grue/import/main.cpp new file mode 100644 index 0000000..ec1d470 --- /dev/null +++ b/examples/sensors/grue/import/main.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtSensors module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtDeclarative/qdeclarativeextensionplugin.h> +#include <QtDeclarative/qdeclarative.h> + +#include <gruesensor.h> + +QT_BEGIN_NAMESPACE + +class GrueSensorQmlImport : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +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")); + } +}; + +QT_END_NAMESPACE + +#include "main.moc" + +Q_EXPORT_PLUGIN2(gruesensorqmlimport, QT_PREPEND_NAMESPACE(GrueSensorQmlImport)); + +/*! + \qmlclass GrueSensor GrueSensor + \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} +*/ + +/*! + \qmlproperty GrueSensorReading Grue1::GrueSensor::reading + Holds the most recent Grue sensor reading. + Please see QSensor::reading for information about this property. +*/ + +/*! + \qmlsignal Grue1::GrueSensor::onReadingChanged() + Called when the reading object changes. + Please see QSensor::readingChanged() for information about this signal. +*/ + +/*! + \qmlclass GrueSensorReading GrueSensorReading + \inqmlmodule Grue 1 + \inherits QtMobility.sensors1::SensorReading + \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/qmldir b/examples/sensors/grue/import/qmldir new file mode 100644 index 0000000..266b7c1 --- /dev/null +++ b/examples/sensors/grue/import/qmldir @@ -0,0 +1 @@ +plugin declarative_grue diff --git a/examples/sensors/grue/import/qsensorsimport.pri b/examples/sensors/grue/import/qsensorsimport.pri new file mode 100644 index 0000000..d5cfeff --- /dev/null +++ b/examples/sensors/grue/import/qsensorsimport.pri @@ -0,0 +1,38 @@ +load(qt_module) + +symbian:load(qt_plugin) +TEMPLATE = lib +CONFIG += qt plugin + +win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release + +isEmpty(TARGETPATH) { + error("qimportbase.pri: You must provide a TARGETPATH!") +} +isEmpty(TARGET) { + error("qimportbase.pri: You must provide a TARGET!") +} + +QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir +copy2build.input = QMLDIRFILE +copy2build.output = $$QT.sensors.imports/$$TARGETPATH/qmldir +!contains(TEMPLATE_PREFIX, vc):copy2build.variable_out = PRE_TARGETDEPS +copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy2build.name = COPY ${QMAKE_FILE_IN} +copy2build.CONFIG += no_link +# `clean' should leave the build in a runnable state, which means it shouldn't delete qmldir +copy2build.CONFIG += no_clean +QMAKE_EXTRA_COMPILERS += copy2build + +TARGET = $$qtLibraryTarget($$TARGET) +contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols + +load(qt_targets) + +wince*:LIBS += $$QMAKE_LIBS_GUI + +symbian: { + TARGET.EPOCALLOWDLLDATA=1 + TARGET.CAPABILITY = All -Tcb + load(armcc_warnings) +} diff --git a/examples/sensors/grueplugin/gruesensor.cpp b/examples/sensors/grue/lib/gruesensor.cpp index c5ee030..da322cb 100644 --- a/examples/sensors/grueplugin/gruesensor.cpp +++ b/examples/sensors/grue/lib/gruesensor.cpp @@ -45,9 +45,7 @@ IMPLEMENT_READING(GrueSensorReading) /*! \class GrueSensorReading - \ingroup sensors_reading - \preliminary \brief The GrueSensorReading class holds readings from the Grue sensor. The Grue Sensor informs you of your chance of being eaten by a Grue. @@ -84,9 +82,7 @@ void GrueSensorReading::setChanceOfBeingEaten(qreal chanceOfBeingEaten) /*! \class GrueFilter - \ingroup sensors_filter - \preliminary \brief The GrueFilter class is a convenience wrapper around QSensorFilter. The only difference is that the filter() method features a pointer to GrueSensorReading @@ -105,9 +101,7 @@ char const * const GrueSensor::type("GrueSensor"); /*! \class GrueSensor - \ingroup sensors_type - \preliminary \brief The GrueSensor class is a convenience wrapper around QSensor. The only behavioural difference is that this class sets the type properly. diff --git a/examples/sensors/grueplugin/gruesensor.h b/examples/sensors/grue/lib/gruesensor.h index 52b08e9..52b08e9 100644 --- a/examples/sensors/grueplugin/gruesensor.h +++ b/examples/sensors/grue/lib/gruesensor.h diff --git a/examples/sensors/grueplugin/gruesensor_p.h b/examples/sensors/grue/lib/gruesensor_p.h index 5eff57e..5eff57e 100644 --- a/examples/sensors/grueplugin/gruesensor_p.h +++ b/examples/sensors/grue/lib/gruesensor_p.h diff --git a/examples/sensors/grue/lib/lib.pro b/examples/sensors/grue/lib/lib.pro new file mode 100644 index 0000000..80bf136 --- /dev/null +++ b/examples/sensors/grue/lib/lib.pro @@ -0,0 +1,17 @@ +TEMPLATE = lib +TARGET = gruesensor + +QT = core sensors + +HEADERS += gruesensor.h\ + gruesensor_p.h\ + +SOURCES += gruesensor.cpp\ + +DESTDIR=$$QT.sensors.libs + +symbian { + TARGET.EPOCALLOWDLLDATA = 1 + TARGET.CAPABILITY = ALL -TCB +} + diff --git a/examples/sensors/grueplugin/gruesensorimpl.cpp b/examples/sensors/grue/plugin/gruesensorimpl.cpp index 4a277c9..4a277c9 100644 --- a/examples/sensors/grueplugin/gruesensorimpl.cpp +++ b/examples/sensors/grue/plugin/gruesensorimpl.cpp diff --git a/examples/sensors/grueplugin/gruesensorimpl.h b/examples/sensors/grue/plugin/gruesensorimpl.h index bddca84..bddca84 100644 --- a/examples/sensors/grueplugin/gruesensorimpl.h +++ b/examples/sensors/grue/plugin/gruesensorimpl.h diff --git a/examples/sensors/grueplugin/main.cpp b/examples/sensors/grue/plugin/main.cpp index d471ece..d471ece 100644 --- a/examples/sensors/grueplugin/main.cpp +++ b/examples/sensors/grue/plugin/main.cpp diff --git a/examples/sensors/grue/plugin/plugin.pro b/examples/sensors/grue/plugin/plugin.pro new file mode 100644 index 0000000..fed8460 --- /dev/null +++ b/examples/sensors/grue/plugin/plugin.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib +CONFIG += plugin +TARGET = $$qtLibraryTarget(qtsensors_grue) +PLUGIN_TYPE = sensors + +QT = core sensors + +INCLUDEPATH += $$PWD/../lib +LIBS += -L$$QT.sensors.libs -lgruesensor + +HEADERS += gruesensorimpl.h\ + +SOURCES += gruesensorimpl.cpp\ + main.cpp\ + +symbian { + TARGET.EPOCALLOWDLLDATA = 1 + TARGET.CAPABILITY = ALL -TCB +} + diff --git a/examples/sensors/grue/qml_app/main.qml b/examples/sensors/grue/qml_app/main.qml new file mode 100644 index 0000000..278bf72 --- /dev/null +++ b/examples/sensors/grue/qml_app/main.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 Grue 1.0 + +Item { + width: 200 + height: 300 + + GrueSensor { + id: sensor + active: true + property int lastPercent: 0 + onReadingChanged: { + var percent = Math.floor(reading.chanceOfBeingEaten * 100); + if (percent == 0) { + text.text = "It is light. You are safe from Grues."; + } else if (lastPercent == 0) { + text.text = "It is dark. You are likely to be eaten by a Grue."; + } + if (percent == 100) { + text.text += "You have been eaten by a Grue!"; + sensor.active = false; + } else if (percent) { + text.text += "Your chance of being eaten by a Grue: "+percent+" percent."; + } + lastPercent = percent; + } + } + + Text { + id: text + anchors.fill: parent + 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 + } +} diff --git a/examples/sensors/grue/qml_app/qml_app.qmlproject b/examples/sensors/grue/qml_app/qml_app.qmlproject new file mode 100644 index 0000000..2218c43 --- /dev/null +++ b/examples/sensors/grue/qml_app/qml_app.qmlproject @@ -0,0 +1,20 @@ +/* File generated by Qt Creator, version 2.2.0 */ + +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ "../exampleplugin" ] +} diff --git a/examples/sensors/grueplugin/grueplugin.pri b/examples/sensors/grueplugin/grueplugin.pri deleted file mode 100644 index 2cade0f..0000000 --- a/examples/sensors/grueplugin/grueplugin.pri +++ /dev/null @@ -1,8 +0,0 @@ -HEADERS += gruesensor.h\ - gruesensor_p.h\ - gruesensorimpl.h\ - -SOURCES += gruesensor.cpp\ - gruesensorimpl.cpp\ - main.cpp\ - diff --git a/examples/sensors/grueplugin/grueplugin.pro b/examples/sensors/grueplugin/grueplugin.pro deleted file mode 100644 index 0b39f91..0000000 --- a/examples/sensors/grueplugin/grueplugin.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin -TARGET = $$qtLibraryTarget(qtsensors_grueplugin) -PLUGIN_TYPE = sensors - -QT = core sensors - -include(version.pri) -include(grueplugin.pri) - -symbian { - TARGET.EPOCALLOWDLLDATA = 1 - TARGET.CAPABILITY = ALL -TCB -} - diff --git a/examples/sensors/grueplugin/version.pri b/examples/sensors/grueplugin/version.pri deleted file mode 100644 index 6fbe025..0000000 --- a/examples/sensors/grueplugin/version.pri +++ /dev/null @@ -1 +0,0 @@ -VERSION = 0.1.1 diff --git a/examples/sensors/sensors.pro b/examples/sensors/sensors.pro index 04033fc..e7ecf2c 100644 --- a/examples/sensors/sensors.pro +++ b/examples/sensors/sensors.pro @@ -3,8 +3,7 @@ TEMPLATE = subdirs SUBDIRS += \ accel\ cubehouse\ - grueapp\ - grueplugin + grue contains(QT_CONFIG,widgets):SUBDIRS += \ sensor_explorer |