Commits

minirop  committed d99d00b

ask on closing window

  • Participants
  • Parent commits e388473

Comments (0)

Files changed (2)

File MainWindow.cpp

 #include <QTimer>
 #include <QFile>
 #include <QAction>
+#include <QFileDialog>
 
 bool MainWindow::isClosing = false;
 
 	}
 }
 
-void MainWindow::closeEvent(QCloseEvent*)
+void MainWindow::closeEvent(QCloseEvent * event)
 {
+	QMessageBox::StandardButton choice = QMessageBox::question(this, "Exit", "Do you really want to quit ? all unsaved progress will be lost", QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+	
+	if(choice == QMessageBox::No)
+	{
+		event->ignore();
+		return;
+	}
+	
 	if(m_gameWidget)
 		m_gameWidget->manageCloseEvent();
 }

File MainWindow.h

 	void hideOptions();
 
 protected:
-	void closeEvent(QCloseEvent* event);
+	void closeEvent(QCloseEvent * event);
 
 private:
 	void loadConfig();