general: Code formatting improvements
Slight improvements to readability. Dropped suggestions for string_view (settings.h:101), pass by value (settings.h:82), reverting double to a float (config.cpp:316), and other smaller ones, some out of scope. Addresses review feedback. Co-authored-by: Ameer J <52414509+ameerj@users.noreply.github.com>
This commit is contained in:
parent
38f658d21e
commit
a949ee0410
|
@ -155,8 +155,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells this setting to represent either the global or custom setting when other member
|
* Tells this setting to represent either the global or custom setting when other member
|
||||||
* functions are used. Setting to_global to true means using the global setting, to false
|
* functions are used.
|
||||||
* false for the custom setting.
|
|
||||||
*
|
*
|
||||||
* @param to_global Whether to use the global or custom setting.
|
* @param to_global Whether to use the global or custom setting.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -264,8 +264,8 @@ struct System::Impl {
|
||||||
if (Settings::values.gamecard_current_game) {
|
if (Settings::values.gamecard_current_game) {
|
||||||
fs_controller.SetGameCard(GetGameFileFromPath(virtual_filesystem, filepath));
|
fs_controller.SetGameCard(GetGameFileFromPath(virtual_filesystem, filepath));
|
||||||
} else if (!Settings::values.gamecard_path.GetValue().empty()) {
|
} else if (!Settings::values.gamecard_path.GetValue().empty()) {
|
||||||
fs_controller.SetGameCard(GetGameFileFromPath(
|
const auto gamecard_path = Settings::values.gamecard_path.GetValue();
|
||||||
virtual_filesystem, static_cast<std::string>(Settings::values.gamecard_path)));
|
fs_controller.SetGameCard(GetGameFileFromPath(virtual_filesystem, gamecard_path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ public:
|
||||||
std::lock_guard lock{mutex};
|
std::lock_guard lock{mutex};
|
||||||
const auto axis_value =
|
const auto axis_value =
|
||||||
static_cast<float>(mouse_input->GetMouseState(button).axis.at(axis));
|
static_cast<float>(mouse_input->GetMouseState(button).axis.at(axis));
|
||||||
return axis_value * Settings::values.mouse_panning_sensitivity.GetValue() /
|
const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue();
|
||||||
(100.0f * range);
|
return axis_value * sensitivity / (100.0f * range);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<float, float> GetAnalog(u32 analog_axis_x, u32 analog_axis_y) const {
|
std::pair<float, float> GetAnalog(u32 analog_axis_x, u32 analog_axis_y) const {
|
||||||
|
|
|
@ -282,22 +282,23 @@ void Config::Initialize(const std::string& config_name) {
|
||||||
template <>
|
template <>
|
||||||
void Config::ReadBasicSetting(Settings::BasicSetting<std::string>& setting) {
|
void Config::ReadBasicSetting(Settings::BasicSetting<std::string>& setting) {
|
||||||
const QString name = QString::fromStdString(setting.GetLabel());
|
const QString name = QString::fromStdString(setting.GetLabel());
|
||||||
|
const auto default_value = QString::fromStdString(setting.GetDefault());
|
||||||
if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) {
|
if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) {
|
||||||
setting.SetValue(setting.GetDefault());
|
setting.SetValue(default_value.toStdString());
|
||||||
} else {
|
} else {
|
||||||
setting.SetValue(qt_config->value(name, QString::fromStdString(setting.GetDefault()))
|
setting.SetValue(qt_config->value(name, default_value).toString().toStdString());
|
||||||
.toString()
|
|
||||||
.toStdString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void Config::ReadBasicSetting(Settings::BasicSetting<Type>& setting) {
|
void Config::ReadBasicSetting(Settings::BasicSetting<Type>& setting) {
|
||||||
const QString name = QString::fromStdString(setting.GetLabel());
|
const QString name = QString::fromStdString(setting.GetLabel());
|
||||||
|
const Type default_value = setting.GetDefault();
|
||||||
if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) {
|
if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) {
|
||||||
setting.SetValue(setting.GetDefault());
|
setting.SetValue(default_value);
|
||||||
} else {
|
} else {
|
||||||
setting.SetValue(
|
setting.SetValue(
|
||||||
static_cast<QVariant>(qt_config->value(name, setting.GetDefault())).value<Type>());
|
static_cast<QVariant>(qt_config->value(name, default_value)).value<Type>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,10 +306,11 @@ void Config::ReadBasicSetting(Settings::BasicSetting<Type>& setting) {
|
||||||
template <>
|
template <>
|
||||||
void Config::WriteBasicSetting(const Settings::BasicSetting<std::string>& setting) {
|
void Config::WriteBasicSetting(const Settings::BasicSetting<std::string>& setting) {
|
||||||
const QString name = QString::fromStdString(setting.GetLabel());
|
const QString name = QString::fromStdString(setting.GetLabel());
|
||||||
qt_config->setValue(name + QStringLiteral("/default"),
|
const std::string& value = setting.GetValue();
|
||||||
setting.GetValue() == setting.GetDefault());
|
qt_config->setValue(name + QStringLiteral("/default"), value == setting.GetDefault());
|
||||||
qt_config->setValue(name, QString::fromStdString(setting.GetValue()));
|
qt_config->setValue(name, QString::fromStdString(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicit float definition: use a double as Qt doesn't write legible floats to config files
|
// Explicit float definition: use a double as Qt doesn't write legible floats to config files
|
||||||
template <>
|
template <>
|
||||||
void Config::WriteBasicSetting(const Settings::BasicSetting<float>& setting) {
|
void Config::WriteBasicSetting(const Settings::BasicSetting<float>& setting) {
|
||||||
|
@ -318,12 +320,13 @@ void Config::WriteBasicSetting(const Settings::BasicSetting<float>& setting) {
|
||||||
setting.GetValue() == setting.GetDefault());
|
setting.GetValue() == setting.GetDefault());
|
||||||
qt_config->setValue(name, value);
|
qt_config->setValue(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void Config::WriteBasicSetting(const Settings::BasicSetting<Type>& setting) {
|
void Config::WriteBasicSetting(const Settings::BasicSetting<Type>& setting) {
|
||||||
const QString name = QString::fromStdString(setting.GetLabel());
|
const QString name = QString::fromStdString(setting.GetLabel());
|
||||||
qt_config->setValue(name + QStringLiteral("/default"),
|
const Type value = setting.GetValue();
|
||||||
setting.GetValue() == setting.GetDefault());
|
qt_config->setValue(name + QStringLiteral("/default"), value == setting.GetDefault());
|
||||||
qt_config->setValue(name, setting.GetValue());
|
qt_config->setValue(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicit float definition: use a double as Qt doesn't write legible floats to config files
|
// Explicit float definition: use a double as Qt doesn't write legible floats to config files
|
||||||
|
@ -340,16 +343,17 @@ void Config::WriteGlobalSetting(const Settings::Setting<float>& setting) {
|
||||||
qt_config->setValue(name, value);
|
qt_config->setValue(name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void Config::WriteGlobalSetting(const Settings::Setting<Type>& setting) {
|
void Config::WriteGlobalSetting(const Settings::Setting<Type>& setting) {
|
||||||
QString name = QString::fromStdString(setting.GetLabel());
|
const QString name = QString::fromStdString(setting.GetLabel());
|
||||||
|
const Type& value = setting.GetValue(global);
|
||||||
if (!global) {
|
if (!global) {
|
||||||
qt_config->setValue(name + QStringLiteral("/use_global"), setting.UsingGlobal());
|
qt_config->setValue(name + QStringLiteral("/use_global"), setting.UsingGlobal());
|
||||||
}
|
}
|
||||||
if (global || !setting.UsingGlobal()) {
|
if (global || !setting.UsingGlobal()) {
|
||||||
qt_config->setValue(name + QStringLiteral("/default"),
|
qt_config->setValue(name + QStringLiteral("/default"), value == setting.GetDefault());
|
||||||
setting.GetValue(global) == setting.GetDefault());
|
qt_config->setValue(name, value);
|
||||||
qt_config->setValue(name, setting.GetValue(global));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue