# HG changeset patch # User Torsten # Date 1360335904 -3600 # Node ID e0df71fbe39bbba493a5e3f476a711dd9c0e0a86 # Parent 06187a0b7a62cbf771a74f581203f251fcdbbc4e gui: clearer message box with cancel button when closing an unsaved editor file * file-editor-tab.cc (check_file_modified): buttons in message box are save, discard and cancel, save is default; removed unused parameters * file-editor-tab.cc (handle_file_modified_answer): adjust button names * file-editor-tab.h: removed unused parameters from check_file_modified diff -r 06187a0b7a62 -r e0df71fbe39b libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Fri Feb 08 10:55:39 2013 +0100 +++ b/libgui/src/m-editor/file-editor-tab.cc Fri Feb 08 16:05:04 2013 +0100 @@ -142,8 +142,7 @@ { // ignore close event if file is not saved and user cancels // closing this window - if (check_file_modified ("Close File", - QMessageBox::Cancel) == QMessageBox::Cancel) + if (check_file_modified () == QMessageBox::Cancel) { e->ignore (); } @@ -691,7 +690,7 @@ } int -file_editor_tab::check_file_modified (const QString&, int) +file_editor_tab::check_file_modified () { int decision = QMessageBox::Yes; if (_edit_area->isModified ()) @@ -700,9 +699,14 @@ // editor tab can't be made parent because it may be deleted depending // upon the response. Instead, change the _edit_area to read only. QMessageBox* msgBox = new QMessageBox ( - QMessageBox::Warning, tr ("Octave Editor"), - tr ("The file \'%1\' has been modified. Do you want to save the changes?"). - arg (_file_name), QMessageBox::Yes | QMessageBox::No, 0); + QMessageBox::Warning, tr ("Octave Editor"), + tr ("The file\n" + "%1\n" + "is about to be closed but has been modified.\n" + "Do you want to cancel closing, save or discard the changes?"). + arg (_file_name), + QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard, 0); + msgBox->setDefaultButton (QMessageBox::Save); _edit_area->setReadOnly (true); connect (msgBox, SIGNAL (finished (int)), this, SLOT (handle_file_modified_answer (int))); @@ -723,12 +727,12 @@ void file_editor_tab::handle_file_modified_answer (int decision) { - if (decision == QMessageBox::Yes) + if (decision == QMessageBox::Save) { // Save file, then remove from editor. save_file (_file_name, true); } - else if (decision == QMessageBox::No) + else if (decision == QMessageBox::Discard) { // User doesn't want to save, just remove from editor. emit tab_remove_request (); diff -r 06187a0b7a62 -r e0df71fbe39b libgui/src/m-editor/file-editor-tab.h --- a/libgui/src/m-editor/file-editor-tab.h Fri Feb 08 10:55:39 2013 +0100 +++ b/libgui/src/m-editor/file-editor-tab.h Fri Feb 08 16:05:04 2013 +0100 @@ -133,7 +133,7 @@ void request_add_breakpoint (int line); void request_remove_breakpoint (int line); - int check_file_modified (const QString& msg, int cancelButton); + int check_file_modified (); void do_comment_selected_text (bool comment); void run_file_callback (void);