Merge pull request #1848 from KLayout/bugfix/issue-1847

Fixing bug #1847 (problem with fresh bindkey configuration)
This commit is contained in:
Matthias Köfferlein 2024-09-08 22:24:08 +02:00 committed by GitHub
commit d70389c0c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 12 deletions

View File

@ -394,25 +394,34 @@ CustomizeMenuConfigPage::apply (const std::vector<std::pair<std::string, std::st
m_item_for_path.clear ();
m_paths_for_action.clear ();
// get the current bindings
m_current_bindings = mp_dispatcher->menu ()->get_shortcuts (false);
// get the default bindings
std::map<std::string, std::string> default_bindings = mp_dispatcher->menu ()->get_shortcuts (true);
m_enable_event = false;
// clear bindings and initialize with the given ones
std::map<std::string, std::string> b;
b.insert (key_bindings.begin (), key_bindings.end ());
for (std::map<std::string, std::string>::iterator kb = m_current_bindings.begin (); kb != m_current_bindings.end (); ++kb) {
std::map<std::string, std::string>::iterator bb = b.find (kb->first);
if (bb != b.end ()) {
lay::Action *a = mp_dispatcher->menu ()->action (kb->first);
kb->second = a->get_effective_shortcut_for (bb->second);
} else {
kb->second.clear ();
if (! key_bindings.empty ()) {
// gets the current bindings and merges with the given ones
m_current_bindings = mp_dispatcher->menu ()->get_shortcuts (false);
std::map<std::string, std::string> b;
b.insert (key_bindings.begin (), key_bindings.end ());
for (std::map<std::string, std::string>::iterator kb = m_current_bindings.begin (); kb != m_current_bindings.end (); ++kb) {
std::map<std::string, std::string>::iterator bb = b.find (kb->first);
if (bb != b.end ()) {
lay::Action *a = mp_dispatcher->menu ()->action (kb->first);
kb->second = a->get_effective_shortcut_for (bb->second);
} else {
kb->second.clear ();
}
}
} else {
// an empty list is a request for reset
m_current_bindings = default_bindings;
}
// clear hidden flags and initialize with the given ones