summaryrefslogtreecommitdiffstats
path: root/src/imports/sensors2
diff options
context:
space:
mode:
authorWolfgang Beck <wolfgang.beck@nokia.com>2011-09-28 13:55:12 +1000
committerLincoln Ramsay <lincoln.ramsay@nokia.com>2011-10-10 09:25:31 +1000
commitc25e4e542fd846facb1ca250d44829c0121abdd2 (patch)
treed9133e16dd718488d3d8e22216747b0c9cc6430c /src/imports/sensors2
parent4e04cda0e600f4e3bb148956ba631647a5c1fa4c (diff)
MTMW356 Coderevew changes for the AmbientLightSensor QML Element
Change-Id: Ic5ceb21897fdf65ca611ad5ff4c7ac397b44547c Reviewed-on: http://codereview.qt-project.org/5664 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Wolfgang Beck <wolfgang.beck@nokia.com>
Diffstat (limited to 'src/imports/sensors2')
-rw-r--r--src/imports/sensors2/qsensor2ambientlight.cpp76
-rw-r--r--src/imports/sensors2/qsensor2ambientlight.h13
2 files changed, 36 insertions, 53 deletions
diff --git a/src/imports/sensors2/qsensor2ambientlight.cpp b/src/imports/sensors2/qsensor2ambientlight.cpp
index e2a99510..376b8919 100644
--- a/src/imports/sensors2/qsensor2ambientlight.cpp
+++ b/src/imports/sensors2/qsensor2ambientlight.cpp
@@ -52,37 +52,10 @@ QT_BEGIN_NAMESPACE
\brief The AmbientLightSensor element provide an easy access to determine the ambient light by using the ambient light sensor.
This element is part of the \bold{QtSensors 5} module.
-
- \target lightLevelenum
- \section1 Enums
- \section2 AmbientLightSensor::LighLevel
-
- This enum describes the ambient light levels.
-
- \table
- \row
- \o AmbientLightSensor::Undefined
- \o Ambient light not defined.
- \row
- \o AmbientLightSensor::Dark
- \o Ambient light is dark.
- \row
- \o AmbientLightSensor::Twilight
- \o Ambient light is twilight.
- \row
- \o AmbientLightSensor::Light
- \o Ambient light is light.
- \row
- \o AmbientLightSensor::Bright
- \o Ambient light is bright.
- \row
- \o AmbientLightSensor::Sunny
- \o Ambient light is sunny.
- \endtable
*/
QSensor2AmbientLight::QSensor2AmbientLight(QObject* parent)
: QObject(parent)
- , _lightLevel(QSensor2AmbientLight::Undefined)
+ , _lightLevel(QSensor2AmbientLight::Unknown)
{
_ambientLight = new QAmbientLightSensor(this);
_ambientLight->addFilter(this);
@@ -94,21 +67,17 @@ QSensor2AmbientLight::~QSensor2AmbientLight()
}
/*!
- \qmlproperty bool QtSensors5::AmbientLightSensor::running
- Holds the identication if the sensor runs or not.
-*/
-/*!
- \qmlsignal QtSensors5::AmbientLightSensor::onRunningChanged()
- This signal is emitted whenever the value of the property running has been changed.
+ \qmlproperty bool QtSensors5::QSensor2AmbientLight::enabled
+ This property can be used to activate or deactivate the sensor.
*/
-bool QSensor2AmbientLight::running()
+bool QSensor2AmbientLight::enabled()
{
return _ambientLight->isActive();
}
-void QSensor2AmbientLight::setRunning(bool val)
+void QSensor2AmbientLight::setEnabled(bool val)
{
- bool active = running();
+ bool active = enabled();
if (active != val){
if (val){
bool ret = _ambientLight->start();
@@ -117,20 +86,35 @@ void QSensor2AmbientLight::setRunning(bool val)
}
else
_ambientLight->stop();
- emit runningChanged();
+ emit enabledChanged();
}
}
/*!
- \qmlproperty AmbientLightSensor::LightLevel QtSensors5::AmbientLightSensor::lightLevel
- Holds the ambient light level.
- \sa {lightLevelenum} {AmbientLightSensor::LighLevel}
-*/
-/*!
- \qmlsignal QtSensors5::AmbientLightSensor::onLightLevelChanged()
- This signal is emitted whenever the value of the property lightLevel has been changed.
-*/
+ \qmlproperty enumeration QtSensors5::AmbientLightSensor::lightLevel
+ Holds the ambient light level in the form of the LightLevel enum:
+ \table
+ \row
+ \o AmbientLightSensor.Unknown
+ \o Ambient light value is not set yet.
+ \row
+ \o AmbientLightSensor.Dark
+ \o It is dark.
+ \row
+ \o AmbientLightSensor.Twilight
+ \o It is moderately dark.
+ \row
+ \o AmbientLightSensor.Light
+ \o It is light (eg. internal lights).
+ \row
+ \o AmbientLightSensor.Bright
+ \o It is bright (eg. shade).
+ \row
+ \o AmbientLightSensor.Sunny
+ \o It is very bright (eg. direct sunlight).
+ \endtable
+*/
QSensor2AmbientLight::LightLevel QSensor2AmbientLight::lightLevel()
{
return _lightLevel;
diff --git a/src/imports/sensors2/qsensor2ambientlight.h b/src/imports/sensors2/qsensor2ambientlight.h
index 5b9a516a..e111508a 100644
--- a/src/imports/sensors2/qsensor2ambientlight.h
+++ b/src/imports/sensors2/qsensor2ambientlight.h
@@ -52,14 +52,14 @@ class QSensor2AmbientLight : public QObject, public QAmbientLightFilter
Q_OBJECT
Q_ENUMS(LightLevel)
Q_PROPERTY(LightLevel lightLevel READ lightLevel NOTIFY lightLevelChanged)
- Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
public:
QSensor2AmbientLight(QObject* parent = 0);
virtual ~QSensor2AmbientLight();
enum LightLevel {
- Undefined = 0,
+ Unknown = 0,
Dark,
Twilight,
Light,
@@ -69,22 +69,21 @@ public:
Q_SIGNALS:
void lightLevelChanged();
- void runningChanged();
+ void enabledChanged();
private:
// Override of QAmbientLightFilter::filter(QAmbientLightReading*)
bool filter(QAmbientLightReading *reading);
LightLevel lightLevel();
- bool running();
- void setRunning(bool val);
+ bool enabled();
+ void setEnabled(bool val);
QAmbientLightSensor* _ambientLight;
LightLevel _lightLevel;
};
-QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QSensor2AmbientLight))
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QSensor2AmbientLight)
#endif // QSENSOR2AMBIENTLIGHT_H