From 426c4a2a5b65ce04a767e4c514aafc182b8d5a56 Mon Sep 17 00:00:00 2001 From: LittleWhite Date: Sun, 24 Jan 2016 18:34:05 +0100 Subject: Add Configure widget --- src/citra_qt/hotkeys.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/citra_qt/hotkeys.cpp') diff --git a/src/citra_qt/hotkeys.cpp b/src/citra_qt/hotkeys.cpp index ed6b12fc4..929ba6f0e 100644 --- a/src/citra_qt/hotkeys.cpp +++ b/src/citra_qt/hotkeys.cpp @@ -94,7 +94,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); -- cgit v1.2.3 From e33b9385054169c2850717e9c969a2531ee9b6f2 Mon Sep 17 00:00:00 2001 From: LittleWhite Date: Sun, 24 Jan 2016 21:23:55 +0100 Subject: Whole config is handled by Config class. This also means : we have only one config file, now --- src/citra_qt/hotkeys.cpp | 51 +++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) (limited to 'src/citra_qt/hotkeys.cpp') 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 +#include #include -#include #include #include "citra_qt/hotkeys.h" +#include "citra_qt/ui_settings.h" struct Hotkey { @@ -24,54 +25,38 @@ typedef std::map 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) -- cgit v1.2.3 From 3eb737a5f5b199fd3f9951a7060255f46011e9ff Mon Sep 17 00:00:00 2001 From: LittleWhite Date: Sun, 24 Jan 2016 21:54:04 +0100 Subject: Add more stuff to configure. --- src/citra_qt/hotkeys.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/citra_qt/hotkeys.cpp') diff --git a/src/citra_qt/hotkeys.cpp b/src/citra_qt/hotkeys.cpp index 92525d53c..41f95c63d 100644 --- a/src/citra_qt/hotkeys.cpp +++ b/src/citra_qt/hotkeys.cpp @@ -32,9 +32,10 @@ void SaveHotkeys() { for (auto hotkey : group.second) { - UISettings::values.shortcuts.push_back(UISettings::Shortcut(group.first + "/" + hotkey.first, - UISettings::ContextedShortcut(hotkey.second.keyseq.toString(), - hotkey.second.context))); + UISettings::values.shortcuts.emplace_back( + UISettings::Shortcut(group.first + "/" + hotkey.first, + UISettings::ContextualShortcut(hotkey.second.keyseq.toString(), + hotkey.second.context))); } } } -- cgit v1.2.3