From 65329e998b27b5ccacd2d39c29a4d6b2fa8f2844 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Heli=20Hyv=C3=A4ttinen?= Date: Wed, 27 Jul 2011 09:47:26 +0300 Subject: [PATCH] Should pause at device lock 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 | 11 +++++++++++ seascene.h | 10 +++++++--- seaview.cpp | 4 ++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/seascene.cpp b/seascene.cpp index 5d1273f..b29c068 100644 --- a/seascene.cpp +++ b/seascene.cpp @@ -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); + } +} diff --git a/seascene.h b/seascene.h index aba6587..0900421 100644 --- a/seascene.h +++ b/seascene.h @@ -30,6 +30,9 @@ #include "level.h" #include #include +#include + +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 diff --git a/seaview.cpp b/seaview.cpp index 8b51b88..55cc504 100644 --- a/seaview.cpp +++ b/seaview.cpp @@ -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())); -- 1.7.9.5