diff options
| author | 2023-06-13 19:38:12 -0400 | |
|---|---|---|
| committer | 2023-07-21 10:56:54 -0400 | |
| commit | 7c52bb27729fcd3aab08af70d512b1ad17927c39 (patch) | |
| tree | 9fab44d214a5e6c6aef05dce577b9fd18039221f /src | |
| parent | settings: Document BasicSetting, add Ranged (diff) | |
| download | yuzu-7c52bb27729fcd3aab08af70d512b1ad17927c39.tar.gz yuzu-7c52bb27729fcd3aab08af70d512b1ad17927c39.tar.xz yuzu-7c52bb27729fcd3aab08af70d512b1ad17927c39.zip | |
shared_widget: Improve logging, use Setting::Ranged
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/shared_widget.cpp | 26 |
1 files 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 @@ | |||
| 4 | #include "yuzu/configuration/shared_widget.h" | 4 | #include "yuzu/configuration/shared_widget.h" |
| 5 | 5 | ||
| 6 | #include <functional> | 6 | #include <functional> |
| 7 | #include <limits> | ||
| 7 | #include <typeindex> | 8 | #include <typeindex> |
| 8 | #include <typeinfo> | 9 | #include <typeinfo> |
| 9 | #include <utility> | 10 | #include <utility> |
| 10 | #include <vector> | 11 | #include <vector> |
| 12 | |||
| 11 | #include <QAbstractButton> | 13 | #include <QAbstractButton> |
| 12 | #include <QAbstractSlider> | 14 | #include <QAbstractSlider> |
| 13 | #include <QBoxLayout> | 15 | #include <QBoxLayout> |
| @@ -33,10 +35,10 @@ | |||
| 33 | #include <fmt/core.h> | 35 | #include <fmt/core.h> |
| 34 | #include <qglobal.h> | 36 | #include <qglobal.h> |
| 35 | #include <qnamespace.h> | 37 | #include <qnamespace.h> |
| 38 | |||
| 36 | #include "common/assert.h" | 39 | #include "common/assert.h" |
| 37 | #include "common/common_types.h" | 40 | #include "common/common_types.h" |
| 38 | #include "common/logging/log.h" | 41 | #include "common/logging/log.h" |
| 39 | #include "common/settings.h" | ||
| 40 | #include "common/settings_common.h" | 42 | #include "common/settings_common.h" |
| 41 | #include "yuzu/configuration/shared_translation.h" | 43 | #include "yuzu/configuration/shared_translation.h" |
| 42 | 44 | ||
| @@ -178,6 +180,12 @@ QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& fo | |||
| 178 | std::function<std::string()>& serializer, | 180 | std::function<std::string()>& serializer, |
| 179 | std::function<void()>& restore_func, | 181 | std::function<void()>& restore_func, |
| 180 | const std::function<void()>& touch) { | 182 | const std::function<void()>& touch) { |
| 183 | if (!setting.Ranged()) { | ||
| 184 | LOG_ERROR(Frontend, "\"{}\" is not a ranged setting, but a slider was requested.", | ||
| 185 | setting.GetLabel()); | ||
| 186 | return nullptr; | ||
| 187 | } | ||
| 188 | |||
| 181 | QWidget* container = new QWidget(this); | 189 | QWidget* container = new QWidget(this); |
| 182 | QHBoxLayout* layout = new QHBoxLayout(container); | 190 | QHBoxLayout* layout = new QHBoxLayout(container); |
| 183 | 191 | ||
| @@ -220,8 +228,10 @@ QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& fo | |||
| 220 | QWidget* Widget::CreateSpinBox(const QString& suffix, std::function<std::string()>& serializer, | 228 | QWidget* Widget::CreateSpinBox(const QString& suffix, std::function<std::string()>& serializer, |
| 221 | std::function<void()>& restore_func, | 229 | std::function<void()>& restore_func, |
| 222 | const std::function<void()>& touch) { | 230 | const std::function<void()>& touch) { |
| 223 | const int min_val = std::stoi(setting.MinVal()); | 231 | const int min_val = |
| 224 | const int max_val = std::stoi(setting.MaxVal()); | 232 | setting.Ranged() ? std::stoi(setting.MinVal()) : std::numeric_limits<int>::min(); |
| 233 | const int max_val = | ||
| 234 | setting.Ranged() ? std::stoi(setting.MaxVal()) : std::numeric_limits<int>::max(); | ||
| 225 | const int default_val = std::stoi(setting.ToString()); | 235 | const int default_val = std::stoi(setting.ToString()); |
| 226 | 236 | ||
| 227 | spinbox = new QSpinBox(this); | 237 | spinbox = new QSpinBox(this); |
| @@ -331,8 +341,10 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu | |||
| 331 | other_setting != nullptr && other_setting->TypeId() == typeid(bool); | 341 | other_setting != nullptr && other_setting->TypeId() == typeid(bool); |
| 332 | 342 | ||
| 333 | if (other_setting != nullptr && other_setting->TypeId() != typeid(bool)) { | 343 | if (other_setting != nullptr && other_setting->TypeId() != typeid(bool)) { |
| 334 | LOG_WARNING(Frontend, | 344 | LOG_WARNING( |
| 335 | "Extra setting specified but is not bool, refusing to create checkbox for it."); | 345 | Frontend, |
| 346 | "Extra setting \"{}\" specified but is not bool, refusing to create checkbox for it.", | ||
| 347 | other_setting->GetLabel()); | ||
| 336 | } | 348 | } |
| 337 | 349 | ||
| 338 | std::function<std::string()> checkbox_serializer = []() -> std::string { return {}; }; | 350 | std::function<std::string()> checkbox_serializer = []() -> std::string { return {}; }; |
| @@ -348,7 +360,7 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu | |||
| 348 | restore_button = CreateRestoreGlobalButton(setting.UsingGlobal(), this); | 360 | restore_button = CreateRestoreGlobalButton(setting.UsingGlobal(), this); |
| 349 | 361 | ||
| 350 | touch = [this]() { | 362 | touch = [this]() { |
| 351 | LOG_DEBUG(Frontend, "Setting custom setting for {}", setting.GetLabel()); | 363 | LOG_DEBUG(Frontend, "Enabling custom setting for \"{}\"", setting.GetLabel()); |
| 352 | restore_button->setEnabled(true); | 364 | restore_button->setEnabled(true); |
| 353 | restore_button->setVisible(true); | 365 | restore_button->setVisible(true); |
| 354 | }; | 366 | }; |
| @@ -410,7 +422,7 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu | |||
| 410 | } | 422 | } |
| 411 | 423 | ||
| 412 | if (data_component == nullptr) { | 424 | if (data_component == nullptr) { |
| 413 | LOG_ERROR(Frontend, "Failed to create widget for {}", setting.GetLabel()); | 425 | LOG_ERROR(Frontend, "Failed to create widget for \"{}\"", setting.GetLabel()); |
| 414 | created = false; | 426 | created = false; |
| 415 | return; | 427 | return; |
| 416 | } | 428 | } |