Mercurial > octave-nkf
changeset 19698:ff56a9899101
fix new shortcut dialog when applying new settings (fix #44196)
* settings-dialog.cc (write_changed_settings): new boolean parameter whether
settings dialog is closing or not, calling function for writing the shortcuts
with this parameter;
(button_clicked): calling write_changed_settings with new flag set to false
when button with accept role was clicked
* settings-dialog.h: write_changed_settings with boolean parameter
* shortcut-manager.cc (do_write_shortcuts): delete shortcut dialog only if
settings dialog is closing, setting to 0 after deletion;
(do_import_export): call do_write_shortcuts with new flag
* shortcut-manager.h: do_/write_shortcuts with new boolean parameter
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 06 Feb 2015 22:55:01 +0100 |
parents | dfea01b3425f |
children | 409d82472aee |
files | libgui/src/settings-dialog.cc libgui/src/settings-dialog.h libgui/src/shortcut-manager.cc libgui/src/shortcut-manager.h |
diffstat | 4 files changed, 15 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/settings-dialog.cc Fri Feb 06 13:06:54 2015 -0500 +++ b/libgui/src/settings-dialog.cc Fri Feb 06 22:55:01 2015 +0100 @@ -609,7 +609,7 @@ } void -settings_dialog::write_changed_settings () +settings_dialog::write_changed_settings (bool closing) { QSettings *settings = resource_manager::get_settings (); // FIXME: what should happen if settings is 0? @@ -823,7 +823,7 @@ if (ui->rb_sc_set2->isChecked ()) set = 1; settings->setValue ("shortcuts/set",set); - shortcut_manager::write_shortcuts (0, settings); // 0: write both sets + shortcut_manager::write_shortcuts (0, settings, closing); // 0: write both sets // settings dialog's geometry settings->setValue ("settings/last_tab",ui->tabWidget->currentIndex ()); @@ -963,7 +963,7 @@ if (button_role == QDialogButtonBox::ApplyRole || button_role == QDialogButtonBox::AcceptRole) { - write_changed_settings (); + write_changed_settings (button_role == QDialogButtonBox::AcceptRole); emit apply_new_settings (); }
--- a/libgui/src/settings-dialog.h Fri Feb 06 13:06:54 2015 -0500 +++ b/libgui/src/settings-dialog.h Fri Feb 06 22:55:01 2015 +0100 @@ -74,7 +74,7 @@ MaxStyleNumber = 128 }; #endif - void write_changed_settings (); + void write_changed_settings (bool closing); void read_workspace_colors (QSettings *settings); void write_workspace_colors (QSettings *settings);
--- a/libgui/src/shortcut-manager.cc Fri Feb 06 13:06:54 2015 -0500 +++ b/libgui/src/shortcut-manager.cc Fri Feb 06 22:55:01 2015 +0100 @@ -419,7 +419,7 @@ // write one or all actual shortcut set(s) into a settings file void -shortcut_manager::do_write_shortcuts (int set, QSettings* settings) +shortcut_manager::do_write_shortcuts (int set, QSettings* settings, bool closing) { if (set) { @@ -442,7 +442,12 @@ settings->setValue("shortcuts/"+_sc.at (i).settings_key+"_1", _sc.at (i).actual_sc[1].toString ()); } - delete _dialog; // the dialog for key sequences can be removed now + + if (closing) + { + delete _dialog; // the dialog for key sequences can be removed now + _dialog = 0; // make sure it is zero again + } } settings->sync (); // sync the settings file @@ -666,7 +671,7 @@ if (import) import_shortcuts (set, osc_settings); // import (special action) else - do_write_shortcuts (set, osc_settings); // export, like saving settings + do_write_shortcuts (set, osc_settings, false); // export, (saving settings) } else qWarning () << tr ("Failed to open %1 as octave shortcut file"). arg (file);
--- a/libgui/src/shortcut-manager.h Fri Feb 06 13:06:54 2015 -0500 +++ b/libgui/src/shortcut-manager.h Fri Feb 06 22:55:01 2015 +0100 @@ -63,10 +63,10 @@ instance->do_init_data (); } - static void write_shortcuts (int set, QSettings *settings) + static void write_shortcuts (int set, QSettings *settings, bool closing) { if (instance_ok ()) - instance->do_write_shortcuts (set, settings); + instance->do_write_shortcuts (set, settings, closing); } static void set_shortcut (QAction *action, const QString& key) @@ -113,7 +113,7 @@ void init (QString, QString, QKeySequence); void do_init_data (); - void do_write_shortcuts (int set, QSettings *settings); + void do_write_shortcuts (int set, QSettings *settings, bool closing); void do_set_shortcut (QAction *action, const QString& key); void do_fill_treewidget (QTreeWidget *tree_view); void do_import_export (bool import, int set);