diff options
Diffstat (limited to 'src/sensors')
-rw-r--r-- | src/sensors/qlightsensor.cpp | 28 | ||||
-rw-r--r-- | src/sensors/qlightsensor.h | 13 | ||||
-rw-r--r-- | src/sensors/qlightsensor_p.h | 11 |
3 files changed, 48 insertions, 4 deletions
diff --git a/src/sensors/qlightsensor.cpp b/src/sensors/qlightsensor.cpp index b712bb6..f02f6b1 100644 --- a/src/sensors/qlightsensor.cpp +++ b/src/sensors/qlightsensor.cpp @@ -120,7 +120,7 @@ char const * const QLightSensor::type("QLightSensor"); Construct the sensor as a child of \a parent. */ QLightSensor::QLightSensor(QObject *parent) - : QSensor(QLightSensor::type, parent) + : QSensor(QLightSensor::type, *new QLightSensorPrivate, parent) { } @@ -144,7 +144,33 @@ QLightSensor::~QLightSensor() \brief a value indicating the field of view. This is an angle that represents the field of view of the sensor. + + Not all light sensor support retrieving their field of view. For sensors + that don't support this property, the value will be 0. Whether the field of + view is supported can be checked with QSensor::isFeatureSupported() and the + QSensor::FieldOfView flag. +*/ + +qreal QLightSensor::fieldOfView() const +{ + Q_D(const QLightSensor); + return d->fieldOfView; +} + +/*! + \since 5.1 + + Sets the field of view. This is to be called from the + backend. */ +void QLightSensor::setFieldOfView(qreal fieldOfView) +{ + Q_D(QLightSensor); + if (d->fieldOfView != fieldOfView) { + d->fieldOfView = fieldOfView; + emit fieldOfViewChanged(fieldOfView); + } +} #include "moc_qlightsensor.cpp" QT_END_NAMESPACE diff --git a/src/sensors/qlightsensor.h b/src/sensors/qlightsensor.h index ddfca17..1da8449 100644 --- a/src/sensors/qlightsensor.h +++ b/src/sensors/qlightsensor.h @@ -66,19 +66,26 @@ private: bool filter(QSensorReading *reading) { return filter(static_cast<QLightReading*>(reading)); } }; +class QLightSensorPrivate; + class Q_SENSORS_EXPORT QLightSensor : public QSensor { Q_OBJECT -#ifdef Q_QDOC - Q_PROPERTY(qreal fieldOfView) -#endif + Q_PROPERTY(qreal fieldOfView READ fieldOfView NOTIFY fieldOfViewChanged) public: explicit QLightSensor(QObject *parent = 0); virtual ~QLightSensor(); QLightReading *reading() const { return static_cast<QLightReading*>(QSensor::reading()); } static char const * const type; + qreal fieldOfView() const; + void setFieldOfView(qreal fieldOfView); + +Q_SIGNALS: + void fieldOfViewChanged(qreal fieldOfView); + private: + Q_DECLARE_PRIVATE(QLightSensor) Q_DISABLE_COPY(QLightSensor) }; diff --git a/src/sensors/qlightsensor_p.h b/src/sensors/qlightsensor_p.h index bd0edfc..a9df63e 100644 --- a/src/sensors/qlightsensor_p.h +++ b/src/sensors/qlightsensor_p.h @@ -68,6 +68,17 @@ public: qreal lux; }; +class QLightSensorPrivate : public QSensorPrivate +{ +public: + QLightSensorPrivate() + : fieldOfView(0) + { + } + + qreal fieldOfView; +}; + QT_END_NAMESPACE #endif |