Exemplo n.º 1
0
KeySequence InputAPI::KeyBinding(const String &actionName, const KeySequence &defaultKey)
{
    auto iter = keyboardMappings.Find(actionName);
    if (iter == keyboardMappings.End())
    {
        SetKeyBinding(actionName, defaultKey);
        return defaultKey;
    }
    return iter->second_;
}
Exemplo n.º 2
0
/// Returns the key associated with the given action.
QKeySequence QtInputService::KeyBinding(const QString &actionName, QKeySequence defaultKey)
{
    std::map<std::string, QKeySequence>::const_iterator iter = keyboardMappings.find(actionName.toStdString());
    if (iter == keyboardMappings.end())
    {
        SetKeyBinding(actionName, defaultKey);
        return defaultKey;
    }
    return iter->second;
}
Exemplo n.º 3
0
void InputAPI::LoadKeyBindingsFromFile()
{
    ConfigAPI &cfg = *framework->Config();
    ConfigData inputConfig(ConfigAPI::FILE_FRAMEWORK, "input");
    for(int i = 0; ; ++i)
    {
        StringList bindings = cfg.Read(inputConfig, String("keybinding") + String(i)).GetString().Split('|');
        if (bindings.Size() != 2)
            break;
        SetKeyBinding(bindings[0], ToInt(bindings[1]));
    }
}
Exemplo n.º 4
0
void QtInputService::LoadKeyBindingsFromFile()
{
    QSettings settings(QSettings::IniFormat, QSettings::UserScope, APPLICATION_NAME, "configuration/KeyBindings");

    int size = settings.beginReadArray("numActions");
    for(int i = 0; i < size; ++i)
    {
        settings.setArrayIndex(i);
        QString actionName = settings.value("actionName").toString();
        QKeySequence keySequence = QKeySequence::fromString(settings.value("keySequence").toString(), QKeySequence::PortableText);
        SetKeyBinding(actionName, keySequence);
    }
    settings.endArray();
}