summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-19 14:46:53 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-19 14:48:25 -0700
commitaf2354c1f310ee2982ef2541668d23b09f786874 (patch)
tree833a3deef9a5486a08273b79253cd589ddf3491f /qt-ui
parent920a2069b07586b0855617c4099ea405cabb594e (diff)
downloadsubsurface-af2354c1f310ee2982ef2541668d23b09f786874.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/mainwindow.cpp15
1 files changed, 12 insertions, 3 deletions
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;
}