summaryrefslogtreecommitdiffstats
path: root/src/citra_qt/hotkeys.cpp
diff options
context:
space:
mode:
authorLittleWhite <lw.demoscene@googlemail.com>2016-01-24 21:23:55 +0100
committerLittleWhite <lw.demoscene@googlemail.com>2016-03-21 20:03:18 +0100
commite33b9385054169c2850717e9c969a2531ee9b6f2 (patch)
tree49d08683e3c45df030f939f2746d9c75b46e2cf9 /src/citra_qt/hotkeys.cpp
parentAdd Configure widget (diff)
downloadyuzu-e33b9385054169c2850717e9c969a2531ee9b6f2.tar
yuzu-e33b9385054169c2850717e9c969a2531ee9b6f2.tar.gz
yuzu-e33b9385054169c2850717e9c969a2531ee9b6f2.tar.bz2
yuzu-e33b9385054169c2850717e9c969a2531ee9b6f2.tar.lz
yuzu-e33b9385054169c2850717e9c969a2531ee9b6f2.tar.xz
yuzu-e33b9385054169c2850717e9c969a2531ee9b6f2.tar.zst
yuzu-e33b9385054169c2850717e9c969a2531ee9b6f2.zip
Diffstat (limited to 'src/citra_qt/hotkeys.cpp')
-rw-r--r--src/citra_qt/hotkeys.cpp51
1 files changed, 18 insertions, 33 deletions
diff --git a/src/citra_qt/hotkeys.cpp b/src/citra_qt/hotkeys.cpp
index 929ba6f0e..92525d53c 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,38 @@ 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.push_back(UISettings::Shortcut(group.first + "/" + hotkey.first,
+ UISettings::ContextedShortcut(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)