citra-qt: Add base support for hotkey reconfiguration + UI (whole of PR citra-emu/citra#3786)

* Adds a new Hotkeys tab in the Controls group.
* Right click to reconfigure.
* See the original PR for more details & screenshots.
This commit is contained in:
Adityarup Laha 2018-05-22 21:30:36 +02:00
parent 95a57a2fe3
commit 5fa25fcf13
No known key found for this signature in database
GPG key ID: 1B24048A1F78845F
22 changed files with 559 additions and 306 deletions

View file

@ -3,7 +3,9 @@
// Refer to the license.txt file included.
#include <algorithm>
#include <array>
#include <unordered_map>
#include <QKeySequence>
#include <QSettings>
#include "citra_qt/configuration/config.h"
#include "citra_qt/ui_settings.h"
@ -318,20 +320,46 @@ void Config::ReadValues() {
qt_config->endGroup();
qt_config->beginGroup("Shortcuts");
QStringList groups = qt_config->childGroups();
for (auto group : groups) {
qt_config->beginGroup(group);
QStringList hotkeys = qt_config->childGroups();
for (auto hotkey : hotkeys) {
qt_config->beginGroup(hotkey);
UISettings::values.shortcuts.emplace_back(UISettings::Shortcut(
group + "/" + hotkey,
UISettings::ContextualShortcut(ReadSetting("KeySeq").toString(),
ReadSetting("Context").toInt())));
qt_config->endGroup();
}
const std::array<UISettings::Shortcut, 14> default_hotkeys{
{{"Load File", "Main Window",
UISettings::ContextualShortcut(QKeySequence(QKeySequence::Open).toString(),
Qt::WindowShortcut)},
{"Exit Citra", "Main Window",
UISettings::ContextualShortcut("Ctrl+Q", Qt::WindowShortcut)},
{"Continue/Pause Emulation", "Main Window",
UISettings::ContextualShortcut("F4", Qt::WindowShortcut)},
{"Stop Emulation", "Main Window",
UISettings::ContextualShortcut("F5", Qt::WindowShortcut)},
{"Restart Emulation", "Main Window",
UISettings::ContextualShortcut("F6", Qt::WindowShortcut)},
{"Swap Screens", "Main Window", UISettings::ContextualShortcut("F9", Qt::WindowShortcut)},
{"Toggle Screen Layout", "Main Window",
UISettings::ContextualShortcut("F10", Qt::WindowShortcut)},
{"Toggle Filter Bar", "Main Window",
UISettings::ContextualShortcut("Ctrl+F", Qt::WindowShortcut)},
{"Toggle Status Bar", "Main Window",
UISettings::ContextualShortcut("Ctrl+S", Qt::WindowShortcut)},
{"Fullscreen", "Main Window",
UISettings::ContextualShortcut(QKeySequence(QKeySequence::FullScreen).toString(),
Qt::WindowShortcut)},
{"Exit Fullscreen", "Main Window",
UISettings::ContextualShortcut("Escape", Qt::WindowShortcut)},
{"Toggle Speed Limit", "Main Window",
UISettings::ContextualShortcut("Ctrl+Z", Qt::ApplicationShortcut)},
{"Increase Speed Limit", "Main Window",
UISettings::ContextualShortcut("+", Qt::ApplicationShortcut)},
{"Decrease Speed Limit", "Main Window",
UISettings::ContextualShortcut("-", Qt::ApplicationShortcut)}}};
for (int i = 0; i < default_hotkeys.size(); i++) {
qt_config->beginGroup(default_hotkeys[i].group);
qt_config->beginGroup(default_hotkeys[i].name);
UISettings::values.shortcuts.push_back(
{default_hotkeys[i].name, default_hotkeys[i].group,
UISettings::ContextualShortcut(
qt_config->value("KeySeq", default_hotkeys[i].shortcut.first).toString(),
qt_config->value("Context", default_hotkeys[i].shortcut.second).toInt())});
qt_config->endGroup();
qt_config->endGroup();
}
qt_config->endGroup();
@ -564,8 +592,12 @@ void Config::SaveValues() {
qt_config->beginGroup("Shortcuts");
for (auto shortcut : UISettings::values.shortcuts) {
WriteSetting(shortcut.first + "/KeySeq", shortcut.second.first);
WriteSetting(shortcut.first + "/Context", shortcut.second.second);
qt_config->beginGroup(shortcut.group);
qt_config->beginGroup(shortcut.name);
WriteSetting("KeySeq", shortcut.shortcut.first);
WriteSetting("Context", shortcut.shortcut.second);
qt_config->endGroup();
qt_config->endGroup();
}
qt_config->endGroup();