Updated the web pages
[chessclock] / chessclockwindow.cpp
index 45a21b4..c5fde01 100644 (file)
@@ -25,6 +25,7 @@
 #include "classes/chessclockwidget.h"
 #include "classes/startwidget.h"
 #include "classes/timecontrol.h"
+#include "classes/turninformation.h"
 
 // Time controls
 #include "classes/timecontrol/notimecontrol.h"
@@ -41,6 +42,7 @@
 #include <QStackedWidget>
 #include <QProcess>
 
+
 ChessClockWindow::ChessClockWindow(QWidget *parent)
     : QMainWindow(parent)
 {
@@ -61,13 +63,19 @@ ChessClockWindow::ChessClockWindow(QWidget *parent)
 
     connect( start_, SIGNAL(selected(TimeControl*)), this, SLOT(startGame(TimeControl*)));
 
+
     // Set up menu
-    menuBar()->addAction( tr("Pause"), this, SLOT(pause()));
+//    menuBar()->addAction( tr("Pause"), this, SLOT(pause()));   // UNUSED - Pause button
     menuBar()->addAction( tr("New game"), this, SLOT(newGame()));
+
     menuBar()->addAction( tr("Visit web page"), this, SLOT(visitWeb()));
     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()
@@ -80,7 +88,7 @@ void ChessClockWindow::newGame()
 {
     pause();
     if(  clocks_ == 0 ||  !clocks_->isPlayStarted()  || QMessageBox::question(this, tr("Start new game"),
-                              tr("Really quit current game and start new one with current settings?"),
+                              tr("Really quit the current game and start a new one?"),
                               QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
     {
         stack_->setCurrentWidget(start_);
@@ -95,6 +103,7 @@ void ChessClockWindow::newGame()
 
 void ChessClockWindow::visitWeb()
 {
+    pause();
     QProcess* process = new QProcess(this);
     process->start(QString("browser --url=chessclock.garage.maemo.org"));
 }
@@ -106,7 +115,7 @@ void ChessClockWindow::about()
                        tr("<h1>Chess Clock %1</h1>"
                           "&copy;Arto Hyv&auml;ttinen 2010"
                           "<p>Chess Clock is free software under the terms of GNU General Public License 3"
-                          "<p>Bugtracker and instructions at <a>checkclock.garage.maemo.org</a>"
+                          "<p>Bugtracker and instructions at <a>http://chessclock.garage.maemo.org</a>"
                           ).arg(qApp->applicationVersion())) ;
 }
 
@@ -136,6 +145,7 @@ void ChessClockWindow::startGame(TimeControl *timecontrol)
         clocks_ = newWidget;
         stack_->addWidget(clocks_);
         stack_->setCurrentWidget(clocks_);
+        connect( clocks_, SIGNAL(TurnFinished(TurnInformation*)), this, SLOT(dontEatMemory(TurnInformation*)));
     }
 }
 
@@ -144,3 +154,19 @@ 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);
+    }
+}
+
+void ChessClockWindow::dontEatMemory(TurnInformation *turnInformation)
+{
+    delete turnInformation; // hopefully don't cause Segematation Fault
+}