Mercurial > octave
diff libgui/src/shortcut-manager.cc @ 31691:fc3bc1402b0d
eliminate unnecessary table of keyboard shortcuts in shortcut_manager class
* shortcut-manager.h, shortcut-manager.cc
(shortcut_manager::m_action_hash): Delete data member and all uses.
(shortcut_manager::set_shortcut, shortcut_manager::shortcut):
Don't check m_action_hash for shortcut. Just use value from settings
if it exists.
(shortcut_manager::init): Don't store shortcut in m_action_hash.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 24 Dec 2022 14:54:52 -0500 |
parents | deb553ac2c54 |
children | 2422fb7f1e6c |
line wrap: on
line diff
--- a/libgui/src/shortcut-manager.cc Tue Dec 27 14:55:03 2022 -0500 +++ b/libgui/src/shortcut-manager.cc Sat Dec 24 14:54:52 2022 -0500 @@ -343,36 +343,26 @@ return; } - // Enable: Is the given key known? If yes, get the value from the - // settings file and set it to the action - int index; + gui_settings settings; - index = m_action_hash[scpref.key] - 1; + QString shortcut = settings.sc_value (scpref); - if (index > -1 && index < m_sc.count ()) - { - gui_settings settings; - - action->setShortcut (QKeySequence (settings.sc_value (scpref))); - } + if (! shortcut.isEmpty ()) + action->setShortcut (QKeySequence (shortcut)); else - qDebug () << "Key: " << scpref.key << " not found in m_action_hash"; + qDebug () << "Key: " << scpref.key << " not found in settings"; } void shortcut_manager::shortcut (QShortcut *sc, const sc_pref& scpref) { - int index; + gui_settings settings; - index = m_action_hash[scpref.key] - 1; + QString shortcut = settings.sc_value (scpref); - if (index > -1 && index < m_sc.count ()) - { - gui_settings settings; - - sc->setKey (QKeySequence (settings.sc_value (scpref))); - } + if (! shortcut.isEmpty ()) + sc->setKey (QKeySequence (shortcut)); else - qDebug () << "Key: " << scpref.key << " not found in m_action_hash"; + qDebug () << "Key: " << scpref.key << " not found in settings"; } void shortcut_manager::fill_treewidget (QTreeWidget *tree_view) @@ -638,7 +628,6 @@ // insert shortcut in order to check for duplicates later if (! actual.isEmpty ()) m_shortcut_hash[actual.toString ()] = m_sc.count (); - m_action_hash[sc.key] = m_sc.count (); // check whether ctrl+d is used from main window, i.e. is a global shortcut QString main_group_prefix