From 812de67703815641a91c27def1d23e812028cf55 Mon Sep 17 00:00:00 2001 From: Christopher Cooper Date: Mon, 28 Dec 2015 16:13:13 -0500 Subject: [PATCH] Add support for multiple keybindings to a single control --- src/configobject.cpp | 29 +++++++++++++++++++++-------- src/configobject.h | 2 +- src/mixxxkeyboard.cpp | 7 ++++++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/configobject.cpp b/src/configobject.cpp index ef3219a..ba34e56 100644 --- a/src/configobject.cpp +++ b/src/configobject.cpp @@ -74,23 +74,36 @@ ConfigValueKbd::ConfigValueKbd() ConfigValueKbd::ConfigValueKbd(QString _value) : ConfigValue(_value) { - QString key; + QStringList keys = _value.split(" "); - QTextStream(&_value) >> key; - m_qKey = QKeySequence(key); + m_qKeys = QList(); + for (QStringList::iterator it = keys.begin(); + it != keys.end(); ++it) { + QString key = *it; + m_qKeys.append(QKeySequence(key)); + } } ConfigValueKbd::ConfigValueKbd(QKeySequence key) { - m_qKey = key; - QTextStream(&value) << m_qKey.toString(); -// qDebug() << "value" << value; + m_qKeys = QList(); + m_qKeys.append(key); + for (QList::iterator it = m_qKeys.begin(); + it != m_qKeys.end(); ++it) { + QKeySequence qKey = *it; + QTextStream(&value) << qKey.toString(); + } + // qDebug() << "value" << value; } void ConfigValueKbd::valCopy(const ConfigValueKbd& v) { - m_qKey = v.m_qKey; - QTextStream(&value) << m_qKey.toString(); + QList m_qKeys(v.m_qKeys); + for (QList::iterator it = m_qKeys.begin(); + it != m_qKeys.end(); ++it) { + QKeySequence qKey = *it; + QTextStream(&value) << qKey.toString(); + } } bool operator==(const ConfigValue& s1, const ConfigValue& s2) diff --git a/src/configobject.h b/src/configobject.h index 8521989..c14aeff 100644 --- a/src/configobject.h +++ b/src/configobject.h @@ -95,7 +95,7 @@ class ConfigValueKbd : public ConfigValue { void valCopy(const ConfigValueKbd& v); friend bool operator==(const ConfigValueKbd& s1, const ConfigValueKbd& s2); - QKeySequence m_qKey; + QList m_qKeys; }; template class ConfigOption { diff --git a/src/mixxxkeyboard.cpp b/src/mixxxkeyboard.cpp index 4228176..bde68d8 100644 --- a/src/mixxxkeyboard.cpp +++ b/src/mixxxkeyboard.cpp @@ -184,7 +184,12 @@ void MixxxKeyboard::setKeyboardConfig(ConfigObject* pKbdConfigOb m_keySequenceToControlHash.clear(); for (QHash::const_iterator it = keyboardConfig.begin(); it != keyboardConfig.end(); ++it) { - m_keySequenceToControlHash.insert(it.value().m_qKey, it.key()); + QList kslist = it.value().m_qKeys; + for (QList::iterator it2 = kslist.begin(); + it2 != kslist.end(); ++it2) { + QKeySequence current = *it2; + m_keySequenceToControlHash.insert(current, it.key()); + } } m_pKbdConfigObject = pKbdConfigObject; } -- 2.4.3