From: Heli Hyvättinen Date: Mon, 11 Oct 2010 15:27:03 +0000 (+0300) Subject: Added game pausing when the application is minimized X-Git-Tag: v1.9.0~77 X-Git-Url: http://vcs.maemo.org/git/?p=chessclock;a=commitdiff_plain;h=e43c493689b3e5a28625a293f811a888bd5042e8 Added game pausing when the application is minimized --- diff --git a/chessclockwindow.cpp b/chessclockwindow.cpp index ea0d746..2a7c7cb 100644 --- a/chessclockwindow.cpp +++ b/chessclockwindow.cpp @@ -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); + } +} diff --git a/chessclockwindow.h b/chessclockwindow.h index d17d979..4fe01c5 100644 --- a/chessclockwindow.h +++ b/chessclockwindow.h @@ -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_; diff --git a/main.cpp b/main.cpp index a92f7ec..6a3656c 100644 --- 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;