all repos — mgba @ c95d0b7b07da602d9894a6e01c667dc7e4c80343

mGBA Game Boy Advance Emulator

Qt: Shortcut loading fixes
Vicki Pfau vi@endrift.com
Tue, 11 Apr 2017 13:06:50 -0700
commit

c95d0b7b07da602d9894a6e01c667dc7e4c80343

parent

34ec93670ad408ae195bc376c6f692c0023c1d26

1 files changed, 18 insertions(+), 3 deletions(-)

jump to
M src/platform/qt/InputModel.cppsrc/platform/qt/InputModel.cpp

@@ -166,7 +166,13 @@ });

if (!item) { return; } - m_keys[qMakePair(platform, key)] = item; + bool loadedShortcut = false; + if (m_config) { + loadedShortcut = loadShortcuts(item); + } + if (!loadedShortcut && !m_keys.contains(qMakePair(platform, shortcut))) { + m_keys[qMakePair(platform, shortcut)] = item; + } } QModelIndex InputModel::addMenu(QMenu* menu, QMenu* parentMenu) {

@@ -254,11 +260,20 @@ }

void InputModel::updateKey(InputItem* item, int keySequence) { int oldShortcut = item->shortcut(); - if (item->functions().first || item->key() >= 0) { + if (item->functions().first) { if (oldShortcut > 0) { m_heldKeys.take(oldShortcut); } - if (keySequence >= 0) { + if (keySequence > 0) { + m_heldKeys[keySequence] = item; + } + } + + if (item->key() >= 0) { + if (oldShortcut > 0) { + m_keys.take(qMakePair(item->platform(), oldShortcut)); + } + if (keySequence > 0) { m_keys[qMakePair(item->platform(), keySequence)] = item; } }