Mercurial > octave
diff libgui/src/shortcut-manager.cc @ 20987:f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
* QTerminal.cc (set_global_shortcuts): (un)set shortcut Ctrl-D for dummy action;
(notice_settings): do not consider obsolete shortcut sets, check whether
Ctrl+D is used as global shortcut and enable the dummy action accordingly
* QTerminal.h (QTerminal): new dummy action with shortcut Ctrl+D
* shortcut-manager.cc (do_init_data): reset flag for global Ctrl-D usage;
(init, do_write_shortcuts): check for Ctrl-D usage as global shortcut and
set the flag in settings accordingly
author | Torsten <ttl@justmail.de> |
---|---|
date | Sat, 26 Dec 2015 08:49:41 +0100 |
parents | 00835323fb44 |
children | 1c91ff4cf9ec |
line wrap: on
line diff
--- a/libgui/src/shortcut-manager.cc Fri Dec 25 22:31:23 2015 +0100 +++ b/libgui/src/shortcut-manager.cc Sat Dec 26 08:49:41 2015 +0100 @@ -105,6 +105,8 @@ // actions of the main window + _settings->setValue ("shortcuts/main_ctrld",false); // reset use fo ctrl-d + // file init (tr ("New File"), "main_file:new_file", QKeySequence::New); init (tr ("New Function"), "main_file:new_function", @@ -343,6 +345,11 @@ if (! actual.isEmpty ()) _shortcut_hash[actual.toString ()] = _sc.count (); _action_hash[key] = _sc.count (); + + // check whether ctrl+d is used from main window, i.e. is a global shortcut + if (key.startsWith ("main_") + && actual == QKeySequence (Qt::ControlModifier+Qt::Key_D)) + _settings->setValue ("shortcuts/main_ctrld",true); } void @@ -433,11 +440,20 @@ shortcut_manager::do_write_shortcuts (QSettings* settings, bool closing) { + bool sc_ctrld = false; + for (int i = 0; i < _sc.count (); i++) // loop over all shortcuts { settings->setValue("shortcuts/"+_sc.at (i).settings_key, _sc.at (i).actual_sc.toString ()); + // special: check main-window for Ctrl-D (Terminal) + if (_sc.at (i).settings_key.startsWith ("main_") + && _sc.at (i).actual_sc == QKeySequence (Qt::ControlModifier+Qt::Key_D)) + sc_ctrld = true; } + + settings->setValue ("shortcuts/main_ctrld",sc_ctrld); + if (closing) { delete _dialog; // the dialog for key sequences can be removed now