Exemplo n.º 1
0
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 ();
}
Exemplo n.º 2
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 ();
}
Exemplo n.º 3
0
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 ();
}