mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
EnhancementsWidget:: Move to using ConfigControls and add new control for ComboBoxes that set two settings at once.
This commit is contained in:
@@ -71,3 +71,102 @@ void ConfigStringChoice::OnConfigChanged()
|
||||
{
|
||||
Load();
|
||||
}
|
||||
|
||||
ConfigComplexChoice::ConfigComplexChoice(const InfoVariant setting1, const InfoVariant setting2,
|
||||
Config::Layer* layer)
|
||||
: m_setting1(setting1), m_setting2(setting2), m_layer(layer)
|
||||
{
|
||||
connect(&Settings::Instance(), &Settings::ConfigChanged, this, &ConfigComplexChoice::Refresh);
|
||||
connect(this, &QComboBox::currentIndexChanged, this, &ConfigComplexChoice::SaveValue);
|
||||
}
|
||||
|
||||
void ConfigComplexChoice::Refresh()
|
||||
{
|
||||
auto& location = GetLocation();
|
||||
|
||||
QFont bf = font();
|
||||
if (m_layer != nullptr)
|
||||
{
|
||||
bf.setBold(m_layer->Exists(location.first) || m_layer->Exists(location.second));
|
||||
}
|
||||
else
|
||||
{
|
||||
bf.setBold(Config::GetActiveLayerForConfig(location.first) != Config::LayerType::Base ||
|
||||
Config::GetActiveLayerForConfig(location.second) != Config::LayerType::Base);
|
||||
}
|
||||
|
||||
setFont(bf);
|
||||
UpdateComboIndex();
|
||||
}
|
||||
|
||||
void ConfigComplexChoice::Add(const QString& name, const OptionVariant option1,
|
||||
const OptionVariant option2)
|
||||
{
|
||||
const QSignalBlocker blocker(this);
|
||||
addItem(name);
|
||||
m_options.push_back(std::make_pair(option1, option2));
|
||||
}
|
||||
|
||||
void ConfigComplexChoice::Reset()
|
||||
{
|
||||
clear();
|
||||
m_options.clear();
|
||||
}
|
||||
|
||||
void ConfigComplexChoice::SaveValue(int choice)
|
||||
{
|
||||
auto Set = [this, choice](auto& setting, auto& value) {
|
||||
if (m_layer != nullptr)
|
||||
{
|
||||
m_layer->Set(setting.GetLocation(), value);
|
||||
Config::OnConfigChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
Config::SetBaseOrCurrent(setting, value);
|
||||
};
|
||||
|
||||
std::visit(Set, m_setting1, m_options[choice].first);
|
||||
std::visit(Set, m_setting2, m_options[choice].second);
|
||||
}
|
||||
|
||||
void ConfigComplexChoice::UpdateComboIndex()
|
||||
{
|
||||
auto Get = [this](auto& setting) {
|
||||
if (m_layer != nullptr)
|
||||
return static_cast<OptionVariant>(m_layer->Get(setting));
|
||||
|
||||
return static_cast<OptionVariant>(Config::Get(setting));
|
||||
};
|
||||
|
||||
std::pair<OptionVariant, OptionVariant> values =
|
||||
std::make_pair(std::visit(Get, m_setting1), std::visit(Get, m_setting2));
|
||||
|
||||
auto it = std::find(m_options.begin(), m_options.end(), values);
|
||||
int index = static_cast<int>(std::distance(m_options.begin(), it));
|
||||
|
||||
const QSignalBlocker blocker(this);
|
||||
setCurrentIndex(index);
|
||||
}
|
||||
|
||||
const std::pair<Config::Location, Config::Location> ConfigComplexChoice::GetLocation() const
|
||||
{
|
||||
auto visit = [](auto& v) { return v.GetLocation(); };
|
||||
|
||||
return {std::visit(visit, m_setting1), std::visit(visit, m_setting2)};
|
||||
}
|
||||
|
||||
void ConfigComplexChoice::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::RightButton && m_layer != nullptr)
|
||||
{
|
||||
auto& location = GetLocation();
|
||||
m_layer->DeleteKey(location.first);
|
||||
m_layer->DeleteKey(location.second);
|
||||
Config::OnConfigChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
QComboBox::mousePressEvent(event);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -51,3 +51,30 @@ private:
|
||||
const Config::Info<std::string>& m_setting;
|
||||
bool m_text_is_data = false;
|
||||
};
|
||||
|
||||
class ConfigComplexChoice final : public ToolTipComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
using InfoVariant = std::variant<Config::Info<u32>, Config::Info<int>, Config::Info<bool>>;
|
||||
using OptionVariant = std::variant<u32, int, bool>;
|
||||
|
||||
public:
|
||||
ConfigComplexChoice(const InfoVariant setting1, const InfoVariant setting2,
|
||||
Config::Layer* layer = nullptr);
|
||||
|
||||
void Add(const QString& name, const OptionVariant option1, const OptionVariant option2);
|
||||
void Refresh();
|
||||
void Reset();
|
||||
const std::pair<Config::Location, Config::Location> GetLocation() const;
|
||||
|
||||
private:
|
||||
void SaveValue(int choice);
|
||||
void UpdateComboIndex();
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
|
||||
Config::Layer* m_layer;
|
||||
const InfoVariant m_setting1;
|
||||
const InfoVariant m_setting2;
|
||||
std::vector<std::pair<OptionVariant, OptionVariant>> m_options;
|
||||
};
|
||||
|
||||
@@ -363,4 +363,15 @@ void GameConfigWidget::SetItalics()
|
||||
italics(config);
|
||||
for (auto* config : findChildren<ConfigStringChoice*>())
|
||||
italics(config);
|
||||
|
||||
for (auto* config : findChildren<ConfigComplexChoice*>())
|
||||
{
|
||||
std::pair<Config::Location, Config::Location> location = config->GetLocation();
|
||||
if (m_global_layer->Exists(location.first) || m_global_layer->Exists(location.second))
|
||||
{
|
||||
QFont ifont = config->font();
|
||||
ifont.setItalic(true);
|
||||
config->setFont(ifont);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,19 +9,19 @@
|
||||
|
||||
class ConfigBool;
|
||||
class ConfigChoice;
|
||||
class ConfigComplexChoice;
|
||||
class ConfigStringChoice;
|
||||
class ConfigSlider;
|
||||
class GameConfigWidget;
|
||||
class GraphicsWindow;
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
class QPushButton;
|
||||
class QSlider;
|
||||
class ToolTipComboBox;
|
||||
class ToolTipPushButton;
|
||||
enum class StereoMode : int;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
template <typename T>
|
||||
class Info;
|
||||
class Layer;
|
||||
} // namespace Config
|
||||
|
||||
@@ -33,22 +33,28 @@ public:
|
||||
EnhancementsWidget(GameConfigWidget* parent, Config::Layer* layer);
|
||||
|
||||
private:
|
||||
void LoadSettings();
|
||||
void SaveSettings();
|
||||
template <typename T>
|
||||
T ReadSetting(const Config::Info<T>& setting) const;
|
||||
|
||||
void CreateWidgets();
|
||||
void ConnectWidgets();
|
||||
void AddDescriptions();
|
||||
|
||||
void OnBackendChanged();
|
||||
void UpdateAAOptions();
|
||||
void LoadPPShaders();
|
||||
void ShaderChanged();
|
||||
void OnConfigChanged();
|
||||
|
||||
void ConfigureColorCorrection();
|
||||
void ConfigurePostProcessingShader();
|
||||
void LoadPPShaders(StereoMode stereo_mode);
|
||||
|
||||
// Enhancements
|
||||
ConfigChoice* m_ir_combo;
|
||||
ToolTipComboBox* m_aa_combo;
|
||||
ToolTipComboBox* m_texture_filtering_combo;
|
||||
ToolTipComboBox* m_output_resampling_combo;
|
||||
ToolTipComboBox* m_pp_effect;
|
||||
ConfigComplexChoice* m_aa_combo;
|
||||
ConfigComplexChoice* m_texture_filtering_combo;
|
||||
ConfigChoice* m_output_resampling_combo;
|
||||
ConfigStringChoice* m_pp_effect;
|
||||
ToolTipPushButton* m_configure_color_correction;
|
||||
QPushButton* m_configure_pp_effect;
|
||||
ConfigBool* m_scaled_efb_copy;
|
||||
@@ -68,6 +74,4 @@ private:
|
||||
ConfigBool* m_3d_per_eye_resolution;
|
||||
|
||||
Config::Layer* m_game_layer = nullptr;
|
||||
int m_msaa_modes;
|
||||
bool m_block_save;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user