diff options
author | bunnei <bunneidev@gmail.com> | 2016-04-11 02:21:34 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2016-04-11 02:21:34 +0200 |
commit | a1b81469a3a72f0a6550075e2a693e31dab31ea9 (patch) | |
tree | 196b2ae1191198f1c47af2c33a145931c853c915 /src/citra_qt/hotkeys.cpp | |
parent | Merge pull request #1653 from mailwl/blx-lr (diff) | |
parent | Add more stuff to configure. (diff) | |
download | yuzu-a1b81469a3a72f0a6550075e2a693e31dab31ea9.tar yuzu-a1b81469a3a72f0a6550075e2a693e31dab31ea9.tar.gz yuzu-a1b81469a3a72f0a6550075e2a693e31dab31ea9.tar.bz2 yuzu-a1b81469a3a72f0a6550075e2a693e31dab31ea9.tar.lz yuzu-a1b81469a3a72f0a6550075e2a693e31dab31ea9.tar.xz yuzu-a1b81469a3a72f0a6550075e2a693e31dab31ea9.tar.zst yuzu-a1b81469a3a72f0a6550075e2a693e31dab31ea9.zip |
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 ed6b12fc4..41f95c63d 100644 --- a/src/citra_qt/hotkeys.cpp +++ b/src/citra_qt/hotkeys.cpp @@ -4,11 +4,12 @@ #include <map> +#include <QtGlobal> #include <QKeySequence> -#include <QSettings> #include <QShortcut> #include "citra_qt/hotkeys.h" +#include "citra_qt/ui_settings.h" struct Hotkey { @@ -24,54 +25,39 @@ typedef std::map<QString, HotkeyMap> HotkeyGroupMap; HotkeyGroupMap hotkey_groups; -void SaveHotkeys(QSettings& settings) +void SaveHotkeys() { - settings.beginGroup("Shortcuts"); - + UISettings::values.shortcuts.clear(); for (auto group : hotkey_groups) { - settings.beginGroup(group.first); for (auto hotkey : group.second) { - settings.beginGroup(hotkey.first); - settings.setValue(QString("KeySeq"), hotkey.second.keyseq.toString()); - settings.setValue(QString("Context"), hotkey.second.context); - settings.endGroup(); + UISettings::values.shortcuts.emplace_back( + UISettings::Shortcut(group.first + "/" + hotkey.first, + UISettings::ContextualShortcut(hotkey.second.keyseq.toString(), + hotkey.second.context))); } - settings.endGroup(); } - settings.endGroup(); } -void LoadHotkeys(QSettings& settings) +void LoadHotkeys() { - settings.beginGroup("Shortcuts"); - // Make sure NOT to use a reference here because it would become invalid once we call beginGroup() - QStringList groups = settings.childGroups(); - for (auto group : groups) + for (auto shortcut : UISettings::values.shortcuts) { - settings.beginGroup(group); + QStringList cat = shortcut.first.split("/"); + Q_ASSERT(cat.size() >= 2); - QStringList hotkeys = settings.childGroups(); - for (auto hotkey : hotkeys) + // RegisterHotkey assigns default keybindings, so use old values as default parameters + Hotkey& hk = hotkey_groups[cat[0]][cat[1]]; + if (!shortcut.second.first.isEmpty()) { - settings.beginGroup(hotkey); - - // RegisterHotkey assigns default keybindings, so use old values as default parameters - Hotkey& hk = hotkey_groups[group][hotkey]; - hk.keyseq = QKeySequence::fromString(settings.value("KeySeq", hk.keyseq.toString()).toString()); - hk.context = (Qt::ShortcutContext)settings.value("Context", hk.context).toInt(); - if (hk.shortcut) - hk.shortcut->setKey(hk.keyseq); - - settings.endGroup(); + hk.keyseq = QKeySequence::fromString(shortcut.second.first); + hk.context = (Qt::ShortcutContext)shortcut.second.second; } - - settings.endGroup(); + if (hk.shortcut) + hk.shortcut->setKey(hk.keyseq); } - - settings.endGroup(); } void RegisterHotkey(const QString& group, const QString& action, const QKeySequence& default_keyseq, Qt::ShortcutContext default_context) @@ -94,7 +80,7 @@ QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widge } -GHotkeysDialog::GHotkeysDialog(QWidget* parent): QDialog(parent) +GHotkeysDialog::GHotkeysDialog(QWidget* parent): QWidget(parent) { ui.setupUi(this); |