size_t HotkeyMatcher::find_hotkeys (int id, KeyEventList &keys) const { keys.clear (); for (HotkeyRepository::iterator it = m_impl->m_hotkeys.begin (); it != m_impl->m_hotkeys.end (); ++it) { if (it->second == id) keys.push_back (it->first); } return keys.size (); }
size_t IMEngineHotkeyMatcher::find_hotkeys (const String &uuid, KeyEventList &keys) const { for (size_t i = 0; i < m_impl->m_uuids.size (); ++i) { if (m_impl->m_uuids [i] == uuid) return m_impl->m_matcher.find_hotkeys ((int) i, keys); } keys.clear (); return 0; }
size_t HotkeyMatcher::get_all_hotkeys (KeyEventList &keys, std::vector <int> &ids) const { keys.clear (); ids.clear (); for (HotkeyRepository::iterator it = m_impl->m_hotkeys.begin (); it != m_impl->m_hotkeys.end (); ++it) { keys.push_back (it->first); ids.push_back (it->second); } return keys.size (); }
size_t IMEngineHotkeyMatcher::get_all_hotkeys (KeyEventList &keys, std::vector <String> &uuids) const { keys.clear (); uuids.clear (); std::vector <int> ids; if (m_impl->m_matcher.get_all_hotkeys (keys, ids) > 0) { for (size_t i = 0; i < ids.size (); ++i) uuids.push_back (m_impl->m_uuids [ids [i]]); } return keys.size (); }
size_t FrontEndHotkeyMatcher::get_all_hotkeys (KeyEventList &keys, std::vector <FrontEndHotkeyAction> &actions) const { keys.clear (); actions.clear (); std::vector <int> ids; m_impl->m_matcher.get_all_hotkeys (keys, ids); for (size_t i = 0; i < ids.size (); ++i) actions.push_back (static_cast<FrontEndHotkeyAction> (ids [i])); return keys.size (); }
void ScimConsoleImpl::slot_reload_config (const ConfigPointer &config) { scim_frontend_hotkey_matcher.load_hotkeys (scim_config); scim_imengine_hotkey_matcher.load_hotkeys (scim_config); panel_hotkey_matcher.clear (); vector<String> strings; KeyEventList hotkeys; hotkeys.clear (); if (config->read ("/FrontEnd/Console/Hotkeys/Menu", &strings)) { for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) { const String &string = *i; KeyEventList keys; if (scim_string_to_key_list (keys, string)) { for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) { KeyEvent &key = *j; hotkeys.push_back (key); } } } } if (hotkeys.empty ()) { hotkeys.push_back (KeyEvent (SCIM_KEY_F2)); hotkeys.push_back (KeyEvent (SCIM_KEY_Menu)); } panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_MENU); hotkeys.clear (); if (config->read ("/FrontEnd/Console/Hotkeys/Cancel", &strings)) { for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) { const String &string = *i; KeyEventList keys; if (scim_string_to_key_list (keys, string)) { for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) { KeyEvent &key = *j; hotkeys.push_back (key); } } } } if (hotkeys.empty ()) { hotkeys.push_back (KeyEvent (SCIM_KEY_Escape)); hotkeys.push_back (KeyEvent (SCIM_KEY_BackSpace)); hotkeys.push_back (KeyEvent (SCIM_KEY_Delete)); } panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_CANCEL); hotkeys.clear (); if (config->read ("/FrontEnd/Console/Hotkeys/OK", &strings)) { for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) { const String &string = *i; KeyEventList keys; if (scim_string_to_key_list (keys, string)) { for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) { KeyEvent &key = *j; hotkeys.push_back (key); } } } } if (hotkeys.empty ()) { hotkeys.push_back (KeyEvent (SCIM_KEY_Return)); hotkeys.push_back (KeyEvent (SCIM_KEY_space)); } panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_OK); hotkeys.clear (); if (config->read ("/FrontEnd/Console/Hotkeys/Previous", &strings)) { for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) { const String &string = *i; KeyEventList keys; if (scim_string_to_key_list (keys, string)) { for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) { KeyEvent &key = *j; hotkeys.push_back (key); } } } } if (hotkeys.empty ()) { hotkeys.push_back (KeyEvent (SCIM_KEY_Left)); hotkeys.push_back (KeyEvent (SCIM_KEY_Up)); } panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_PREVIOUS); hotkeys.clear (); if (config->read ("/FrontEnd/Console/Hotkeys/Next", &strings)) { for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) { const String &string = *i; KeyEventList keys; if (scim_string_to_key_list (keys, string)) { for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) { KeyEvent &key = *j; hotkeys.push_back (key); } } } } if (hotkeys.empty ()) { hotkeys.push_back (KeyEvent (SCIM_KEY_Right)); hotkeys.push_back (KeyEvent (SCIM_KEY_Down)); } panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_NEXT); // Get keyboard layout setting // Flush the global config first, in order to load the new configs from disk. scim_global_config_flush (); scim_keyboard_layout = scim_get_default_keyboard_layout (); }