summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-05-25 00:23:58 +0200
committerGitHub <noreply@github.com>2019-05-25 00:23:58 +0200
commit59f110ef31ffa64033090c34357829a402857a9c (patch)
treed79b351051ec4c461441b2aaabbc55edaf027add
parentMerge pull request #2489 from FearlessTobi/port-4716 (diff)
parentyuzu/configuration/config: Make default hotkeys an internally-linked array in the cpp file (diff)
downloadyuzu-59f110ef31ffa64033090c34357829a402857a9c.tar
yuzu-59f110ef31ffa64033090c34357829a402857a9c.tar.gz
yuzu-59f110ef31ffa64033090c34357829a402857a9c.tar.bz2
yuzu-59f110ef31ffa64033090c34357829a402857a9c.tar.lz
yuzu-59f110ef31ffa64033090c34357829a402857a9c.tar.xz
yuzu-59f110ef31ffa64033090c34357829a402857a9c.tar.zst
yuzu-59f110ef31ffa64033090c34357829a402857a9c.zip
-rw-r--r--src/yuzu/configuration/config.cpp73
-rw-r--r--src/yuzu/configuration/config.h3
2 files changed, 43 insertions, 33 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index d28826c67..db27da23e 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -11,6 +11,7 @@
#include "core/hle/service/hid/controllers/npad.h"
#include "input_common/main.h"
#include "yuzu/configuration/config.h"
+#include "yuzu/ui_settings.h"
Config::Config() {
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
@@ -206,25 +207,28 @@ const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> Config::default
};
// This shouldn't have anything except static initializers (no functions). So
-// QKeySequnce(...).toString() is NOT ALLOWED HERE.
+// QKeySequence(...).toString() is NOT ALLOWED HERE.
// This must be in alphabetical order according to action name as it must have the same order as
// UISetting::values.shortcuts, which is alphabetically ordered.
-const std::array<UISettings::Shortcut, 15> Config::default_hotkeys{
- {{"Capture Screenshot", "Main Window", {"Ctrl+P", Qt::ApplicationShortcut}},
- {"Continue/Pause Emulation", "Main Window", {"F4", Qt::WindowShortcut}},
- {"Decrease Speed Limit", "Main Window", {"-", Qt::ApplicationShortcut}},
- {"Exit yuzu", "Main Window", {"Ctrl+Q", Qt::WindowShortcut}},
- {"Exit Fullscreen", "Main Window", {"Esc", Qt::WindowShortcut}},
- {"Fullscreen", "Main Window", {"F11", Qt::WindowShortcut}},
- {"Increase Speed Limit", "Main Window", {"+", Qt::ApplicationShortcut}},
- {"Load Amiibo", "Main Window", {"F2", Qt::ApplicationShortcut}},
- {"Load File", "Main Window", {"Ctrl+O", Qt::WindowShortcut}},
- {"Restart Emulation", "Main Window", {"F6", Qt::WindowShortcut}},
- {"Stop Emulation", "Main Window", {"F5", Qt::WindowShortcut}},
- {"Toggle Filter Bar", "Main Window", {"Ctrl+F", Qt::WindowShortcut}},
- {"Toggle Speed Limit", "Main Window", {"Ctrl+Z", Qt::ApplicationShortcut}},
- {"Toggle Status Bar", "Main Window", {"Ctrl+S", Qt::WindowShortcut}},
- {"Change Docked Mode", "Main Window", {"F10", Qt::ApplicationShortcut}}}};
+// clang-format off
+const std::array<UISettings::Shortcut, 15> default_hotkeys{{
+ {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::ApplicationShortcut}},
+ {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}},
+ {QStringLiteral("Decrease Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("-"), Qt::ApplicationShortcut}},
+ {QStringLiteral("Exit yuzu"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Q"), Qt::WindowShortcut}},
+ {QStringLiteral("Exit Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("Esc"), Qt::WindowShortcut}},
+ {QStringLiteral("Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("F11"), Qt::WindowShortcut}},
+ {QStringLiteral("Increase Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("+"), Qt::ApplicationShortcut}},
+ {QStringLiteral("Load Amiibo"), QStringLiteral("Main Window"), {QStringLiteral("F2"), Qt::ApplicationShortcut}},
+ {QStringLiteral("Load File"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+O"), Qt::WindowShortcut}},
+ {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}},
+ {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), Qt::WindowShortcut}},
+ {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}},
+ {QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), Qt::ApplicationShortcut}},
+ {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), Qt::WindowShortcut}},
+ {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::ApplicationShortcut}},
+}};
+// clang-format on
void Config::ReadPlayerValues() {
for (std::size_t p = 0; p < Settings::values.players.size(); ++p) {
@@ -370,14 +374,21 @@ void Config::ReadMouseValues() {
}
void Config::ReadTouchscreenValues() {
- Settings::values.touchscreen.enabled = ReadSetting("touchscreen_enabled", true).toBool();
+ Settings::values.touchscreen.enabled =
+ ReadSetting(QStringLiteral("touchscreen_enabled"), true).toBool();
Settings::values.touchscreen.device =
- ReadSetting("touchscreen_device", "engine:emu_window").toString().toStdString();
+ ReadSetting(QStringLiteral("touchscreen_device"), QStringLiteral("engine:emu_window"))
+ .toString()
+ .toStdString();
- Settings::values.touchscreen.finger = ReadSetting("touchscreen_finger", 0).toUInt();
- Settings::values.touchscreen.rotation_angle = ReadSetting("touchscreen_angle", 0).toUInt();
- Settings::values.touchscreen.diameter_x = ReadSetting("touchscreen_diameter_x", 15).toUInt();
- Settings::values.touchscreen.diameter_y = ReadSetting("touchscreen_diameter_y", 15).toUInt();
+ Settings::values.touchscreen.finger =
+ ReadSetting(QStringLiteral("touchscreen_finger"), 0).toUInt();
+ Settings::values.touchscreen.rotation_angle =
+ ReadSetting(QStringLiteral("touchscreen_angle"), 0).toUInt();
+ Settings::values.touchscreen.diameter_x =
+ ReadSetting(QStringLiteral("touchscreen_diameter_x"), 15).toUInt();
+ Settings::values.touchscreen.diameter_y =
+ ReadSetting(QStringLiteral("touchscreen_diameter_y"), 15).toUInt();
}
void Config::ApplyDefaultProfileIfInputInvalid() {
@@ -541,8 +552,8 @@ void Config::ReadRendererValues() {
void Config::ReadShortcutValues() {
qt_config->beginGroup(QStringLiteral("Shortcuts"));
- for (auto [name, group, shortcut] : default_hotkeys) {
- auto [keyseq, context] = shortcut;
+ for (const auto& [name, group, shortcut] : default_hotkeys) {
+ const auto& [keyseq, context] = shortcut;
qt_config->beginGroup(group);
qt_config->beginGroup(name);
UISettings::values.shortcuts.push_back(
@@ -591,7 +602,8 @@ void Config::ReadUIValues() {
qt_config->beginGroup(QStringLiteral("UI"));
UISettings::values.theme =
- ReadSetting(QStringLiteral("theme"), UISettings::themes[0].second).toString();
+ ReadSetting(QStringLiteral("theme"), QString::fromUtf8(UISettings::themes[0].second))
+ .toString();
UISettings::values.enable_discord_presence =
ReadSetting(QStringLiteral("enable_discord_presence"), true).toBool();
UISettings::values.screenshot_resolution_factor =
@@ -626,7 +638,7 @@ void Config::ReadUIValues() {
}
void Config::ReadUIGamelistValues() {
- qt_config->beginGroup("UIGameList");
+ qt_config->beginGroup(QStringLiteral("UIGameList"));
UISettings::values.show_unknown = ReadSetting(QStringLiteral("show_unknown"), true).toBool();
UISettings::values.show_add_ons = ReadSetting(QStringLiteral("show_add_ons"), true).toBool();
@@ -723,7 +735,7 @@ void Config::SavePlayerValues() {
}
void Config::SaveDebugValues() {
- WriteSetting("debug_pad_enabled", Settings::values.debug_pad_enabled, false);
+ WriteSetting(QStringLiteral("debug_pad_enabled"), Settings::values.debug_pad_enabled, false);
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
WriteSetting(QStringLiteral("debug_pad_") +
@@ -924,7 +936,7 @@ void Config::SaveShortcutValues() {
// Lengths of UISettings::values.shortcuts & default_hotkeys are same.
// However, their ordering must also be the same.
for (std::size_t i = 0; i < default_hotkeys.size(); i++) {
- const auto [name, group, shortcut] = UISettings::values.shortcuts[i];
+ const auto& [name, group, shortcut] = UISettings::values.shortcuts[i];
const auto& default_hotkey = default_hotkeys[i].shortcut;
qt_config->beginGroup(group);
@@ -961,7 +973,8 @@ void Config::SaveSystemValues() {
void Config::SaveUIValues() {
qt_config->beginGroup(QStringLiteral("UI"));
- WriteSetting(QStringLiteral("theme"), UISettings::values.theme, UISettings::themes[0].second);
+ WriteSetting(QStringLiteral("theme"), UISettings::values.theme,
+ QString::fromUtf8(UISettings::themes[0].second));
WriteSetting(QStringLiteral("enable_discord_presence"),
UISettings::values.enable_discord_presence, true);
WriteSetting(QStringLiteral("screenshot_resolution_factor"),
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h
index b62a480ee..6b523ecdd 100644
--- a/src/yuzu/configuration/config.h
+++ b/src/yuzu/configuration/config.h
@@ -9,7 +9,6 @@
#include <string>
#include <QVariant>
#include "core/settings.h"
-#include "yuzu/ui_settings.h"
class QSettings;
@@ -82,8 +81,6 @@ private:
void WriteSetting(const QString& name, const QVariant& value);
void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value);
- static const std::array<UISettings::Shortcut, 15> default_hotkeys;
-
std::unique_ptr<QSettings> qt_config;
std::string qt_config_loc;
};