Added game pausing when the application is minimized
[chessclock] / chessclockwindow.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);
+    }
+}