Mercurial > hg > octave-nkf
changeset 16018:e0df71fbe39b
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
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 08 Feb 2013 16:05:04 +0100 |
parents | 06187a0b7a62 |
children | 5b2126a8c84f |
files | libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h |
diffstat | 2 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -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 ();
--- a/libgui/src/m-editor/file-editor-tab.h +++ b/libgui/src/m-editor/file-editor-tab.h @@ -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);