mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Add GFX property tabs to game properties window, allowing them to be set to the user game ini. Additionally, refactor ConfigWidgets to reduce duplication. Refactor GameConfigWidget to use config system.
Creates a layer outside the game config layer system and passes it to the created gfx widows, so as to not interfere with the global config system. Supports multiple game properties being open at once. Supports editing while a game is playing, but the options only save and update the active game when the window is closed. Right-clicking will remove a property from the game ini.
This commit is contained in:
@ -4,7 +4,13 @@
|
||||
#include "DolphinQt/Config/ConfigControls/ConfigBool.h"
|
||||
|
||||
ConfigBool::ConfigBool(const QString& label, const Config::Info<bool>& setting, bool reverse)
|
||||
: ConfigControl(label, setting.GetLocation()), m_setting(setting), m_reverse(reverse)
|
||||
: ConfigBool(label, setting, nullptr, reverse)
|
||||
{
|
||||
}
|
||||
|
||||
ConfigBool::ConfigBool(const QString& label, const Config::Info<bool>& setting,
|
||||
Config::Layer* layer, bool reverse)
|
||||
: ConfigControl(label, setting.GetLocation(), layer), m_setting(setting), m_reverse(reverse)
|
||||
{
|
||||
setChecked(ReadValue(setting) ^ reverse);
|
||||
|
||||
|
@ -17,6 +17,8 @@ class ConfigBool final : public ConfigControl<ToolTipCheckBox>
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigBool(const QString& label, const Config::Info<bool>& setting, bool reverse = false);
|
||||
ConfigBool(const QString& label, const Config::Info<bool>& setting, Config::Layer* layer,
|
||||
bool reverse = false);
|
||||
|
||||
protected:
|
||||
void OnConfigChanged() override;
|
||||
|
@ -5,8 +5,9 @@
|
||||
|
||||
#include <QSignalBlocker>
|
||||
|
||||
ConfigChoice::ConfigChoice(const QStringList& options, const Config::Info<int>& setting)
|
||||
: ConfigControl(setting.GetLocation()), m_setting(setting)
|
||||
ConfigChoice::ConfigChoice(const QStringList& options, const Config::Info<int>& setting,
|
||||
Config::Layer* layer)
|
||||
: ConfigControl(setting.GetLocation(), layer), m_setting(setting)
|
||||
{
|
||||
addItems(options);
|
||||
setCurrentIndex(ReadValue(setting));
|
||||
@ -25,8 +26,9 @@ void ConfigChoice::OnConfigChanged()
|
||||
}
|
||||
|
||||
ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
|
||||
const Config::Info<std::string>& setting)
|
||||
: ConfigControl(setting.GetLocation()), m_setting(setting), m_text_is_data(true)
|
||||
const Config::Info<std::string>& setting,
|
||||
Config::Layer* layer)
|
||||
: ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(true)
|
||||
{
|
||||
for (const auto& op : options)
|
||||
addItem(QString::fromStdString(op));
|
||||
@ -36,8 +38,9 @@ ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
|
||||
}
|
||||
|
||||
ConfigStringChoice::ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options,
|
||||
const Config::Info<std::string>& setting)
|
||||
: ConfigControl(setting.GetLocation()), m_setting(setting), m_text_is_data(false)
|
||||
const Config::Info<std::string>& setting,
|
||||
Config::Layer* layer)
|
||||
: ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(false)
|
||||
{
|
||||
for (const auto& [option_text, option_data] : options)
|
||||
addItem(option_text, option_data);
|
||||
@ -57,9 +60,10 @@ void ConfigStringChoice::Update(int index)
|
||||
void ConfigStringChoice::Load()
|
||||
{
|
||||
const QString setting_value = QString::fromStdString(ReadValue(m_setting));
|
||||
|
||||
const int index = m_text_is_data ? findText(setting_value) : findData(setting_value);
|
||||
const QSignalBlocker blocker(this);
|
||||
|
||||
// This can be called publicly.
|
||||
const QSignalBlocker block(this);
|
||||
setCurrentIndex(index);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,8 @@ class ConfigChoice final : public ConfigControl<ToolTipComboBox>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigChoice(const QStringList& options, const Config::Info<int>& setting);
|
||||
ConfigChoice(const QStringList& options, const Config::Info<int>& setting,
|
||||
Config::Layer* layer = nullptr);
|
||||
|
||||
protected:
|
||||
void OnConfigChanged() override;
|
||||
@ -36,16 +37,16 @@ class ConfigStringChoice final : public ConfigControl<ToolTipComboBox>
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigStringChoice(const std::vector<std::string>& options,
|
||||
const Config::Info<std::string>& setting);
|
||||
const Config::Info<std::string>& setting, Config::Layer* layer = nullptr);
|
||||
ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options,
|
||||
const Config::Info<std::string>& setting);
|
||||
const Config::Info<std::string>& setting, Config::Layer* layer = nullptr);
|
||||
void Load();
|
||||
|
||||
protected:
|
||||
void OnConfigChanged() override;
|
||||
|
||||
private:
|
||||
void Update(int index);
|
||||
void Load();
|
||||
|
||||
const Config::Info<std::string>& m_setting;
|
||||
bool m_text_is_data = false;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QSignalBlocker>
|
||||
|
||||
#include "Common/Config/Enums.h"
|
||||
#include "Common/Config/Layer.h"
|
||||
#include "DolphinQt/Settings.h"
|
||||
|
||||
namespace Config
|
||||
@ -21,14 +22,19 @@ template <class Derived>
|
||||
class ConfigControl : public Derived
|
||||
{
|
||||
public:
|
||||
ConfigControl(const Config::Location& location) : m_location(location) { ConnectConfig(); }
|
||||
ConfigControl(const QString& label, const Config::Location& location)
|
||||
: Derived(label), m_location(location)
|
||||
ConfigControl(const Config::Location& location, Config::Layer* layer)
|
||||
: m_location(location), m_layer(layer)
|
||||
{
|
||||
ConnectConfig();
|
||||
}
|
||||
ConfigControl(const Qt::Orientation& orient, const Config::Location& location)
|
||||
: Derived(orient), m_location(location)
|
||||
ConfigControl(const QString& label, const Config::Location& location, Config::Layer* layer)
|
||||
: Derived(label), m_location(location), m_layer(layer)
|
||||
{
|
||||
ConnectConfig();
|
||||
}
|
||||
ConfigControl(const Qt::Orientation& orient, const Config::Location& location,
|
||||
Config::Layer* layer)
|
||||
: Derived(orient), m_location(location), m_layer(layer)
|
||||
{
|
||||
ConnectConfig();
|
||||
}
|
||||
@ -51,22 +57,49 @@ protected:
|
||||
template <typename T>
|
||||
void SaveValue(const Config::Info<T>& setting, const T& value)
|
||||
{
|
||||
if (m_layer != nullptr)
|
||||
{
|
||||
m_layer->Set(m_location, value);
|
||||
Config::OnConfigChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
Config::SetBaseOrCurrent(setting, value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T ReadValue(const Config::Info<T>& setting) const
|
||||
{
|
||||
if (m_layer != nullptr)
|
||||
return m_layer->Get(setting);
|
||||
|
||||
return Config::Get(setting);
|
||||
}
|
||||
|
||||
virtual void OnConfigChanged() {};
|
||||
virtual void OnConfigChanged(){};
|
||||
|
||||
private:
|
||||
bool IsConfigLocal() const
|
||||
{
|
||||
return Config::GetActiveLayerForConfig(m_location) != Config::LayerType::Base;
|
||||
if (m_layer != nullptr)
|
||||
return m_layer->Exists(m_location);
|
||||
else
|
||||
return Config::GetActiveLayerForConfig(m_location) != Config::LayerType::Base;
|
||||
}
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override
|
||||
{
|
||||
if (m_layer != nullptr && event->button() == Qt::RightButton)
|
||||
{
|
||||
m_layer->DeleteKey(m_location);
|
||||
Config::OnConfigChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
Derived::mousePressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
const Config::Location m_location;
|
||||
Config::Layer* m_layer;
|
||||
};
|
||||
|
@ -4,8 +4,9 @@
|
||||
#include "DolphinQt/Config/ConfigControls/ConfigFloatSlider.h"
|
||||
|
||||
ConfigFloatSlider::ConfigFloatSlider(float minimum, float maximum,
|
||||
const Config::Info<float>& setting, float step)
|
||||
: ConfigControl(Qt::Horizontal, setting.GetLocation()), m_minimum(minimum), m_step(step),
|
||||
const Config::Info<float>& setting, float step,
|
||||
Config::Layer* layer)
|
||||
: ConfigControl(Qt::Horizontal, setting.GetLocation(), layer), m_minimum(minimum), m_step(step),
|
||||
m_setting(setting)
|
||||
{
|
||||
const float range = maximum - minimum;
|
||||
|
@ -18,7 +18,8 @@ class ConfigFloatSlider final : public ConfigControl<ToolTipSlider>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigFloatSlider(float minimum, float maximum, const Config::Info<float>& setting, float step);
|
||||
ConfigFloatSlider(float minimum, float maximum, const Config::Info<float>& setting, float step,
|
||||
Config::Layer* layer = nullptr);
|
||||
void Update(int value);
|
||||
|
||||
// Returns the adjusted float value
|
||||
|
@ -4,7 +4,13 @@
|
||||
#include "DolphinQt/Config/ConfigControls/ConfigInteger.h"
|
||||
|
||||
ConfigInteger::ConfigInteger(int minimum, int maximum, const Config::Info<int>& setting, int step)
|
||||
: ConfigControl(setting.GetLocation()), m_setting(setting)
|
||||
: ConfigInteger(minimum, maximum, setting, nullptr, step)
|
||||
{
|
||||
}
|
||||
|
||||
ConfigInteger::ConfigInteger(int minimum, int maximum, const Config::Info<int>& setting,
|
||||
Config::Layer* layer, int step)
|
||||
: ConfigControl(setting.GetLocation(), layer), m_setting(setting)
|
||||
{
|
||||
setMinimum(minimum);
|
||||
setMaximum(maximum);
|
||||
|
@ -17,6 +17,9 @@ class ConfigInteger final : public ConfigControl<ToolTipSpinBox>
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigInteger(int minimum, int maximum, const Config::Info<int>& setting, int step = 1);
|
||||
ConfigInteger(int minimum, int maximum, const Config::Info<int>& setting, Config::Layer* layer,
|
||||
int step = 1);
|
||||
|
||||
void Update(int value);
|
||||
|
||||
protected:
|
||||
|
@ -3,8 +3,9 @@
|
||||
|
||||
#include "DolphinQt/Config/ConfigControls/ConfigRadio.h"
|
||||
|
||||
ConfigRadioInt::ConfigRadioInt(const QString& label, const Config::Info<int>& setting, int value)
|
||||
: ConfigControl(label, setting.GetLocation()), m_setting(setting), m_value(value)
|
||||
ConfigRadioInt::ConfigRadioInt(const QString& label, const Config::Info<int>& setting, int value,
|
||||
Config::Layer* layer)
|
||||
: ConfigControl(label, setting.GetLocation(), layer), m_setting(setting), m_value(value)
|
||||
{
|
||||
setChecked(ReadValue(setting) == value);
|
||||
|
||||
|
@ -16,7 +16,8 @@ class ConfigRadioInt final : public ConfigControl<ToolTipRadioButton>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigRadioInt(const QString& label, const Config::Info<int>& setting, int value);
|
||||
ConfigRadioInt(const QString& label, const Config::Info<int>& setting, int value,
|
||||
Config::Layer* layer = nullptr);
|
||||
|
||||
signals:
|
||||
// Since selecting a new radio button deselects the old one, ::toggled will generate two signals.
|
||||
|
@ -4,7 +4,13 @@
|
||||
#include "DolphinQt/Config/ConfigControls/ConfigSlider.h"
|
||||
|
||||
ConfigSlider::ConfigSlider(int minimum, int maximum, const Config::Info<int>& setting, int tick)
|
||||
: ConfigControl(Qt::Horizontal, setting.GetLocation()), m_setting(setting)
|
||||
: ConfigSlider(minimum, maximum, setting, nullptr, tick)
|
||||
{
|
||||
}
|
||||
|
||||
ConfigSlider::ConfigSlider(int minimum, int maximum, const Config::Info<int>& setting,
|
||||
Config::Layer* layer, int tick)
|
||||
: ConfigControl(Qt::Horizontal, setting.GetLocation(), layer), m_setting(setting)
|
||||
|
||||
{
|
||||
setMinimum(minimum);
|
||||
|
@ -17,6 +17,9 @@ class ConfigSlider final : public ConfigControl<ToolTipSlider>
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigSlider(int minimum, int maximum, const Config::Info<int>& setting, int tick = 0);
|
||||
ConfigSlider(int minimum, int maximum, const Config::Info<int>& setting, Config::Layer* layer,
|
||||
int tick = 0);
|
||||
|
||||
void Update(int value);
|
||||
|
||||
protected:
|
||||
|
Reference in New Issue
Block a user