Polls for screen locked status
[ghostsoverboard] / seascene.cpp
index 5d1273f..9ee3925 100644 (file)
@@ -90,6 +90,11 @@ SeaScene::SeaScene(QObject *parent) :
     connect(pPauseAction_,SIGNAL(toggled(bool)),this,SLOT(pause(bool)));
 
 
+    deviceLockPollTimer_.setInterval(20*60); // 2s
+    connect(&deviceLockPollTimer_,SIGNAL(timeout()),this,SLOT(pollDeviceLocked()));
+    deviceLockPollTimer_.start();
+
+
     autopauseTimer.setSingleShot(true);
     autopauseTimer.setInterval(15*60*1000);
     connect(&autopauseTimer,SIGNAL(timeout()),this,SLOT(turnPauseOn()));
@@ -364,6 +369,7 @@ void SeaScene::pause(bool paused)
                 pPausetextItem_->hide();
 
             autopauseTimer.start(); //Start counting towards autopause
+            deviceLockPollTimer_.start(); //Start polling whether device is locked
         }
 
         else
@@ -380,6 +386,7 @@ void SeaScene::pause(bool paused)
 //                else qDebug() << "No pause text available";
 
             autopauseTimer.stop(); //No need to count toward autopause when already paused
+            deviceLockPollTimer_.stop(); //No need to check for unlock as no unpause anyway
         }
 }
 
@@ -712,3 +719,32 @@ void SeaScene::turnPauseOn()
 {
     pPauseAction_->setChecked(true);
 }
+
+void SeaScene::handleDeviceLocked(bool isLocked)
+{
+    //pauses if locked but does not unpause if unlocked
+    if(isLocked)
+    {
+        pPauseAction_->setChecked(true);
+    }
+}
+
+void SeaScene::pollDeviceLocked()
+{
+
+    bool locked = deviceInfo_.isDeviceLocked();
+
+    if (locked)
+    {
+        if (!alreadyLocked_)
+        {
+            pPauseAction_->setChecked(true);
+            alreadyLocked_ = true;
+        }
+
+    else
+        {
+            alreadyLocked_ = false;
+        }
+    }
+}