Should pause at device lock
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Wed, 27 Jul 2011 06:47:26 +0000 (09:47 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Wed, 27 Jul 2011 06:47:26 +0000 (09:47 +0300)
Would fix the bug that device unlocks itself a while after being locked
by user by lock key.
Also moved to use normal pause when app goes background and not
unpausing when going foreground. Former way was bug risky.

The signal used would require QtMobility 1.2. That would lock the app
into extras-devel until 1.2 gets to extras, if ever.

seascene.cpp
seascene.h
seaview.cpp

index 5d1273f..b29c068 100644 (file)
@@ -89,6 +89,8 @@ SeaScene::SeaScene(QObject *parent) :
     pPauseAction_->setCheckable(true);
     connect(pPauseAction_,SIGNAL(toggled(bool)),this,SLOT(pause(bool)));
 
+    connect(&deviceInfo_,SIGNAL(lockStatusChanged(bool)),this,SLOT(handleDeviceLocked(bool)));
+
 
     autopauseTimer.setSingleShot(true);
     autopauseTimer.setInterval(15*60*1000);
@@ -712,3 +714,12 @@ 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);
+    }
+}
index aba6587..0900421 100644 (file)
@@ -30,6 +30,9 @@
 #include "level.h"
 #include <QAction>
 #include <QTimer>
+#include <QSystemDeviceInfo>
+
+using namespace QtMobility;
 
 class SeaScene : public QGraphicsScene
 {
@@ -90,6 +93,8 @@ public slots:
 
     void turnPauseOn();
 
+    void handleDeviceLocked(bool isLocked);
+
 
 
 protected:
@@ -118,7 +123,6 @@ protected:
 
     ScreenLitKeeper screenLitKeeper_;
 
-
     int menuItemCount_;
 
     QGraphicsTextItem * pPausetextItem_;
@@ -142,10 +146,10 @@ protected:
 
     QAction* pPauseAction_;
 
-    bool pauseForced_;
-
     QTimer autopauseTimer;
 
+    QSystemDeviceInfo deviceInfo_;
+
 };
 
 #endif // SEASCENE_H
index 8b51b88..55cc504 100644 (file)
@@ -39,8 +39,8 @@ SeaView::SeaView(QWidget *parent) :
 
 
     connect(this,SIGNAL(screenTapped()),pScene_,SLOT(handleScreenTapped()));
-    connect(this,SIGNAL(goingBackgroung()),pScene_,SLOT(forcePause()));
-    connect(this,SIGNAL(goingForeground()),pScene_,SLOT(softContinue()));
+    connect(this,SIGNAL(goingBackgroung()),pScene_,SLOT(turnPauseOn()));
+//    connect(this,SIGNAL(goingForeground()),pScene_,SLOT(softContinue()));
 
     connect(pScene_,SIGNAL(minimizeRequested()),this,SLOT(showNormal()));
     connect(pScene_,SIGNAL(fullscreenRequested()),this,SLOT(showFullScreen()));