Added game pausing when the application is minimized
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 11 Oct 2010 15:27:03 +0000 (18:27 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 11 Oct 2010 15:27:03 +0000 (18:27 +0300)
chessclockwindow.cpp
chessclockwindow.h
main.cpp

index ea0d746..2a7c7cb 100644 (file)
@@ -71,6 +71,10 @@ ChessClockWindow::ChessClockWindow(QWidget *parent)
     menuBar()->addAction( tr("About"),this, SLOT(about()));
     menuBar()->addAction(tr("About Qt"), this, SLOT(aboutQt()));
 
+    //set the event filter to grap window deactivate
+
+    installEventFilter(this);
+
 }
 
 void ChessClockWindow::pause()
@@ -148,3 +152,14 @@ ChessClockWindow::~ChessClockWindow()
 {
 
 }
+
+bool ChessClockWindow::eventFilter(QObject *obj, QEvent *event)
+{
+    if (event->type() == QEvent::WindowDeactivate) {
+        pause();
+        return QObject::eventFilter(obj,event);
+    } else {
+        // standard event processing
+        return QObject::eventFilter(obj, event);
+    }
+}
index d17d979..4fe01c5 100644 (file)
@@ -49,6 +49,8 @@ public slots:
 
 protected:
     void initTimeControls();
+    /*! Pauses the game if the application main window is not active e.g. the app is minimized*/
+    bool eventFilter(QObject *obj, QEvent *event);
 
 protected:
     ClocksWidget*   clocks_;
index a92f7ec..6a3656c 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
     a.setApplicationName( a.tr("Chess Clock","Application name") );
     a.setOrganizationName("Chess Clock");
     a.setOrganizationDomain("chessclock.garage.maemo.org");
-    a.setApplicationVersion("1.1.0");
+    a.setApplicationVersion("1.1.1");
 
     ChessClockWindow w;