Merge branch 'autopause3' into harmattan
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sat, 23 Jul 2011 09:10:47 +0000 (12:10 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sat, 23 Jul 2011 09:10:47 +0000 (12:10 +0300)
seascene.cpp
seascene.h

index 3062678..cb77b10 100644 (file)
@@ -87,6 +87,11 @@ SeaScene::SeaScene(QObject *parent) :
     connect(pPauseAction_,SIGNAL(toggled(bool)),this,SLOT(pause(bool)));
 
 
+    autopauseTimer.setSingleShot(true);
+    autopauseTimer.setInterval(15*60*1000);
+    connect(&autopauseTimer,SIGNAL(timeout()),this,SLOT(forcePause()));
+
+
 }
 
 void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
@@ -213,6 +218,8 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
         connect(pOctopus,SIGNAL(droppingGhosts()),pShip,SLOT(dropAllGhosts()));
     }
     delete pPosition;
+
+
 }
 
 void SeaScene::setupMap(Level level)
@@ -344,6 +351,8 @@ void SeaScene::pause(bool paused)
             screenLitKeeper_.keepScreenLit(true);
             if (pPausetextItem_)
                 pPausetextItem_->hide();
+
+            autopauseTimer.start(); //Start counting towards autopause
         }
 
         else
@@ -358,6 +367,8 @@ void SeaScene::pause(bool paused)
                 qDebug() << "showing pause text";
             }
                 else qDebug() << "No pause text available";
+
+            autopauseTimer.stop(); //No need to count toward autopause when already paused
         }
 }
 
@@ -543,6 +554,7 @@ void SeaScene::restartLevel()
     setupMap(levelList_.value(currentLevel_));  //value() returns default constructor Level if index is invalid, so no risk of crash
     vibrationActivate(pVibrateAction_->isChecked());  //Vibration effects are lost without this
    // qDebug() << pVibrateAction_->isChecked();
+    autopauseTimer.start();  //reset counting towards autopause
 }
 
 
index 5fce73f..0e2a513 100644 (file)
@@ -29,6 +29,7 @@
 #include "screenlitkeeper.h"
 #include "level.h"
 #include <QAction>
+#include <QTimer>
 
 class SeaScene : public QGraphicsScene
 {
@@ -129,6 +130,7 @@ protected:
 
     bool pauseForced_;
 
+    QTimer autopauseTimer;
 
 };