Mercurial > octave
changeset 18639:7cb98e81ecd1 gui-release
GUI: Prompt to exit Octave option (Bug #41080)
* libgui/src/settings-dialog.ui: Add prompt to exit checkbox.
* libgui/src/main-window.cc, libgui/src/main-window.h:
(main_window::confirm_exit_octave): New function.
(main_window::closeEvent): call prompt/check function before exit.
* libgui/src/settings-dialog.cc:
(settings_dialog::settings_dialog): Load prompt_on_exit setting.
(settings_dialog::write_changed_settings): Save prompt on exit settings.
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Mon, 07 Apr 2014 13:31:33 -0400 |
parents | 5b6901b06106 |
children | 992b6354c8c6 |
files | libgui/src/main-window.cc libgui/src/main-window.h libgui/src/settings-dialog.cc libgui/src/settings-dialog.ui |
diffstat | 4 files changed, 40 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Sun Apr 06 13:37:23 2014 -0700 +++ b/libgui/src/main-window.cc Mon Apr 07 13:31:33 2014 -0400 @@ -894,7 +894,8 @@ main_window::closeEvent (QCloseEvent *e) { e->ignore (); - octave_link::post_event (this, &main_window::exit_callback); + if (confirm_exit_octave()) + octave_link::post_event (this, &main_window::exit_callback); } void @@ -2365,3 +2366,25 @@ { _clipboard->clear (QClipboard::Clipboard); } + +bool +main_window::confirm_exit_octave () +{ + bool closenow = true; + + QSettings *settings = resource_manager::get_settings (); + + if (settings->value ("prompt_to_exit", false ).toBool()) + { + int ans = QMessageBox::question (this, tr ("Octave"), + tr ("Are you sure you want to exit Octave?"), + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); + + if (ans != QMessageBox::Ok) + closenow = false; + + } + return closenow; +} + +
--- a/libgui/src/main-window.h Sun Apr 06 13:37:23 2014 -0700 +++ b/libgui/src/main-window.h Mon Apr 07 13:31:33 2014 -0400 @@ -271,6 +271,8 @@ void execute_debug_callback (); + bool confirm_exit_octave (); + workspace_model *_workspace_model; // Toolbars.
--- a/libgui/src/settings-dialog.cc Sun Apr 06 13:37:23 2014 -0700 +++ b/libgui/src/settings-dialog.cc Mon Apr 07 13:31:33 2014 -0400 @@ -118,6 +118,10 @@ ui->cb_widget_custom_style->setChecked ( settings->value ("DockWidgets/widget_title_custom_style",false).toBool ()); + // prompt on exit + ui->cb_prompt_to_exit->setChecked ( + settings->value ("prompt_to_exit",false).toBool ()); + // Octave startup ui->cb_restore_octave_dir->setChecked ( settings->value ("restore_octave_dir",false).toBool ()); @@ -538,6 +542,9 @@ // icon size settings->setValue ("toolbar_icon_size", ui->toolbar_icon_size->value ()); + // promp to exit + settings->setValue ( "prompt_to_exit", ui->cb_prompt_to_exit->isChecked ()); + // Octave startup settings->setValue ("restore_octave_dir", ui->cb_restore_octave_dir->isChecked ());
--- a/libgui/src/settings-dialog.ui Sun Apr 06 13:37:23 2014 -0700 +++ b/libgui/src/settings-dialog.ui Mon Apr 07 13:31:33 2014 -0400 @@ -103,6 +103,13 @@ </property> </widget> </item> + <item row="5" column="0"> + <widget class="QCheckBox" name="cb_prompt_to_exit"> + <property name="text"> + <string>Confirm before exiting</string> + </property> + </widget> + </item> <item row="4" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_4"> <item>