diff options
author | Thomas McGuire <thomas.mcguire.qnx@kdab.com> | 2013-02-01 10:31:57 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-08 11:17:40 +0100 |
commit | b974efa5ca4306b1b9474207317ade4da33bdbc9 (patch) | |
tree | b7d242eea56196b23ffebacd5191f80d809afb3c /src/imports | |
parent | 270e896a26713cb4d7e7c5703a03413bce76e581 (diff) | |
download | qtsensors-b974efa5ca4306b1b9474207317ade4da33bdbc9.tar.gz |
Convert QLightSensor::fieldOfView to a proper property
Change-Id: Ic6e5388e0cbc2a0045157873c05aa241ffe5e82d
Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/sensors/plugins.qmltypes | 4 | ||||
-rw-r--r-- | src/imports/sensors/qmllightsensor.cpp | 10 | ||||
-rw-r--r-- | src/imports/sensors/qmllightsensor.h | 4 |
3 files changed, 8 insertions, 10 deletions
diff --git a/src/imports/sensors/plugins.qmltypes b/src/imports/sensors/plugins.qmltypes index b6f724a..88f61f9 100644 --- a/src/imports/sensors/plugins.qmltypes +++ b/src/imports/sensors/plugins.qmltypes @@ -107,6 +107,10 @@ Module { prototype: "QmlSensor" exports: ["LightSensor 5.0", "LightSensor 5.1"] Property { name: "fieldOfView"; type: "double"; isReadonly: true } + Signal { + name: "fieldOfViewChanged" + Parameter { name: "fieldOfView"; type: "double" } + } } Component { name: "QmlLightSensorReading" diff --git a/src/imports/sensors/qmllightsensor.cpp b/src/imports/sensors/qmllightsensor.cpp index 1c3fed2..86126a2 100644 --- a/src/imports/sensors/qmllightsensor.cpp +++ b/src/imports/sensors/qmllightsensor.cpp @@ -63,6 +63,8 @@ QmlLightSensor::QmlLightSensor(QObject *parent) : QmlSensor(parent) , m_sensor(new QLightSensor(this)) { + connect(m_sensor, SIGNAL(fieldOfViewChanged(qreal)), + this, SIGNAL(fieldOfViewChanged(qreal))); } QmlLightSensor::~QmlLightSensor() @@ -88,13 +90,7 @@ QSensor *QmlLightSensor::sensor() const qreal QmlLightSensor::fieldOfView() const { - return m_sensor->property("fieldOfView").value<qreal>(); -} - -void QmlLightSensor::_update() -{ - if (fieldOfView() != qreal()) - Q_EMIT fieldOfViewChanged(); + return m_sensor->fieldOfView(); } /*! diff --git a/src/imports/sensors/qmllightsensor.h b/src/imports/sensors/qmllightsensor.h index de7e394..e42d781 100644 --- a/src/imports/sensors/qmllightsensor.h +++ b/src/imports/sensors/qmllightsensor.h @@ -58,13 +58,11 @@ public: qreal fieldOfView() const; - Q_SIGNALS: - void fieldOfViewChanged(); + void fieldOfViewChanged(qreal fieldOfView); private: QSensor *sensor() const Q_DECL_OVERRIDE; - void _update(); QLightSensor *m_sensor; QmlSensorReading *createReading() const Q_DECL_OVERRIDE; }; |