diff options
Diffstat (limited to 'examples')
21 files changed, 317 insertions, 33 deletions
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 |