Config: Add support for enums
This makes it possible to use enums as the config type.
Default values are now clearer and there's no need for casts
when calling Config::Get/Set anymore.
In order to add support for enums, the common code was updated to
handle enums by using the underlying type when loading/saving settings.
A copy constructor is also provided for conversions from
`ConfigInfo<Enum>` to `ConfigInfo<underlying_type<Enum>>`
so that enum settings can still easily work with code that doesn't care
about the actual enum values (like Graphics{Choice,Radio} in DolphinQt2
which only treat the setting as an integer).
This commit is contained in:
@@ -6,11 +6,7 @@
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
namespace Config
|
||||
{
|
||||
template <typename T>
|
||||
struct ConfigInfo;
|
||||
}
|
||||
#include "Common/Config/Config.h"
|
||||
|
||||
class GraphicsChoice : public QComboBox
|
||||
{
|
||||
@@ -20,5 +16,5 @@ public:
|
||||
private:
|
||||
void Update(int choice);
|
||||
|
||||
const Config::ConfigInfo<int>& m_setting;
|
||||
Config::ConfigInfo<int> m_setting;
|
||||
};
|
||||
|
||||
@@ -6,11 +6,7 @@
|
||||
|
||||
#include <QRadioButton>
|
||||
|
||||
namespace Config
|
||||
{
|
||||
template <typename T>
|
||||
struct ConfigInfo;
|
||||
}
|
||||
#include "Common/Config/Config.h"
|
||||
|
||||
class GraphicsRadioInt : public QRadioButton
|
||||
{
|
||||
@@ -21,6 +17,6 @@ public:
|
||||
private:
|
||||
void Update();
|
||||
|
||||
const Config::ConfigInfo<int>& m_setting;
|
||||
Config::ConfigInfo<int> m_setting;
|
||||
int m_value;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user