From 624b98e3fdcba3cbaa1595166205a2367613c07d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timo=20H=C3=A4rk=C3=B6nen?= Date: Thu, 2 Sep 2010 20:40:50 +0300 Subject: [PATCH 1/1] save game query on exit if game is incomplete --- debian/changelog | 7 +++++++ src/gameview.cpp | 14 -------------- src/gameview.h | 3 --- src/mainwindow.cpp | 17 +++++++++++++++++ src/mainwindow.h | 3 +++ 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/debian/changelog b/debian/changelog index ba85419..bd7aadd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +impuzzle (0.6.3-1maemo0) unstable; urgency=low + + * Show save game query when quitting if game is incomplete + * Changed new game dialog logic. + + -- Timo Härkönen Thu, 2 Sep 2010 20:38:00 +0200 + impuzzle (0.6.2-1maemo0) unstable; urgency=low * Fixes: Application crash if Mydocs/.images empty diff --git a/src/gameview.cpp b/src/gameview.cpp index ad51a83..4164b24 100644 --- a/src/gameview.cpp +++ b/src/gameview.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -589,19 +588,6 @@ void GameView::saveGame() qApp->quit(); } -void GameView::closeEvent(QCloseEvent *event) -{ - int answer = QMessageBox::question(this, tr("Save game status?"), - tr("Saved status will be automatically loaded when you start the application next time"), - QMessageBox::Yes, QMessageBox::No); - - if(answer == QMessageBox::Yes) { - saveGame(); - } - - event->accept(); -} - int GameView::correctPlaces() const { int c = 0; diff --git a/src/gameview.h b/src/gameview.h index 4e8d6d0..4656cde 100644 --- a/src/gameview.h +++ b/src/gameview.h @@ -50,9 +50,6 @@ signals: void gameWon(); void gameRestored(); -protected: - void closeEvent(QCloseEvent *event); - private: GameView(QWidget *parent = 0); int correctPlaces() const; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e2b2b19..bb6ac1b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include @@ -122,3 +124,18 @@ void MainWindow::enableSaving() saveAction_->setEnabled(true); } } + +void MainWindow::closeEvent(QCloseEvent *event) +{ + if(saveAction_->isEnabled()) { + int answer = QMessageBox::question(this, tr("Save game status?"), + tr("Saved status will be automatically loaded when you start the application next time"), + QMessageBox::Yes, QMessageBox::No); + + if(answer == QMessageBox::Yes) { + GameView::instance()->saveGame(); + } + } + + event->accept(); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 097be48..2ce4607 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -41,6 +41,9 @@ private slots: void gameEnded(); void enableSaving(); +protected: + void closeEvent(QCloseEvent *event); + private: MainWindow(QWidget *parent = 0); void createActions(); -- 1.7.9.5