diff options
Diffstat (limited to 'src/imports/sensors2')
-rw-r--r-- | src/imports/sensors2/plugin.json | 1 | ||||
-rw-r--r-- | src/imports/sensors2/plugins.qmltypes | 91 | ||||
-rw-r--r-- | src/imports/sensors2/qmldir | 3 | ||||
-rw-r--r-- | src/imports/sensors2/qsensor2ambientlight.cpp | 116 | ||||
-rw-r--r-- | src/imports/sensors2/qsensor2ambientlight.h | 87 | ||||
-rw-r--r-- | src/imports/sensors2/qsensor2common.cpp | 111 | ||||
-rw-r--r-- | src/imports/sensors2/qsensor2common.h | 76 | ||||
-rw-r--r-- | src/imports/sensors2/qsensor2gesture.cpp | 266 | ||||
-rw-r--r-- | src/imports/sensors2/qsensor2gesture.h | 105 | ||||
-rw-r--r-- | src/imports/sensors2/qsensor2proximity.cpp | 98 | ||||
-rw-r--r-- | src/imports/sensors2/qsensor2proximity.h | 79 | ||||
-rw-r--r-- | src/imports/sensors2/qsensor2tilt.cpp | 409 | ||||
-rw-r--r-- | src/imports/sensors2/qsensor2tilt.h | 111 | ||||
-rw-r--r-- | src/imports/sensors2/sensors2.cpp | 72 | ||||
-rw-r--r-- | src/imports/sensors2/sensors2.pro | 22 |
15 files changed, 0 insertions, 1647 deletions
diff --git a/src/imports/sensors2/plugin.json b/src/imports/sensors2/plugin.json deleted file mode 100644 index 0967ef42..00000000 --- a/src/imports/sensors2/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/src/imports/sensors2/plugins.qmltypes b/src/imports/sensors2/plugins.qmltypes deleted file mode 100644 index ea8b5260..00000000 --- a/src/imports/sensors2/plugins.qmltypes +++ /dev/null @@ -1,91 +0,0 @@ -import QtQuick.tooling 1.1 - -// This file describes the plugin-supplied types contained in the library. -// It is used for QML tooling purposes only. -// -// This file was auto-generated with the command 'qmlplugindump QtSensors 5.0 /home/lramsay/build/qt50/qtbase/imports'. - -Module { - Component { - name: "QSensor2AmbientLight" - prototype: "qsensor2common" - exports: ["AmbientLightSensor 5.0"] - Enum { - name: "LightLevel" - values: { - "Unknown": 0, - "Dark": 1, - "Twilight": 2, - "Light": 3, - "Bright": 4, - "Sunny": 5 - } - } - Property { name: "lightLevel"; type: "LightLevel"; isReadonly: true } - Signal { name: "lightLevelChanged"; type: "void" } - } - Component { - name: "QSensor2Gesture" - prototype: "QObject" - exports: ["SensorGesture 5.0"] - Property { name: "availableGestures"; type: "QStringList"; isReadonly: true } - Property { name: "gestures"; type: "QStringList" } - Property { name: "validGestures"; type: "QStringList"; isReadonly: true } - Property { name: "invalidGestures"; type: "QStringList"; isReadonly: true } - Property { name: "enabled"; type: "bool" } - Signal { - name: "detected" - type: "void" - Parameter { name: "gesture"; type: "string" } - } - Signal { name: "availableGesturesChanged"; type: "void" } - Signal { name: "gesturesChanged"; type: "void" } - Signal { name: "validGesturesChanged"; type: "void" } - Signal { name: "invalidGesturesChanged"; type: "void" } - Signal { name: "enabledChanged"; type: "void" } - } - Component { - name: "QSensor2Proximity" - prototype: "qsensor2common" - exports: ["ProximitySensor 5.0"] - Property { name: "near"; type: "bool"; isReadonly: true } - Signal { name: "nearChanged"; type: "void" } - } - Component { - name: "QSensor2Tilt" - prototype: "qsensor2common" - exports: ["TiltSensor 5.0"] - Enum { - name: "Speed" - values: { - "Slow": 0, - "Medium": 1, - "Fast": 2 - } - } - Property { name: "yRotation"; type: "double"; isReadonly: true } - Property { name: "xRotation"; type: "double"; isReadonly: true } - Property { name: "speed"; type: "Speed" } - Property { name: "settings"; type: "QByteArray" } - Signal { name: "yRotationChanged"; type: "void" } - Signal { name: "xRotationChanged"; type: "void" } - Signal { name: "speedChanged"; type: "void" } - Signal { - name: "tiltChanged" - type: "void" - Parameter { name: "deltaX"; type: "double" } - Parameter { name: "deltaY"; type: "double" } - } - Signal { name: "accuracyChanged"; type: "void" } - Method { name: "calibrate"; type: "void" } - } - Component { - name: "qsensor2common" - prototype: "QObject" - exports: ["Sensor 5.0"] - Property { name: "enabled"; type: "bool" } - Property { name: "alwaysOn"; type: "bool" } - Signal { name: "enabledChanged"; type: "void" } - Signal { name: "alwaysOnChanged"; type: "void" } - } -} diff --git a/src/imports/sensors2/qmldir b/src/imports/sensors2/qmldir deleted file mode 100644 index cfef92b2..00000000 --- a/src/imports/sensors2/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module QtSensors -plugin declarative_qtsensors5 -typeinfo plugins.qmltypes diff --git a/src/imports/sensors2/qsensor2ambientlight.cpp b/src/imports/sensors2/qsensor2ambientlight.cpp deleted file mode 100644 index a670a5ff..00000000 --- a/src/imports/sensors2/qsensor2ambientlight.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensor2ambientlight.h" -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype AmbientLightSensor - \instantiates QSensor2AmbientLight - \inherits QtSensors5::Sensor - \inqmlmodule QtSensors 5.0 - \ingroup qml-QtSensors5 - \since QtSensors 5.0 - \brief Provides access to the current ambient light level. - - This type provides easy access to determine the ambient light by using the ambient light sensor. - For example brightening the screen according to whether the device is in full sunlight or not. - - This type is part of the \b{QtSensors 5} module. - - The \l {Qt Sensors - QML example} is an example how to use this QML type. -*/ -QSensor2AmbientLight::QSensor2AmbientLight(QObject* parent) - : qsensor2common(parent) - , _lightLevel(QSensor2AmbientLight::Unknown) -{ - _ambientLight = new QAmbientLightSensor(this); - _ambientLight->addFilter(this); -} - - -QSensor2AmbientLight::~QSensor2AmbientLight() -{ -} - -/*! - \qmlproperty enumeration QtSensors5::AmbientLightSensor::lightLevel - Holds the ambient light level in the form of the LightLevel enum: - - \table - \row - \li AmbientLightSensor.Unknown - \li Ambient light value is not set yet. - \row - \li AmbientLightSensor.Dark - \li It is dark. - \row - \li AmbientLightSensor.Twilight - \li It is moderately dark. - \row - \li AmbientLightSensor.Light - \li It is light (internal lights). - \row - \li AmbientLightSensor.Bright - \li It is bright (outside but in the shade). - \row - \li AmbientLightSensor.Sunny - \li It is very bright (direct sunlight). - \endtable -*/ -QSensor2AmbientLight::LightLevel QSensor2AmbientLight::lightLevel() -{ - return _lightLevel; -} - -bool QSensor2AmbientLight::filter(QAmbientLightReading *reading) -{ - QSensor2AmbientLight::LightLevel lv = (QSensor2AmbientLight::LightLevel)reading->lightLevel(); - if (lv != _lightLevel){ - _lightLevel = lv; - Q_EMIT lightLevelChanged(); - } - return false; -} - -QT_END_NAMESPACE diff --git a/src/imports/sensors2/qsensor2ambientlight.h b/src/imports/sensors2/qsensor2ambientlight.h deleted file mode 100644 index 96bb5cd3..00000000 --- a/src/imports/sensors2/qsensor2ambientlight.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSENSOR2AMBIENTLIGHT_H -#define QSENSOR2AMBIENTLIGHT_H - -#include <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include <qambientlightsensor.h> -#include "qsensor2common.h" - -QT_BEGIN_NAMESPACE - -class QSensor2AmbientLight : public qsensor2common, public QAmbientLightFilter -{ - Q_OBJECT - Q_ENUMS(LightLevel) - Q_PROPERTY(LightLevel lightLevel READ lightLevel NOTIFY lightLevelChanged) -public: - QSensor2AmbientLight(QObject* parent = 0); - virtual ~QSensor2AmbientLight(); - - enum LightLevel { - Unknown = 0, - Dark, - Twilight, - Light, - Bright, - Sunny - }; - -Q_SIGNALS: - void lightLevelChanged(); - -private: - // Override of QAmbientLightFilter::filter(QAmbientLightReading*) - bool filter(QAmbientLightReading *reading); - LightLevel lightLevel(); - - QSensor *sensor() { return _ambientLight; } - QAmbientLightSensor* _ambientLight; - LightLevel _lightLevel; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QSensor2AmbientLight) - -#endif // QSENSOR2AMBIENTLIGHT_H diff --git a/src/imports/sensors2/qsensor2common.cpp b/src/imports/sensors2/qsensor2common.cpp deleted file mode 100644 index a151b864..00000000 --- a/src/imports/sensors2/qsensor2common.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensor2common.h" -#include <QSensor> -#include <QDebug> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Sensor - \instantiates qsensor2common - \inqmlmodule QtSensors 5.0 - \brief The Sensor type serves as a base type for sensors. - - The Sensor type serves as a base type for sensors. - - This type cannot be directly created. Please use one of the sub-classes instead. -*/ - -qsensor2common::qsensor2common(QObject *parent) - : QObject(parent) -{ -} - -qsensor2common::~qsensor2common() -{ -} - -/*! - \qmlproperty bool QtSensors5::Sensor::enabled - Starts or stops the sensor. Default value is false. -*/ - -bool qsensor2common::enabled() -{ - return sensor()->isActive(); -} - -void qsensor2common::setEnabled(bool val) -{ - bool active = enabled(); - if (active != val){ - if (val){ - bool ret = sensor()->start(); - if (!ret) - qWarning() << "couldn't start the sensor."; - } - else - sensor()->stop(); - Q_EMIT enabledChanged(); - } -} - -/*! - \qmlproperty bool QtSensors5::Sensor::alwaysOn - Keeps the sensor running when the screen turns off. Default value is false. -*/ - -bool qsensor2common::alwaysOn() -{ - return sensor()->isAlwaysOn(); -} - -void qsensor2common::setAlwaysOn(bool alwaysOn) -{ - if (sensor()->isAlwaysOn() == alwaysOn) return; - sensor()->setAlwaysOn(alwaysOn); - Q_EMIT alwaysOnChanged(); -} - -QT_END_NAMESPACE - diff --git a/src/imports/sensors2/qsensor2common.h b/src/imports/sensors2/qsensor2common.h deleted file mode 100644 index 84aac1eb..00000000 --- a/src/imports/sensors2/qsensor2common.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSENSOR2COMMON_H -#define QSENSOR2COMMON_H - -#include <QObject> - -QT_BEGIN_NAMESPACE - -class QSensor; - -class qsensor2common : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(bool alwaysOn READ alwaysOn WRITE setAlwaysOn NOTIFY alwaysOnChanged) -public: - explicit qsensor2common(QObject *parent = 0); - virtual ~qsensor2common(); - - bool enabled(); - virtual void setEnabled(bool val); - - bool alwaysOn(); - void setAlwaysOn(bool alwaysOn); - -signals: - void enabledChanged(); - void alwaysOnChanged(); - -protected: - virtual QSensor *sensor() = 0; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/imports/sensors2/qsensor2gesture.cpp b/src/imports/sensors2/qsensor2gesture.cpp deleted file mode 100644 index 8341c521..00000000 --- a/src/imports/sensors2/qsensor2gesture.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensor2gesture.h" -#include <qsensorgesture.h> -#include <qsensorgesturemanager.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype SensorGesture - \instantiates QSensor2Gesture - \inqmlmodule QtSensors 5.0 - \since QtSensors 5.0 - \brief Provides notifications when sensor-based gestures are detected. - - This type provides notification when sensor gestures are triggered. - - This type is part of the \b{QtSensors 5} module. - - The following QML code creates a "shake" and "SecondCounter" SensorGesture QML type, and - displays the detected gesture in a text type. - - QtSensors.shake gesture is available with the Qt Sensors API, but the QtSensors.SecondCounter - sensor gesture is provided as example code for the \l {Qt Sensors - SensorGesture QML Type example} - - \qml - Item { - SensorGesture { - id: sensorGesture - enabled: false - gestures : ["QtSensors.shake", "QtSensors.SecondCounter"] - onDetected:{ - detectedText.text = gesture - } - } - Text { - id: detectedText - x:5 - y:160 - text: "" - } - } - \endqml - - \l {Qt Sensor Gestures} contains a list of currently supported sensor gestures and their - descriptions. - - -*/ -QSensor2Gesture::QSensor2Gesture(QObject* parent) - : QObject(parent) - , isEnabled(false) - , initDone(false) - , sensorGesture(0) - , sensorGestureManager(new QSensorGestureManager(this)) -{ - connect(sensorGestureManager, SIGNAL(newSensorGestureAvailable()), SIGNAL(availableGesturesChanged())); -} - -QSensor2Gesture::~QSensor2Gesture() -{ -} - -/* - QQmlParserStatus interface implementation -*/ -void QSensor2Gesture::classBegin() -{ -} - -void QSensor2Gesture::componentComplete() -{ - /* - this is needed in the case the customer defines the type(s) and set it enabled = true - */ - initDone = true; - setEnabled(isEnabled); -} -/* - End of QQmlParserStatus interface implementation -*/ - -/*! - \qmlproperty stringlist QtSensors5::SensorGesture::availableGestures - This property can be used to determine all available gestures on the system. -*/ -QStringList QSensor2Gesture::availableGestures() -{ - return sensorGestureManager->gestureIds(); -} - -/*! - \qmlproperty stringlist QtSensors5::SensorGesture::gestures - Set this property to a list of the gestures that the application is interested in detecting. - This property cannot be changed while the type is enabled. - - The properties validGestures and invalidGestures will be set as appropriate immediately. - To determine all available getures on the system please use the - \l {QtSensors5::SensorGesture::availableGestures} {availableGestures} property. - - \sa {QtSensorGestures Plugins} -*/ -QStringList QSensor2Gesture::gestures() const -{ - return gestureList; -} - -void QSensor2Gesture::setGestures(const QStringList& value) -{ - if (gestureList == value) - return; - - if (initDone && enabled()) { - qWarning() << "Cannot change gestures while running."; - return; - } - gestureList.clear(); - gestureList = value; - createGesture(); - Q_EMIT gesturesChanged(); -} - - -/*! - \qmlproperty stringlist QtSensors5::SensorGesture::validGestures - This property holds the requested gestures that were found on the system. -*/ -QStringList QSensor2Gesture::validGestures() const -{ - if (sensorGesture) - return sensorGesture->validIds(); - return QStringList(); -} - -/*! - \qmlproperty stringlist QtSensors5::SensorGesture::invalidGestures - This property holds the requested gestures that were not found on the system. -*/ -QStringList QSensor2Gesture::invalidGestures() const -{ - if (sensorGesture) - return sensorGesture->invalidIds(); - return QStringList(); -} - -/*! - \qmlproperty bool QtSensors5::SensorGesture::enabled - This property can be used to activate or deactivate the sensor gesture. - Default value is false; - \sa {QtSensors5::SensorGesture::detected}, {detected} -*/ -bool QSensor2Gesture::enabled() const -{ - return isEnabled; -} - -void QSensor2Gesture::setEnabled(bool value) -{ - bool hasChanged = false; - if (isEnabled != value) { - isEnabled = value; - hasChanged = true; - } - if (!initDone) - return; - - if (sensorGesture) { - if (value) { - sensorGesture->startDetection(); - } else { - sensorGesture->stopDetection(); - } - } - if (hasChanged) - Q_EMIT enabledChanged(); -} - -/*! - \qmlsignal QtSensors5::SensorGesture::detected(string gesture) - This signal is emitted whenever a gesture is detected. - The gesture parameter contains the gesture that was detected. -*/ - -/* - private funtion implementation -*/ -void QSensor2Gesture::deleteGesture() -{ - if (sensorGesture) { - bool emitInvalidChange = !invalidGestures().isEmpty(); - bool emitValidChange = !validGestures().isEmpty(); - - if (sensorGesture->isActive()) { - sensorGesture->stopDetection(); - } - delete sensorGesture; - sensorGesture = 0; - - if (emitInvalidChange) { - Q_EMIT invalidGesturesChanged(); - } - if (emitValidChange) { - Q_EMIT validGesturesChanged(); - } - } -} - -void QSensor2Gesture::createGesture() -{ - deleteGesture(); - sensorGesture = new QSensorGesture(gestureList, this); - if (!validGestures().isEmpty()) { - QObject::connect(sensorGesture - , SIGNAL(detected(QString)) - , this - , SIGNAL(detected(QString))); - Q_EMIT validGesturesChanged(); - } - if (!invalidGestures().isEmpty()) - Q_EMIT invalidGesturesChanged(); -} - -/* - End of private funtion implementation -*/ - -QT_END_NAMESPACE diff --git a/src/imports/sensors2/qsensor2gesture.h b/src/imports/sensors2/qsensor2gesture.h deleted file mode 100644 index 2a27b055..00000000 --- a/src/imports/sensors2/qsensor2gesture.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSENSOR2GESTURE_H -#define QSENSOR2GESTURE_H - -#include <QtQml/QQmlParserStatus> -#include <QtQml/qqml.h> -#include <QtCore/QStringList> -#include <QtCore/QMap> - -QT_BEGIN_NAMESPACE - -class QSensorGesture; -class QSensorGestureManager; -class QSensor2Gesture : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_PROPERTY(QStringList availableGestures READ availableGestures NOTIFY availableGesturesChanged) - Q_PROPERTY(QStringList gestures READ gestures WRITE setGestures NOTIFY gesturesChanged) - Q_PROPERTY(QStringList validGestures READ validGestures NOTIFY validGesturesChanged) - Q_PROPERTY(QStringList invalidGestures READ invalidGestures NOTIFY invalidGesturesChanged) - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_INTERFACES(QQmlParserStatus) - -public: - explicit QSensor2Gesture(QObject* parent = 0); - ~QSensor2Gesture(); - void classBegin() Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; - -Q_SIGNALS: - void detected(const QString &gesture); - void availableGesturesChanged(); - void gesturesChanged(); - void validGesturesChanged(); - void invalidGesturesChanged(); - void enabledChanged(); - -public: - QStringList availableGestures(); - QStringList gestures() const; - void setGestures(const QStringList& value); - bool enabled() const; - void setEnabled(bool value); - QStringList validGestures() const; - QStringList invalidGestures() const; - -private: - void deleteGesture(); - void createGesture(); - -private: - QStringList gestureIds; - bool isEnabled; - bool initDone; - QStringList gestureList; - - QSensorGesture* sensorGesture; - QSensorGestureManager* sensorGestureManager; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QSensor2Gesture) - -#endif // QSENSOR2GESTURE_H diff --git a/src/imports/sensors2/qsensor2proximity.cpp b/src/imports/sensors2/qsensor2proximity.cpp deleted file mode 100644 index b5e3dd71..00000000 --- a/src/imports/sensors2/qsensor2proximity.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensor2proximity.h" -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype ProximitySensor - \instantiates QSensor2Proximity - \inherits QtSensors5::Sensor - \inqmlmodule QtSensors 5.0 - \since QtSensors 5.0 - \brief Provides access to the proximity sensor. - - This type allows determining if something is held in close proximity to the device, such - as determining if the user is holding the device to their ear. - - This type is part of the \b{QtSensors 5} module. - - The \l {Qt Sensors - QML example} is an example how to use this QML type. - -*/ - -QSensor2Proximity::QSensor2Proximity(QObject* parent) - : qsensor2common(parent) - , _near(false) -{ - _proximity = new QProximitySensor(this); - _proximity->addFilter(this); -} - -QSensor2Proximity::~QSensor2Proximity() -{ -} - -/*! - \qmlproperty bool QtSensors5::ProximitySensor::near - This property holds whether the sensor has detected something in close proximity. - The definition of close proximity is device dependent, but it - typically stands for a distance of 1-2 cm. -*/ -bool QSensor2Proximity::near() -{ - return _near; -} - -bool QSensor2Proximity::filter(QProximityReading *reading) -{ - bool cl = reading->close(); - if (_near != cl){ - _near = cl; - Q_EMIT nearChanged(); - } - - return false; -} - -QT_END_NAMESPACE diff --git a/src/imports/sensors2/qsensor2proximity.h b/src/imports/sensors2/qsensor2proximity.h deleted file mode 100644 index 3c64cf9b..00000000 --- a/src/imports/sensors2/qsensor2proximity.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSENSOR2PROXIMITY_H -#define QSENSOR2PROXIMITY_H - -#include <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include <qproximitysensor.h> -#include "qsensor2common.h" - -QT_BEGIN_NAMESPACE - -class QSensor2Proximity : public qsensor2common, public QProximityFilter -{ - Q_OBJECT - Q_PROPERTY(bool near READ near NOTIFY nearChanged) - -public: - QSensor2Proximity(QObject* parent = 0); - virtual ~QSensor2Proximity(); - -Q_SIGNALS: - void nearChanged(); - -private: - // Override of QProximityFilter::filter(QProximityReading*) - bool filter(QProximityReading *reading); - bool near(); - -private: - QSensor *sensor() { return _proximity; } - QProximitySensor* _proximity; - bool _near; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QSensor2Proximity) - -#endif // QSENSOR2PROXIMITY_H diff --git a/src/imports/sensors2/qsensor2tilt.cpp b/src/imports/sensors2/qsensor2tilt.cpp deleted file mode 100644 index 85d39ce8..00000000 --- a/src/imports/sensors2/qsensor2tilt.cpp +++ /dev/null @@ -1,409 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensor2tilt.h" -#define _USE_MATH_DEFINES -#include <qmath.h> -#include <QtCore/QDebug> -#include <QtCore/QStringList> - -#define MAXRATE 30 - -QT_BEGIN_NAMESPACE - -/*! - \qmltype TiltSensor - \instantiates QSensor2Tilt - \inherits QtSensors5::Sensor - \inqmlmodule QtSensors 5.0 - \since QtSensors 5.0 - \brief Provides access to the current X and Y axis rotation angles of the device. - - This type provides tilt data from the rotation around the x and y axis of the device using - the accelerometer sensor. Like for a marble and maze game, where the marble is rolled - around the screen according to the user tilting the device. - - This type is part of the \b{QtSensors 5} module. - - The \l {Qt Sensors - QML example} is an example how to use this QML type. - -*/ -QSensor2Tilt::QSensor2Tilt(QObject* parent) - : qsensor2common(parent) - , _yRotation(0) - , _xRotation(0) - , _radAccuracy(M_PI / 180) - , _pitch(0) - , _roll(0) - , _calibratedPitch(0) - , _calibratedRoll(0) - , _speed(QSensor2Tilt::Slow) -{ - _accel = new QAccelerometer(this); - _accel->addFilter(this); -} - -QSensor2Tilt::~QSensor2Tilt() -{ -} - -int searchDataRate(const QList<int>& datarates, int value) -{ - int l = 0; - int r = datarates.count() - 1; - int m = (l + r) / 2; - - while (l <= r) { - m = (l + r) / 2; - if (datarates[m] == value) - break; - else if (datarates[m] < value) - r = m - 1; - else - l = m + 1; - } - if (m > 0){ - int ddr = datarates[m - 1]; - ddr -= value; - int ddr1 = datarates[m] - value; - if (ddr1 < 0) ddr1 = -ddr1; - if (ddr < ddr1) - return datarates[m - 1]; - } - - return datarates[m]; -} - -QMap<QSensor2Tilt::Speed, int> QSensor2Tilt::dataRate() -{ - return _dataRate; -} - -void QSensor2Tilt::createRunModeDataRateMap() -{ - _dataRate.clear(); - qrangelist rl = _accel->availableDataRates(); - - //1. make a list of all available datarates - QList<int> dr; - foreach (const qrange &r, rl) { - for (int i = r.first; i <= r.second; i++){ - if (i <= MAXRATE){ - if (!dr.contains(i)) - dr.append(i); - } - } - } - - //2. Sort the list - if (dr.count() > 0){ - qSort(dr.begin(), dr.end(), qGreater<int>()); - _dataRate.insert(QSensor2Tilt::Slow, searchDataRate(dr, 2)); - _dataRate.insert(QSensor2Tilt::Medium, searchDataRate(dr, 10)); - _dataRate.insert(QSensor2Tilt::Fast, searchDataRate(dr, 20)); - } -} - -/*! - \qmlproperty enumeration QtSensors5::TiltSensor::speed - Holds the speed that the sensor should be run at. - Default is Slow. - - \table - \row - \li TiltSensor.Slow - \li The sensor runs in slow mode. - \li Closest available datarate at 2Hz. - \row - \li TiltSensor.Medium - \li The sensor runs in medium mode. - \li Closest available datarate at 10Hz. - \row - \li TiltSensor.Fast - \li The sensor runs in fast mode. - \li Closest available datarate at 20Hz. - \endtable -*/ -QSensor2Tilt::Speed QSensor2Tilt::speed() -{ - return _speed; -} - -void QSensor2Tilt::setSpeed(const QSensor2Tilt::Speed val) -{ - if (_dataRate.keys().contains(val)){ - if (_dataRate.value(val) != _accel->dataRate()){ - _accel->setDataRate(_dataRate.value(val)); - Q_EMIT speedChanged(); - } - } - _speed = val; -} - -void QSensor2Tilt::setEnabled(const bool val) -{ - bool active = enabled(); - if (active != val){ - if (val){ - bool readDatarateMap = !_accel->isConnectedToBackend(); - bool ret = _accel->start(); - if (!ret) - qWarning() << "couldn't start the sensor."; - else if (readDatarateMap){ - createRunModeDataRateMap(); - setSpeed(_speed); - } - } - else - _accel->stop(); - Q_EMIT enabledChanged(); - } -} - - -/*! - \qmlproperty real QtSensors5::TiltSensor::yRotation - Holds the rotation arround the y axis. - - \table - \row - \li - \image YAngle.gif - \li - \image YAngleNegative.gif - \endtable -*/ -qreal QSensor2Tilt::yRotation() -{ - return _yRotation * 180 / M_PI; -} - -/*! - \qmlproperty real QtSensors5::TiltSensor::xRotation - Holds the rotation arround the x axis. - \table - \row - \li - \image XAngle.gif - \li - \image XAngleNegative.gif - \endtable -*/ -qreal QSensor2Tilt::xRotation() -{ - return _xRotation * 180 / M_PI; -} - -/* - Angle between Ground and X - | Ax | - pitch = arctan| ----------------------- | - | sqrt(Ay * Ay + Az * Az)| -*/ -inline qreal calcPitch(double Ax, double Ay, double Az) -{ - return -qAtan2(Ax, sqrt(Ay * Ay + Az * Az)); -} - -/* - Angle between Ground and Y - | Ay | - roll = arctan| ----------------------- | - | sqrt(Ax * Ax + Az * Az)| -*/ -inline qreal calcRoll(double Ax, double Ay, double Az) -{ - return qAtan2(Ay, (sqrt(Ax * Ax + Az * Az))); -} - -/*! - \qmlproperty real QtSensors5::TiltSensor::accuracy - This property contains the accuracy (in degrees) in which the rotation should be measured. - This can be used to minimize signal emiting and therefore saving of performance. - Default value is 1 degree. - The accuracy value is unsigned and works clockwise and counterclockwise in X and Y axis rotation - directions. Accuracy range can be 0 to 90 degrees. - - - For example: - Accuracy 5.5 will notify the client application about an rotation change only if the rotation angle over the X and / or Y axis was changed by 5.5 or more degrees clockwise or anti-clockwise. - - \table - \header \li Rotation \li notify application \li reason - \row \li 0.2424 \li no \li - \row \li 4.34234 \li no \li - \row \li 5.23423 \li no \li - \row \li 6.34324 \li yes \li because 6.34324 >= 5.5 - \row \li 7.43264 \li no \li - \row \li 8.24504 \li no \li - \row \li 9.34653 \li no \li - \row \li 10.23476 \li no \li - \row \li 11.43565 \li no \li - \row \li 12.45645 \li yes \li because 12.45645 - 6.34324 = 6.11321 >= 5.5 - \endtable -*/ -/*! - \qmlsignal QtSensors5::TiltSensor::tiltChanged(real deltaX, real deltaY) - This signal is emitted whenever the change from at leat one of the rotation values was higher than the accuracy. - The angle value is based on degrees. - -*/ - -//void QSensor2Tilt::setAccuracy(qreal val) -//{ -// //save in rad to save convertion calc in filter function -// if (val <= 90 && val >= 0) -// _radAccuracy = M_PI * val / 180; -//} - -/*! - \qmlmethod void QtSensors5::TiltSensor::calibrate() - The call of this function calibrates the tilt from x and y to the current position. -*/ -void QSensor2Tilt::calibrate() -{ - _calibratedPitch = _pitch; - _calibratedRoll = _roll; -#ifdef LOGCALIBRATION - qDebug() << "--------- calibrate --------"; - qDebug() << "_calibratedPitch: " << _calibratedPitch; - qDebug() << "_calibratedRoll: " << _calibratedRoll; - qDebug() << "----------------------------"; -#endif -} - -/*! - \qmlproperty real QtSensors5::TiltSensor::settings - This property contains the setting of the current state. - It can be used for saving and reloading previously saved calibrations. -*/ -QByteArray QSensor2Tilt::settings() const -{ - QByteArray arr; - arr.append(QString::number((double)_calibratedPitch)); - arr.append(";"); - arr.append(QString::number((double)_calibratedRoll)); - return arr; -} - -void QSensor2Tilt::setSettings(const QByteArray val) -{ - QString str(val); - if (str.indexOf(";") > 0){ - QStringList strlist = str.split(";"); - if (strlist.length() == 2){ - _calibratedPitch = strlist.at(0).toDouble(); - _calibratedRoll = strlist.at(1).toDouble(); - } - } -} - -bool QSensor2Tilt::filter(QAccelerometerReading* reading) -{ - /* - z y - | / - |/___ x - */ - - qreal ax = reading->x(); - qreal ay = reading->y(); - qreal az = reading->z(); -#ifdef LOGCALIBRATION - qDebug() << "------------ new value -----------"; - qDebug() << "old _pitch: " << _pitch; - qDebug() << "old _roll: " << _roll; - qDebug() << "_calibratedPitch: " << _calibratedPitch; - qDebug() << "_calibratedRoll: " << _calibratedRoll; -#endif - _pitch = calcPitch(ax, ay, az); - _roll = calcRoll (ax, ay, az); -#ifdef LOGCALIBRATION - qDebug() << "_pitch: " << _pitch; - qDebug() << "_roll: " << _roll; -#endif - qreal xrot = _roll - _calibratedRoll; - qreal yrot = _pitch - _calibratedPitch; - //get angle beteen 0 and 180 or 0 -180 - qreal aG = 1 * sin(xrot); - qreal aK = 1 * cos(xrot); - xrot = qAtan2(aG, aK); - if (xrot > M_PI_2) - xrot = M_PI - xrot; - else if (xrot < -M_PI_2) - xrot = -(M_PI + xrot); - aG = 1 * sin(yrot); - aK = 1 * cos(yrot); - yrot = qAtan2(aG, aK); - if (yrot > M_PI_2) - yrot = M_PI - yrot; - else if (yrot < -M_PI_2) - yrot = -(M_PI + yrot); - - -#ifdef LOGCALIBRATION - qDebug() << "new xrot: " << xrot; - qDebug() << "new yrot: " << yrot; - qDebug() << "----------------------------------"; -#endif - qreal dxrot = xrot - _xRotation; - qreal dyrot = yrot - _yRotation; - if (dxrot < 0) dxrot = -dxrot; - if (dyrot < 0) dyrot = -dyrot; - - bool change = false; - if (dxrot >= _radAccuracy){ - _xRotation = xrot; - Q_EMIT xRotationChanged(); - change = true; - } - if (dyrot >= _radAccuracy){ - _yRotation = yrot; - Q_EMIT yRotationChanged(); - change = true; - } - if (change){ - Q_EMIT tiltChanged(dxrot * 180 / M_PI, dyrot * 180 / M_PI); - } - return false; -} - -QT_END_NAMESPACE diff --git a/src/imports/sensors2/qsensor2tilt.h b/src/imports/sensors2/qsensor2tilt.h deleted file mode 100644 index 359db0d5..00000000 --- a/src/imports/sensors2/qsensor2tilt.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSEONSOR2TILT_H -#define QSEONSOR2TILT_H - -#include <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include <qaccelerometer.h> -#include "qsensor2common.h" - -QT_BEGIN_NAMESPACE - -class QSensor2Tilt : public qsensor2common, public QAccelerometerFilter -{ - Q_OBJECT - Q_ENUMS(Unit Speed) - Q_PROPERTY(qreal yRotation READ yRotation NOTIFY yRotationChanged) - Q_PROPERTY(qreal xRotation READ xRotation NOTIFY xRotationChanged) - Q_PROPERTY(Speed speed READ speed WRITE setSpeed NOTIFY speedChanged) - Q_PROPERTY(QByteArray settings READ settings WRITE setSettings) - -public: - QSensor2Tilt(QObject* parent = 0); - virtual ~QSensor2Tilt(); - Q_INVOKABLE void calibrate(); - - enum Speed{ - Slow = 0 - , Medium - , Fast - }; - - -Q_SIGNALS: - void yRotationChanged(); - void xRotationChanged(); - void speedChanged(); - void tiltChanged(qreal deltaX, qreal deltaY); - -public: - // Override of QAcclerometerFilter::filter(QAccelerometerReading*) - qreal yRotation(); - qreal xRotation(); - Speed speed(); - void setSpeed(const Speed val); - void setEnabled(bool val); - QByteArray settings() const; - void setSettings(const QByteArray val); - void createRunModeDataRateMap(); - QMap<Speed, int> dataRate(); - -private: - bool filter(QAccelerometerReading* reading); - - QSensor *sensor() { return _accel; } - QAccelerometer* _accel; - qreal _yRotation; - qreal _xRotation; - qreal _radAccuracy; - qreal _pitch; - qreal _roll; - qreal _calibratedPitch; - qreal _calibratedRoll; - QMap<Speed, int> _dataRate; - Speed _speed; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QSensor2Tilt) - -#endif // QSEONSOR2TILT_H diff --git a/src/imports/sensors2/sensors2.cpp b/src/imports/sensors2/sensors2.cpp deleted file mode 100644 index 061549db..00000000 --- a/src/imports/sensors2/sensors2.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include "qsensor2ambientlight.h" -#include "qsensor2proximity.h" -#include "qsensor2tilt.h" -#include "qsensor2gesture.h" -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -class QSensors2DeclarativeModule : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json") -public: - virtual void registerTypes(const char *uri) - { - qDebug() << "QSensors2DeclarativeModule::registerTypes(const char *uri)"; - Q_ASSERT(QLatin1String(uri) == QLatin1String("QtSensors")); - - qmlRegisterUncreatableType<qsensor2common >(uri, 5, 0, "Sensor", QLatin1String("Cannot create Sensor")); - qmlRegisterType <QSensor2Tilt >(uri, 5, 0, "TiltSensor"); - qmlRegisterType <QSensor2AmbientLight>(uri, 5, 0, "AmbientLightSensor"); - qmlRegisterType <QSensor2Proximity >(uri, 5, 0, "ProximitySensor"); - qmlRegisterType <QSensor2Gesture >(uri, 5, 0, "SensorGesture"); - } -}; - -QT_END_NAMESPACE - -#include "sensors2.moc" diff --git a/src/imports/sensors2/sensors2.pro b/src/imports/sensors2/sensors2.pro deleted file mode 100644 index 24f3fb93..00000000 --- a/src/imports/sensors2/sensors2.pro +++ /dev/null @@ -1,22 +0,0 @@ -CXX_MODULE = sensors -TARGET = declarative_qtsensors5 - -QT += qml sensors - -SOURCES += sensors2.cpp \ - qsensor2ambientlight.cpp \ - qsensor2proximity.cpp \ - qsensor2tilt.cpp \ - qsensor2gesture.cpp \ - qsensor2common.cpp - -HEADERS += qsensor2ambientlight.h \ - qsensor2proximity.h \ - qsensor2tilt.h \ - qsensor2gesture.h \ - qsensor2common.h - -load(qml_plugin) - -OTHER_FILES += \ - plugin.json qmldir plugins.qmltypes |