[Qt] Move settings panes and widgets folders outside of tabs folder

This commit is contained in:
Satori 2020-08-27 18:14:25 +01:00
parent 333f55d27a
commit b2f5186249
21 changed files with 167 additions and 17 deletions

View File

@ -3,7 +3,7 @@
#include <QLabel>
#include <QVBoxLayout>
#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();

View File

@ -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<T>* 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<T>* var,
var->SetConfigValue(value.value<T>());
config::SaveConfig();
Config::Instance().SaveConfig();
return true;
}

View File

@ -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<bool, XCheckBox> {
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

View File

@ -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 <typename T>
class SettingsComboBox : SettingsWidget<T, XComboBox> {
static_assert(std::is_same_v<T, std::string> || std::is_same_v<T, int>,
"Settings TextEdit must use std::string or int");
};
} // namespace qt
} // namespace ui
} // namespace xe

View File

@ -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<int, XRadioBox> {};
} // namespace qt
} // namespace ui
} // namespace xe

View File

@ -0,0 +1,23 @@
#ifndef XENIA_UI_QT_SETTINGS_SETTINGS_TEXT_EDIT_H_
#define XENIA_UI_QT_SETTINGS_SETTINGS_TEXT_EDIT_H_
#include <filesystem>
#include <string>
#include "settings_widget.h"
#include "xenia/ui/qt/widgets/text_edit.h"
namespace xe {
namespace ui {
namespace qt {
template <typename T>
class SettingsTextEdit : SettingsWidget<T, XRadioBox> {
static_assert(
std::is_same_v<T, std::string> ||
std::is_same_v<T, std::filesystem::path>,
"Settings TextEdit must use std::string or std::filesystem::path");
};
} // namespace qt
} // namespace ui
} // namespace xe

View File

@ -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 <typename T, typename Widget>
class SettingsWidget : public Widget {
public:
template <typename... Args>
SettingsWidget(const std::string& config_name, Args... args)
: Widget(args...), cvar_(nullptr) {
cvar_ = dynamic_cast<cvar::ConfigVar<T>*>(
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<T>* cvar_;
};
} // namespace qt
} // namespace ui
} // namespace xe
#endif

View File

@ -4,13 +4,13 @@
#include <QGraphicsEffect>
#include <QScrollArea>
#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"