mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
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>
This commit is contained in:
parent
920a2069b0
commit
af2354c1f3
1 changed files with 12 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue