From af2354c1f310ee2982ef2541668d23b09f786874 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 19 May 2013 14:46:53 -0700 Subject: Show the correct question at exit when there are unsaved changes We want to give the user the option to 'cancel' and not exit the program, to 'save' the file, or to say I'm 'OK' with losing the unsaved data. This does NOT implement the actual save / save-as, yet. Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index eed9aa883..3ee8dc29a 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -284,13 +284,22 @@ QString MainWindow::filter() bool MainWindow::askSaveChanges() { - QString message = ! existing_filename ? tr("You have unsaved changes\nWould you like to save those before closing the datafile?") - : tr("You have unsaved changes to file: %1 \nWould you like to save those before closing the datafile?").arg(existing_filename); + QString message; + QMessageBox::StandardButton response; - if (QMessageBox::question(this, tr("Save Changes?"), message) == QMessageBox::Ok) { + if (existing_filename) + message = tr("You have unsaved changes to file: %1\nDo you really want to close the file without saving?").arg(existing_filename); + else + message = tr("You have unsaved changes\nDo you really want to close the datafile without saving?"); + + response = QMessageBox::question(this, tr("Save Changes?"), message, + QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Ok, QMessageBox::Save); + if (response == QMessageBox::Save) { // WARNING: Port. // file_save(NULL,NULL); return true; + } else if (response == QMessageBox::Ok) { + return true; } return false; } -- cgit v1.2.3-70-g09d2