Don't disable GPS when we are obscured by location-ui or conndlgs
[harmattan/cameraplus] / src / harmattan / displaystate.cpp
index cb612bc..a4ce3fc 100644 (file)
 #include <QDebug>
 
 DisplayState::DisplayState(QObject *parent) :
-  QObject(parent), m_state(new MeeGo::QmDisplayState(this)), m_timer(new QTimer(this)) {
+  QObject(parent),
+  m_state(new MeeGo::QmDisplayState(this)),
+  m_timer(new QTimer(this)) {
 
   m_timer->setSingleShot(false);
   m_timer->setInterval(50 * 1000);
 
   QObject::connect(m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
+
+  QObject::connect(m_state, SIGNAL(displayStateChanged(MeeGo::QmDisplayState::DisplayState)),
+                  this, SLOT(displayStateChanged()));
 }
 
 DisplayState::~DisplayState() {
@@ -69,3 +74,11 @@ void DisplayState::timeout() {
     qWarning() << "Failed to inhibit display dimming!";
   }
 }
+
+bool DisplayState::isOn() {
+  return m_state->get() == MeeGo::QmDisplayState::On;
+}
+
+void DisplayState::displayStateChanged() {
+  emit isOnChanged();
+}