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:
Dirk Hohndel 2013-05-19 14:46:53 -07:00
parent 920a2069b0
commit af2354c1f3

View file

@ -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;
}