@ -149,14 +149,14 @@ void Config::ReadGlobalSetting(Settings::SwitchableSetting<Type, ranged>& settin
const bool use_global = qt_config - > value ( name + QStringLiteral ( " /use_global " ) , true ) . toBool ( ) ;
setting . SetGlobal ( use_global ) ;
if ( global | | ! use_global ) {
QVariant value{ } ;
QVariant default_ value{ } ;
if constexpr ( std : : is_enum_v < Type > ) {
using TypeU = std : : underlying_type_t < Type > ;
value = QVariant : : fromValue < TypeU > ( static_cast < TypeU > ( setting . GetDefault ( ) ) ) ;
setting . SetValue ( static_cast < Type > ( ReadSetting ( name , value) . value < TypeU > ( ) ) ) ;
default_ value = QVariant : : fromValue < TypeU > ( static_cast < TypeU > ( setting . GetDefault ( ) ) ) ;
setting . SetValue ( static_cast < Type > ( ReadSetting ( name , default_ value) . value < TypeU > ( ) ) ) ;
} else {
value = QVariant : : fromValue < Type > ( setting . GetDefault ( ) ) ;
setting . SetValue ( ReadSetting ( name , value) . value < Type > ( ) ) ;
default_ value = QVariant : : fromValue < Type > ( setting . GetDefault ( ) ) ;
setting . SetValue ( ReadSetting ( name , default_ value) . value < Type > ( ) ) ;
}
}
}
@ -182,6 +182,15 @@ void Config::WriteBasicSetting(const Settings::Setting<std::string>& setting) {
qt_config - > setValue ( name , QString : : fromStdString ( value ) ) ;
}
// Explicit u16 definition: Qt would store it as QMetaType otherwise, which is not human-readable
template < >
void Config : : WriteBasicSetting ( const Settings : : Setting < u16 > & setting ) {
const QString name = QString : : fromStdString ( setting . GetLabel ( ) ) ;
const u16 & value = setting . GetValue ( ) ;
qt_config - > setValue ( name + QStringLiteral ( " /default " ) , value = = setting . GetDefault ( ) ) ;
qt_config - > setValue ( name , static_cast < u32 > ( value ) ) ;
}
template < typename Type , bool ranged >
void Config : : WriteBasicSetting ( const Settings : : Setting < Type , ranged > & setting ) {
const QString name = QString : : fromStdString ( setting . GetLabel ( ) ) ;
@ -224,6 +233,20 @@ void Config::WriteGlobalSetting(const Settings::SwitchableSetting<std::string>&
}
}
// Explicit u16 definition: Qt would store it as QMetaType otherwise, which is not human-readable
template < >
void Config : : WriteGlobalSetting ( const Settings : : SwitchableSetting < u16 , true > & setting ) {
const QString name = QString : : fromStdString ( setting . GetLabel ( ) ) ;
const u16 & value = setting . GetValue ( global ) ;
if ( ! global ) {
qt_config - > setValue ( name + QStringLiteral ( " /use_global " ) , setting . UsingGlobal ( ) ) ;
}
if ( global | | ! setting . UsingGlobal ( ) ) {
qt_config - > setValue ( name + QStringLiteral ( " /default " ) , value = = setting . GetDefault ( ) ) ;
qt_config - > setValue ( name , static_cast < u32 > ( value ) ) ;
}
}
void Config : : ReadValues ( ) {
if ( global ) {
ReadControlValues ( ) ;
@ -474,13 +497,8 @@ void Config::ReadLayoutValues() {
ReadGlobalSetting ( Settings : : values . render_3d ) ;
ReadGlobalSetting ( Settings : : values . factor_3d ) ;
Settings : : values . pp_shader_name =
ReadSetting ( QStringLiteral ( " pp_shader_name " ) , ( Settings : : values . render_3d . GetValue ( ) = =
Settings : : StereoRenderOption : : Anaglyph )
? QStringLiteral ( " dubois (builtin) " )
: QStringLiteral ( " none (builtin) " ) )
. toString ( )
. toStdString ( ) ;
ReadGlobalSetting ( Settings : : values . pp_shader_name ) ;
ReadGlobalSetting ( Settings : : values . anaglyph_shader_name ) ;
ReadGlobalSetting ( Settings : : values . filter_mode ) ;
ReadGlobalSetting ( Settings : : values . layout_option ) ;
ReadGlobalSetting ( Settings : : values . swap_screen ) ;
@ -989,11 +1007,8 @@ void Config::SaveLayoutValues() {
WriteGlobalSetting ( Settings : : values . render_3d ) ;
WriteGlobalSetting ( Settings : : values . factor_3d ) ;
WriteSetting ( QStringLiteral ( " pp_shader_name " ) ,
QString : : fromStdString ( Settings : : values . pp_shader_name . GetValue ( ) ) ,
( Settings : : values . render_3d . GetValue ( ) = = Settings : : StereoRenderOption : : Anaglyph )
? QStringLiteral ( " dubois (builtin) " )
: QStringLiteral ( " none (builtin) " ) ) ;
WriteGlobalSetting ( Settings : : values . pp_shader_name ) ;
WriteGlobalSetting ( Settings : : values . anaglyph_shader_name ) ;
WriteGlobalSetting ( Settings : : values . filter_mode ) ;
WriteGlobalSetting ( Settings : : values . layout_option ) ;
WriteGlobalSetting ( Settings : : values . swap_screen ) ;
@ -1276,15 +1291,6 @@ QVariant Config::ReadSetting(const QString& name, const QVariant& default_value)
return result ;
}
template < typename Type >
void Config : : ReadSettingGlobal ( Type & setting , const QString & name ,
const QVariant & default_value ) const {
const bool use_global = qt_config - > value ( name + QStringLiteral ( " /use_global " ) , true ) . toBool ( ) ;
if ( global | | ! use_global ) {
setting = ReadSetting ( name , default_value ) . value < Type > ( ) ;
}
}
void Config : : WriteSetting ( const QString & name , const QVariant & value ) {
qt_config - > setValue ( name , value ) ;
}
@ -1295,17 +1301,6 @@ void Config::WriteSetting(const QString& name, const QVariant& value,
qt_config - > setValue ( name , value ) ;
}
void Config : : WriteSetting ( const QString & name , const QVariant & value , const QVariant & default_value ,
bool use_global ) {
if ( ! global ) {
qt_config - > setValue ( name + QStringLiteral ( " /use_global " ) , use_global ) ;
}
if ( global | | ! use_global ) {
qt_config - > setValue ( name + QStringLiteral ( " /default " ) , value = = default_value ) ;
qt_config - > setValue ( name , value ) ;
}
}
void Config : : Reload ( ) {
ReadValues ( ) ;
// To apply default value changes