From 7c52bb27729fcd3aab08af70d512b1ad17927c39 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:38:12 -0400 Subject: shared_widget: Improve logging, use Setting::Ranged --- src/yuzu/configuration/shared_widget.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp index 6fdd00c67..f644b2ade 100644 --- a/src/yuzu/configuration/shared_widget.cpp +++ b/src/yuzu/configuration/shared_widget.cpp @@ -4,10 +4,12 @@ #include "yuzu/configuration/shared_widget.h" #include +#include #include #include #include #include + #include #include #include @@ -33,10 +35,10 @@ #include #include #include + #include "common/assert.h" #include "common/common_types.h" #include "common/logging/log.h" -#include "common/settings.h" #include "common/settings_common.h" #include "yuzu/configuration/shared_translation.h" @@ -178,6 +180,12 @@ QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& fo std::function& serializer, std::function& restore_func, const std::function& touch) { + if (!setting.Ranged()) { + LOG_ERROR(Frontend, "\"{}\" is not a ranged setting, but a slider was requested.", + setting.GetLabel()); + return nullptr; + } + QWidget* container = new QWidget(this); QHBoxLayout* layout = new QHBoxLayout(container); @@ -220,8 +228,10 @@ QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& fo QWidget* Widget::CreateSpinBox(const QString& suffix, std::function& serializer, std::function& restore_func, const std::function& touch) { - const int min_val = std::stoi(setting.MinVal()); - const int max_val = std::stoi(setting.MaxVal()); + const int min_val = + setting.Ranged() ? std::stoi(setting.MinVal()) : std::numeric_limits::min(); + const int max_val = + setting.Ranged() ? std::stoi(setting.MaxVal()) : std::numeric_limits::max(); const int default_val = std::stoi(setting.ToString()); spinbox = new QSpinBox(this); @@ -331,8 +341,10 @@ void Widget::SetupComponent(const QString& label, std::function& load_fu other_setting != nullptr && other_setting->TypeId() == typeid(bool); if (other_setting != nullptr && other_setting->TypeId() != typeid(bool)) { - LOG_WARNING(Frontend, - "Extra setting specified but is not bool, refusing to create checkbox for it."); + LOG_WARNING( + Frontend, + "Extra setting \"{}\" specified but is not bool, refusing to create checkbox for it.", + other_setting->GetLabel()); } std::function checkbox_serializer = []() -> std::string { return {}; }; @@ -348,7 +360,7 @@ void Widget::SetupComponent(const QString& label, std::function& load_fu restore_button = CreateRestoreGlobalButton(setting.UsingGlobal(), this); touch = [this]() { - LOG_DEBUG(Frontend, "Setting custom setting for {}", setting.GetLabel()); + LOG_DEBUG(Frontend, "Enabling custom setting for \"{}\"", setting.GetLabel()); restore_button->setEnabled(true); restore_button->setVisible(true); }; @@ -410,7 +422,7 @@ void Widget::SetupComponent(const QString& label, std::function& load_fu } if (data_component == nullptr) { - LOG_ERROR(Frontend, "Failed to create widget for {}", setting.GetLabel()); + LOG_ERROR(Frontend, "Failed to create widget for \"{}\"", setting.GetLabel()); created = false; return; } -- cgit v1.2.3