diff --git a/src/xenia/ui/qt/tabs/settings/advanced_pane.cc b/src/xenia/ui/qt/settings/panes/advanced_pane.cc similarity index 100% rename from src/xenia/ui/qt/tabs/settings/advanced_pane.cc rename to src/xenia/ui/qt/settings/panes/advanced_pane.cc diff --git a/src/xenia/ui/qt/tabs/settings/advanced_pane.h b/src/xenia/ui/qt/settings/panes/advanced_pane.h similarity index 100% rename from src/xenia/ui/qt/tabs/settings/advanced_pane.h rename to src/xenia/ui/qt/settings/panes/advanced_pane.h diff --git a/src/xenia/ui/qt/tabs/settings/controls_pane.cc b/src/xenia/ui/qt/settings/panes/controls_pane.cc similarity index 100% rename from src/xenia/ui/qt/tabs/settings/controls_pane.cc rename to src/xenia/ui/qt/settings/panes/controls_pane.cc diff --git a/src/xenia/ui/qt/tabs/settings/controls_pane.h b/src/xenia/ui/qt/settings/panes/controls_pane.h similarity index 100% rename from src/xenia/ui/qt/tabs/settings/controls_pane.h rename to src/xenia/ui/qt/settings/panes/controls_pane.h diff --git a/src/xenia/ui/qt/tabs/settings/cpu_pane.cc b/src/xenia/ui/qt/settings/panes/cpu_pane.cc similarity index 100% rename from src/xenia/ui/qt/tabs/settings/cpu_pane.cc rename to src/xenia/ui/qt/settings/panes/cpu_pane.cc diff --git a/src/xenia/ui/qt/tabs/settings/cpu_pane.h b/src/xenia/ui/qt/settings/panes/cpu_pane.h similarity index 100% rename from src/xenia/ui/qt/tabs/settings/cpu_pane.h rename to src/xenia/ui/qt/settings/panes/cpu_pane.h diff --git a/src/xenia/ui/qt/tabs/settings/general_pane.cc b/src/xenia/ui/qt/settings/panes/general_pane.cc similarity index 88% rename from src/xenia/ui/qt/tabs/settings/general_pane.cc rename to src/xenia/ui/qt/settings/panes/general_pane.cc index 696cf3014..d9f64d0b8 100644 --- a/src/xenia/ui/qt/tabs/settings/general_pane.cc +++ b/src/xenia/ui/qt/settings/panes/general_pane.cc @@ -3,7 +3,7 @@ #include #include -#include "xenia/ui/qt/widgets/checkbox.h" +#include "xenia/ui/qt/settings/widgets/settings_checkbox.h" #include "xenia/ui/qt/widgets/combobox.h" #include "xenia/ui/qt/widgets/groupbox.h" #include "xenia/ui/qt/widgets/scroll_area.h" @@ -16,7 +16,7 @@ DECLARE_bool(show_debug_tab) const QStringList game_languages = { "English", "Japanese", "German", "French", "Spanish", - "Italian", "Korean", "Chinese", "Portugese", "Polish", + "Italian", "Korean", "Chinese", "Portuguese", "Polish", "Russian", "Swedish", "Turkish", "Norwegian", "Dutch"}; void GeneralPane::Build() { @@ -53,13 +53,9 @@ DECLARE_bool(show_debug_tab) groupbox_layout->setContentsMargins(16, 16, 16, 16); groupbox->setLayout(groupbox_layout); - XCheckBox* discord_presence_checkbox = new XCheckBox(); + auto discord_presence_checkbox = new SettingsCheckBox("discord"); discord_presence_checkbox->setText("Discord Rich Presence"); - - connect(discord_presence_checkbox, &XCheckBox::stateChanged, - [&](bool value) { - //update_config_var(cvars::cv_show_debug_tab, value); - }); + groupbox_layout->addWidget(discord_presence_checkbox); XCheckBox* game_icon_checkbox = new XCheckBox(); diff --git a/src/xenia/ui/qt/tabs/settings/general_pane.h b/src/xenia/ui/qt/settings/panes/general_pane.h similarity index 100% rename from src/xenia/ui/qt/tabs/settings/general_pane.h rename to src/xenia/ui/qt/settings/panes/general_pane.h diff --git a/src/xenia/ui/qt/tabs/settings/gpu_pane.cc b/src/xenia/ui/qt/settings/panes/gpu_pane.cc similarity index 100% rename from src/xenia/ui/qt/tabs/settings/gpu_pane.cc rename to src/xenia/ui/qt/settings/panes/gpu_pane.cc diff --git a/src/xenia/ui/qt/tabs/settings/gpu_pane.h b/src/xenia/ui/qt/settings/panes/gpu_pane.h similarity index 100% rename from src/xenia/ui/qt/tabs/settings/gpu_pane.h rename to src/xenia/ui/qt/settings/panes/gpu_pane.h diff --git a/src/xenia/ui/qt/tabs/settings/interface_pane.cc b/src/xenia/ui/qt/settings/panes/interface_pane.cc similarity index 100% rename from src/xenia/ui/qt/tabs/settings/interface_pane.cc rename to src/xenia/ui/qt/settings/panes/interface_pane.cc diff --git a/src/xenia/ui/qt/tabs/settings/interface_pane.h b/src/xenia/ui/qt/settings/panes/interface_pane.h similarity index 100% rename from src/xenia/ui/qt/tabs/settings/interface_pane.h rename to src/xenia/ui/qt/settings/panes/interface_pane.h diff --git a/src/xenia/ui/qt/tabs/settings/library_pane.cc b/src/xenia/ui/qt/settings/panes/library_pane.cc similarity index 100% rename from src/xenia/ui/qt/tabs/settings/library_pane.cc rename to src/xenia/ui/qt/settings/panes/library_pane.cc diff --git a/src/xenia/ui/qt/tabs/settings/library_pane.h b/src/xenia/ui/qt/settings/panes/library_pane.h similarity index 100% rename from src/xenia/ui/qt/tabs/settings/library_pane.h rename to src/xenia/ui/qt/settings/panes/library_pane.h diff --git a/src/xenia/ui/qt/tabs/settings/settings_pane.h b/src/xenia/ui/qt/settings/panes/settings_pane.h similarity index 94% rename from src/xenia/ui/qt/tabs/settings/settings_pane.h rename to src/xenia/ui/qt/settings/panes/settings_pane.h index e7db4349f..0b2f66099 100644 --- a/src/xenia/ui/qt/tabs/settings/settings_pane.h +++ b/src/xenia/ui/qt/settings/panes/settings_pane.h @@ -6,6 +6,7 @@ #include "xenia/base/cvar.h" #include "xenia/config.h" #include "xenia/ui/qt/themeable_widget.h" +#include "xenia/config.h" namespace xe { namespace ui { @@ -49,7 +50,7 @@ bool SettingsPane::update_config_var(cvar::ConfigVar* var, const T& value) const { var->SetConfigValue(value); - config::SaveConfig(); + Config::Instance().SaveConfig(); return true; } @@ -64,7 +65,7 @@ bool SettingsPane::update_config_var(cvar::ConfigVar* var, var->SetConfigValue(value.value()); - config::SaveConfig(); + Config::Instance().SaveConfig(); return true; } diff --git a/src/xenia/ui/qt/settings/widgets/settings_checkbox.h b/src/xenia/ui/qt/settings/widgets/settings_checkbox.h new file mode 100644 index 000000000..5f0dcc37b --- /dev/null +++ b/src/xenia/ui/qt/settings/widgets/settings_checkbox.h @@ -0,0 +1,48 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2020 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_UI_QT_SETTINGS_SETTINGS_CHECKBOX_H_ +#define XENIA_UI_QT_SETTINGS_SETTINGS_CHECKBOX_H_ + +#include "settings_widget.h" +#include "xenia/base/logging.h" +#include "xenia/ui/qt/widgets/checkbox.h" + +namespace xe { +namespace ui { +namespace qt { + +class SettingsCheckBox : public SettingsWidget { + public: + explicit SettingsCheckBox(const std::string& config_name, + QWidget* parent = nullptr) + : SettingsWidget(config_name, parent) { + if (!cvar_) { + return; + } + + setChecked(*cvar_->current_value()); + + connect(this, &SettingsCheckBox::stateChanged, [&](int state) { + if (state == Qt::Checked) { + UpdateValue(true); + } else if (state == Qt::Unchecked) { + UpdateValue(false); + } else { + XELOGW("PartiallyChecked state not supported for SettingsCheckBox"); + } + }); + } +}; + +} // namespace qt +} // namespace ui +} // namespace xe + +#endif \ No newline at end of file diff --git a/src/xenia/ui/qt/settings/widgets/settings_combobox.h b/src/xenia/ui/qt/settings/widgets/settings_combobox.h new file mode 100644 index 000000000..5b52b3978 --- /dev/null +++ b/src/xenia/ui/qt/settings/widgets/settings_combobox.h @@ -0,0 +1,19 @@ +#ifndef XENIA_UI_QT_SETTINGS_SETTINGS_COMBOBOX_H_ +#define XENIA_UI_QT_SETTINGS_SETTINGS_COMBOBOX_H_ + +#include "settings_widget.h" +#include "xenia/ui/qt/widgets/combobox.h" + +namespace xe { +namespace ui { +namespace qt { + +template +class SettingsComboBox : SettingsWidget { + static_assert(std::is_same_v || std::is_same_v, + "Settings TextEdit must use std::string or int"); +}; + +} // namespace qt +} // namespace ui +} // namespace xe \ No newline at end of file diff --git a/src/xenia/ui/qt/settings/widgets/settings_radio_button.h b/src/xenia/ui/qt/settings/widgets/settings_radio_button.h new file mode 100644 index 000000000..6c2aeab1e --- /dev/null +++ b/src/xenia/ui/qt/settings/widgets/settings_radio_button.h @@ -0,0 +1,15 @@ +#ifndef XENIA_UI_QT_SETTINGS_SETTINGS_RADIOBOX_H_ +#define XENIA_UI_QT_SETTINGS_SETTINGS_RADIOBOX_H_ + +#include "settings_widget.h" +#include "xenia/ui/qt/widgets/radiobox.h" + +namespace xe { +namespace ui { +namespace qt { + +class SettingsRadioBox : SettingsWidget {}; + +} // namespace qt +} // namespace ui +} // namespace xe \ No newline at end of file diff --git a/src/xenia/ui/qt/settings/widgets/settings_text_edit.h b/src/xenia/ui/qt/settings/widgets/settings_text_edit.h new file mode 100644 index 000000000..11ff85b48 --- /dev/null +++ b/src/xenia/ui/qt/settings/widgets/settings_text_edit.h @@ -0,0 +1,23 @@ +#ifndef XENIA_UI_QT_SETTINGS_SETTINGS_TEXT_EDIT_H_ +#define XENIA_UI_QT_SETTINGS_SETTINGS_TEXT_EDIT_H_ + +#include +#include +#include "settings_widget.h" +#include "xenia/ui/qt/widgets/text_edit.h" + +namespace xe { +namespace ui { +namespace qt { + +template +class SettingsTextEdit : SettingsWidget { + static_assert( + std::is_same_v || + std::is_same_v, + "Settings TextEdit must use std::string or std::filesystem::path"); +}; + +} // namespace qt +} // namespace ui +} // namespace xe \ No newline at end of file diff --git a/src/xenia/ui/qt/settings/widgets/settings_widget.h b/src/xenia/ui/qt/settings/widgets/settings_widget.h new file mode 100644 index 000000000..fbf4d0f0e --- /dev/null +++ b/src/xenia/ui/qt/settings/widgets/settings_widget.h @@ -0,0 +1,48 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2020 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_UI_QT_SETTINGS_SETTINGS_WIDGET_H_ +#define XENIA_UI_QT_SETTINGS_SETTINGS_WIDGET_H_ + +#include "xenia/base/cvar.h" +#include "xenia/config.h" +#include "xenia/ui/qt/themeable_widget.h" + +namespace xe { +namespace ui { +namespace qt { + +template +class SettingsWidget : public Widget { + public: + template + SettingsWidget(const std::string& config_name, Args... args) + : Widget(args...), cvar_(nullptr) { + cvar_ = dynamic_cast*>( + Config::Instance().FindConfigVar(config_name)); + } + + void UpdateValue(T val) { + if (cvar_) { + cvar_->set_config_value(val); + } + Config::Instance().SaveConfig(); + } + + void SaveToConfig() { Config::Instance().SaveConfig(); } + + protected: + cvar::ConfigVar* cvar_; +}; + +} // namespace qt +} // namespace ui +} // namespace xe + +#endif \ No newline at end of file diff --git a/src/xenia/ui/qt/tabs/settings_tab.cc b/src/xenia/ui/qt/tabs/settings_tab.cc index 34d80ecfa..92dccf474 100644 --- a/src/xenia/ui/qt/tabs/settings_tab.cc +++ b/src/xenia/ui/qt/tabs/settings_tab.cc @@ -4,13 +4,13 @@ #include #include -#include "settings/advanced_pane.h" -#include "settings/controls_pane.h" -#include "settings/cpu_pane.h" -#include "settings/general_pane.h" -#include "settings/gpu_pane.h" -#include "settings/interface_pane.h" -#include "settings/library_pane.h" +#include "xenia/ui/qt/settings/panes/advanced_pane.h" +#include "xenia/ui/qt/settings/panes/controls_pane.h" +#include "xenia/ui/qt/settings/panes/cpu_pane.h" +#include "xenia/ui/qt/settings/panes/general_pane.h" +#include "xenia/ui/qt/settings/panes/gpu_pane.h" +#include "xenia/ui/qt/settings/panes/interface_pane.h" +#include "xenia/ui/qt/settings/panes/library_pane.h" #include "xenia/ui/qt/widgets/separator.h"