From 71f36efd273a40ae44380c04058d1159c504f13f Mon Sep 17 00:00:00 2001 From: Adityarup Laha <30696515+adityaruplaha@users.noreply.github.com> Date: Wed, 12 Dec 2018 21:14:27 +0530 Subject: [PATCH] citra-qt: Use structured bindings where applicable in `ConfigureHotkeys::applyConfiguration`. Fix a few minor issues. * Address https://github.com/citra-emu/citra/pull/4437#discussion_r241380912 --- src/citra_qt/configuration/configure_dialog.h | 2 +- src/citra_qt/configuration/configure_hotkeys.cpp | 16 +++++++--------- src/citra_qt/hotkeys.cpp | 4 +++- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/citra_qt/configuration/configure_dialog.h b/src/citra_qt/configuration/configure_dialog.h index 39ece2847..5abd28543 100644 --- a/src/citra_qt/configuration/configure_dialog.h +++ b/src/citra_qt/configuration/configure_dialog.h @@ -17,7 +17,7 @@ class ConfigureDialog : public QDialog { Q_OBJECT public: - explicit ConfigureDialog(QWidget* parent, const HotkeyRegistry& registry); + explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry); ~ConfigureDialog() override; void UpdateVisibleTabs(); diff --git a/src/citra_qt/configuration/configure_hotkeys.cpp b/src/citra_qt/configuration/configure_hotkeys.cpp index 1d961c5f0..cf4ae1034 100644 --- a/src/citra_qt/configuration/configure_hotkeys.cpp +++ b/src/citra_qt/configuration/configure_hotkeys.cpp @@ -107,15 +107,13 @@ void ConfigureHotkeys::applyConfiguration(HotkeyRegistry& registry) { for (int key_column_id = 0; key_column_id < parent->rowCount(); key_column_id++) { QStandardItem* action = parent->child(key_column_id, 0); QStandardItem* keyseq = parent->child(key_column_id, 1); - for (auto key_iterator = registry.hotkey_groups.begin(); - key_iterator != registry.hotkey_groups.end(); ++key_iterator) { - if (key_iterator->first == parent->text()) { - for (auto it2 = key_iterator->second.begin(); it2 != key_iterator->second.end(); - ++it2) { - if (it2->first == action->text()) { - it2->second.keyseq = QKeySequence(keyseq->text()); - } - } + for (auto& [group, sub_actions] : registry.hotkey_groups) { + if (group != parent->text()) + continue; + for (auto& [action_name, hotkey] : sub_actions) { + if (action_name != action->text()) + continue; + hotkey.keyseq = QKeySequence(keyseq->text()); } } } diff --git a/src/citra_qt/hotkeys.cpp b/src/citra_qt/hotkeys.cpp index b4038ba54..0939bcf49 100644 --- a/src/citra_qt/hotkeys.cpp +++ b/src/citra_qt/hotkeys.cpp @@ -32,8 +32,10 @@ void HotkeyRegistry::LoadHotkeys() { hk.keyseq = QKeySequence::fromString(shortcut.shortcut.first, QKeySequence::NativeText); hk.context = (Qt::ShortcutContext)shortcut.shortcut.second; } - if (hk.shortcut) + if (hk.shortcut) { + hk.shortcut->disconnect(); hk.shortcut->setKey(hk.keyseq); + } } }