diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp index 02804880eb..209c029556 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp @@ -198,6 +198,8 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() &m_Camera.rotation_increment, 10.0 ) ); m_params.emplace_back( new PARAM( "camera.projection_mode", &m_Camera.projection_mode, 1 ) ); + + m_params.emplace_back( new PARAM_OBSOLETE( "colors" ) ); } diff --git a/common/settings/json_settings.cpp b/common/settings/json_settings.cpp index 2966de4808..6b7c1967a4 100644 --- a/common/settings/json_settings.cpp +++ b/common/settings/json_settings.cpp @@ -369,18 +369,6 @@ void JSON_SETTINGS::ResetToDefaults() } -bool JSON_SETTINGS::IsDefault( const std::string& aParamName ) -{ - for( const PARAM_BASE* param : m_params ) - { - if( param->GetJsonPath() == aParamName ) - return param->IsDefault(); - } - - return false; -} - - bool JSON_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce ) { if( !m_writeFile ) diff --git a/common/settings/parameters.cpp b/common/settings/parameters.cpp index c00c02967f..0a31441fcd 100644 --- a/common/settings/parameters.cpp +++ b/common/settings/parameters.cpp @@ -25,6 +25,13 @@ #include #include #include +#include + + +void PARAM_OBSOLETE::Store( JSON_SETTINGS* aSettings ) const +{ + aSettings->Internals()->erase( m_path ); +} template diff --git a/include/settings/color_settings.h b/include/settings/color_settings.h index afdbe5ab44..966ad2055d 100644 --- a/include/settings/color_settings.h +++ b/include/settings/color_settings.h @@ -151,11 +151,6 @@ public: ( *m_map )[ m_key ] = m_default; } - bool IsDefault() const override - { - return ( *m_map )[ m_key ] == m_default; - } - bool MatchesFile( JSON_SETTINGS* aSettings ) const override { if( OPT optval = aSettings->Get( m_path ) ) diff --git a/include/settings/json_settings.h b/include/settings/json_settings.h index d06a71d14a..0118810058 100644 --- a/include/settings/json_settings.h +++ b/include/settings/json_settings.h @@ -61,7 +61,8 @@ public: friend class NESTED_SETTINGS; JSON_SETTINGS( const wxString& aFilename, SETTINGS_LOC aLocation, int aSchemaVersion ) : - JSON_SETTINGS( aFilename, aLocation, aSchemaVersion, true, true, true ) {} + JSON_SETTINGS( aFilename, aLocation, aSchemaVersion, true, true, true ) + {} JSON_SETTINGS( const wxString& aFilename, SETTINGS_LOC aLocation, int aSchemaVersion, bool aCreateIfMissing, bool aCreateIfDefault, bool aWriteFile ); @@ -123,13 +124,6 @@ c * @return true if the file was saved */ void ResetToDefaults(); - /** - * Checks if the current state of a parameter matches its default value - * @param aParamName is the JSON path to the parameter - * @return true if the given parameter is at its default value - */ - bool IsDefault( const std::string& aParamName ); - /** * Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the * form "key1.key2.key3" to refer to nested objects. diff --git a/include/settings/parameters.h b/include/settings/parameters.h index 7e8f163027..9e540031fb 100644 --- a/include/settings/parameters.h +++ b/include/settings/parameters.h @@ -54,12 +54,6 @@ public: virtual void SetDefault() = 0; - /** - * Checks whether or not this param has been changed from its default value - * @return true if the parameter in memory matches its default value - */ - virtual bool IsDefault() const = 0; - /** * Checks whether the parameter in memory matches the one in a given JSON file * @param aSettings is a JSON_SETTINGS to check the JSON file contents of @@ -144,11 +138,6 @@ public: *m_ptr = m_default; } - bool IsDefault() const override - { - return *m_ptr == m_default; - } - bool MatchesFile( JSON_SETTINGS* aSettings ) const override { if( OPT optval = aSettings->Get( m_path ) ) @@ -167,6 +156,30 @@ protected: ValueType m_default; }; +/** + * Handles an obsolete parameter (ie: removes it on write). + */ +class PARAM_OBSOLETE : public PARAM_BASE +{ +public: + PARAM_OBSOLETE( const std::string& aJsonPath ) : + PARAM_BASE( aJsonPath, false ) + { } + + void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override + { } + + void Store( JSON_SETTINGS* aSettings ) const override; + + void SetDefault() override + { } + + bool MatchesFile( JSON_SETTINGS* aSettings ) const override + { + return !aSettings->Contains( m_path ); + } +}; + /** * Stores a path as a string with directory separators normalized to unix-style */ @@ -268,11 +281,6 @@ public: *m_ptr = m_default; } - bool IsDefault() const override - { - return *m_ptr == m_default; - } - bool MatchesFile( JSON_SETTINGS* aSettings ) const override { if( OPT val = aSettings->Get( m_path ) ) @@ -328,11 +336,6 @@ public: m_setter( m_default ); } - bool IsDefault() const override - { - return m_getter() == m_default; - } - bool MatchesFile( JSON_SETTINGS* aSettings ) const override; private: @@ -414,11 +417,6 @@ public: *m_ptr = m_default; } - bool IsDefault() const override - { - return *m_ptr == m_default; - } - bool MatchesFile( JSON_SETTINGS* aSettings ) const override { if( OPT optval = aSettings->Get( m_path ) ) @@ -463,11 +461,6 @@ public: *m_ptr = m_default; } - bool IsDefault() const override - { - return *m_ptr == m_default; - } - bool MatchesFile( JSON_SETTINGS* aSettings ) const override; protected: @@ -559,11 +552,6 @@ public: *m_ptr = m_default; } - bool IsDefault() const override - { - return *m_ptr == m_default; - } - bool MatchesFile( JSON_SETTINGS* aSettings ) const override; private: @@ -596,11 +584,6 @@ public: *m_ptr = m_default; } - bool IsDefault() const override - { - return *m_ptr == m_default; - } - bool MatchesFile( JSON_SETTINGS* aSettings ) const override; private: