diff options
| author | 2016-09-21 11:29:48 -0700 | |
|---|---|---|
| committer | 2016-09-21 11:29:48 -0700 | |
| commit | d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a (patch) | |
| tree | 8a22ca73ff838f3f0090b29a548ae81087fc90ed /src/citra_qt/hotkeys.cpp | |
| parent | README: Specify master branch for Travis CI badge (diff) | |
| parent | Fix Travis clang-format check (diff) | |
| download | yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.gz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.xz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.zip | |
Merge pull request #2086 from linkmauve/clang-format
Add clang-format as part of our {commit,travis}-time checks
Diffstat (limited to 'src/citra_qt/hotkeys.cpp')
| -rw-r--r-- | src/citra_qt/hotkeys.cpp | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/src/citra_qt/hotkeys.cpp b/src/citra_qt/hotkeys.cpp index 41f95c63d..158ed506f 100644 --- a/src/citra_qt/hotkeys.cpp +++ b/src/citra_qt/hotkeys.cpp | |||
| @@ -3,16 +3,13 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <map> | 5 | #include <map> |
| 6 | |||
| 7 | #include <QtGlobal> | ||
| 8 | #include <QKeySequence> | 6 | #include <QKeySequence> |
| 9 | #include <QShortcut> | 7 | #include <QShortcut> |
| 10 | 8 | #include <QtGlobal> | |
| 11 | #include "citra_qt/hotkeys.h" | 9 | #include "citra_qt/hotkeys.h" |
| 12 | #include "citra_qt/ui_settings.h" | 10 | #include "citra_qt/ui_settings.h" |
| 13 | 11 | ||
| 14 | struct Hotkey | 12 | struct Hotkey { |
| 15 | { | ||
| 16 | Hotkey() : shortcut(nullptr), context(Qt::WindowShortcut) {} | 13 | Hotkey() : shortcut(nullptr), context(Qt::WindowShortcut) {} |
| 17 | 14 | ||
| 18 | QKeySequence keyseq; | 15 | QKeySequence keyseq; |
| @@ -25,33 +22,28 @@ typedef std::map<QString, HotkeyMap> HotkeyGroupMap; | |||
| 25 | 22 | ||
| 26 | HotkeyGroupMap hotkey_groups; | 23 | HotkeyGroupMap hotkey_groups; |
| 27 | 24 | ||
| 28 | void SaveHotkeys() | 25 | void SaveHotkeys() { |
| 29 | { | ||
| 30 | UISettings::values.shortcuts.clear(); | 26 | UISettings::values.shortcuts.clear(); |
| 31 | for (auto group : hotkey_groups) | 27 | for (auto group : hotkey_groups) { |
| 32 | { | 28 | for (auto hotkey : group.second) { |
| 33 | for (auto hotkey : group.second) | ||
| 34 | { | ||
| 35 | UISettings::values.shortcuts.emplace_back( | 29 | UISettings::values.shortcuts.emplace_back( |
| 36 | UISettings::Shortcut(group.first + "/" + hotkey.first, | 30 | UISettings::Shortcut(group.first + "/" + hotkey.first, |
| 37 | UISettings::ContextualShortcut(hotkey.second.keyseq.toString(), | 31 | UISettings::ContextualShortcut(hotkey.second.keyseq.toString(), |
| 38 | hotkey.second.context))); | 32 | hotkey.second.context))); |
| 39 | } | 33 | } |
| 40 | } | 34 | } |
| 41 | } | 35 | } |
| 42 | 36 | ||
| 43 | void LoadHotkeys() | 37 | void LoadHotkeys() { |
| 44 | { | 38 | // Make sure NOT to use a reference here because it would become invalid once we call |
| 45 | // Make sure NOT to use a reference here because it would become invalid once we call beginGroup() | 39 | // beginGroup() |
| 46 | for (auto shortcut : UISettings::values.shortcuts) | 40 | for (auto shortcut : UISettings::values.shortcuts) { |
| 47 | { | ||
| 48 | QStringList cat = shortcut.first.split("/"); | 41 | QStringList cat = shortcut.first.split("/"); |
| 49 | Q_ASSERT(cat.size() >= 2); | 42 | Q_ASSERT(cat.size() >= 2); |
| 50 | 43 | ||
| 51 | // RegisterHotkey assigns default keybindings, so use old values as default parameters | 44 | // RegisterHotkey assigns default keybindings, so use old values as default parameters |
| 52 | Hotkey& hk = hotkey_groups[cat[0]][cat[1]]; | 45 | Hotkey& hk = hotkey_groups[cat[0]][cat[1]]; |
| 53 | if (!shortcut.second.first.isEmpty()) | 46 | if (!shortcut.second.first.isEmpty()) { |
| 54 | { | ||
| 55 | hk.keyseq = QKeySequence::fromString(shortcut.second.first); | 47 | hk.keyseq = QKeySequence::fromString(shortcut.second.first); |
| 56 | hk.context = (Qt::ShortcutContext)shortcut.second.second; | 48 | hk.context = (Qt::ShortcutContext)shortcut.second.second; |
| 57 | } | 49 | } |
| @@ -60,17 +52,15 @@ void LoadHotkeys() | |||
| 60 | } | 52 | } |
| 61 | } | 53 | } |
| 62 | 54 | ||
| 63 | void RegisterHotkey(const QString& group, const QString& action, const QKeySequence& default_keyseq, Qt::ShortcutContext default_context) | 55 | void RegisterHotkey(const QString& group, const QString& action, const QKeySequence& default_keyseq, |
| 64 | { | 56 | Qt::ShortcutContext default_context) { |
| 65 | if (hotkey_groups[group].find(action) == hotkey_groups[group].end()) | 57 | if (hotkey_groups[group].find(action) == hotkey_groups[group].end()) { |
| 66 | { | ||
| 67 | hotkey_groups[group][action].keyseq = default_keyseq; | 58 | hotkey_groups[group][action].keyseq = default_keyseq; |
| 68 | hotkey_groups[group][action].context = default_context; | 59 | hotkey_groups[group][action].context = default_context; |
| 69 | } | 60 | } |
| 70 | } | 61 | } |
| 71 | 62 | ||
| 72 | QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widget) | 63 | QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widget) { |
| 73 | { | ||
| 74 | Hotkey& hk = hotkey_groups[group][action]; | 64 | Hotkey& hk = hotkey_groups[group][action]; |
| 75 | 65 | ||
| 76 | if (!hk.shortcut) | 66 | if (!hk.shortcut) |
| @@ -79,16 +69,12 @@ QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widge | |||
| 79 | return hk.shortcut; | 69 | return hk.shortcut; |
| 80 | } | 70 | } |
| 81 | 71 | ||
| 82 | 72 | GHotkeysDialog::GHotkeysDialog(QWidget* parent) : QWidget(parent) { | |
| 83 | GHotkeysDialog::GHotkeysDialog(QWidget* parent): QWidget(parent) | ||
| 84 | { | ||
| 85 | ui.setupUi(this); | 73 | ui.setupUi(this); |
| 86 | 74 | ||
| 87 | for (auto group : hotkey_groups) | 75 | for (auto group : hotkey_groups) { |
| 88 | { | ||
| 89 | QTreeWidgetItem* toplevel_item = new QTreeWidgetItem(QStringList(group.first)); | 76 | QTreeWidgetItem* toplevel_item = new QTreeWidgetItem(QStringList(group.first)); |
| 90 | for (auto hotkey : group.second) | 77 | for (auto hotkey : group.second) { |
| 91 | { | ||
| 92 | QStringList columns; | 78 | QStringList columns; |
| 93 | columns << hotkey.first << hotkey.second.keyseq.toString(); | 79 | columns << hotkey.first << hotkey.second.keyseq.toString(); |
| 94 | QTreeWidgetItem* item = new QTreeWidgetItem(columns); | 80 | QTreeWidgetItem* item = new QTreeWidgetItem(columns); |