diff --git a/common/settings/color_settings.cpp b/common/settings/color_settings.cpp index b3e89c8272..50a975a111 100644 --- a/common/settings/color_settings.cpp +++ b/common/settings/color_settings.cpp @@ -33,11 +33,13 @@ const int colorsSchemaVersion = 3; -COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename ) : +COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath ) : JSON_SETTINGS( std::move( aFilename ), SETTINGS_LOC::COLORS, colorsSchemaVersion ), m_overrideSchItemColors( false ), m_useBoardStackupColors( true ) { + if( aAbsolutePath ) + SetLocation( SETTINGS_LOC::NONE ); m_params.emplace_back( new PARAM( "meta.name", &m_displayName, "KiCad Default" ) ); diff --git a/common/settings/settings_manager.cpp b/common/settings/settings_manager.cpp index 684c19208a..6978b7a70f 100644 --- a/common/settings/settings_manager.cpp +++ b/common/settings/settings_manager.cpp @@ -249,11 +249,12 @@ public: }; -COLOR_SETTINGS* SETTINGS_MANAGER::registerColorSettings( const wxString& aName ) +COLOR_SETTINGS* SETTINGS_MANAGER::registerColorSettings( const wxString& aName, bool aAbsolutePath ) { if( !m_color_settings.count( aName ) ) { - COLOR_SETTINGS* colorSettings = RegisterSettings( new COLOR_SETTINGS( aName ) ); + COLOR_SETTINGS* colorSettings = RegisterSettings( new COLOR_SETTINGS( aName, + aAbsolutePath ) ); m_color_settings[aName] = colorSettings; } @@ -303,27 +304,25 @@ void SETTINGS_MANAGER::loadAllColorSettings() wxDir third_party_colors_dir( third_party_path.GetFullPath() ); wxString color_settings_path = GetColorSettingsPath(); - JSON_DIR_TRAVERSER copier( - [&]( const wxFileName& aFilename ) - { - wxFileName new_file( color_settings_path, aFilename.GetFullName() ); - - if( !new_file.Exists() ) - wxCopyFile( aFilename.GetFullPath(), new_file.GetFullPath()); - } ); - // Search for and load any other settings JSON_DIR_TRAVERSER loader( [&]( const wxFileName& aFilename ) { registerColorSettings( aFilename.GetName() ); } ); + JSON_DIR_TRAVERSER thirdPartyLoader( + [&]( const wxFileName& aFilename ) + { + COLOR_SETTINGS* settings = registerColorSettings( aFilename.GetFullPath(), true ); + settings->SetReadOnly( true ); + } ); + wxDir colors_dir( color_settings_path ); if( colors_dir.IsOpened() ) { if( third_party_colors_dir.IsOpened() ) - third_party_colors_dir.Traverse( copier ); + third_party_colors_dir.Traverse( thirdPartyLoader ); colors_dir.Traverse( loader ); } diff --git a/include/settings/color_settings.h b/include/settings/color_settings.h index 59f8120966..e098b7c354 100644 --- a/include/settings/color_settings.h +++ b/include/settings/color_settings.h @@ -58,7 +58,8 @@ public: */ std::vector m_Palette; - explicit COLOR_SETTINGS( const wxString& aFilename = wxT( "user" ) ); + explicit COLOR_SETTINGS( const wxString& aFilename = wxT( "user" ), + bool aAbsolutePath = false ); virtual ~COLOR_SETTINGS() {} diff --git a/include/settings/json_settings.h b/include/settings/json_settings.h index 0118810058..b3ea477b22 100644 --- a/include/settings/json_settings.h +++ b/include/settings/json_settings.h @@ -75,6 +75,7 @@ public: void SetFilename( const wxString& aFilename ) { m_filename = aFilename; } + void SetLocation( SETTINGS_LOC aLocation ) { m_location = aLocation; } SETTINGS_LOC GetLocation() const { return m_location; } void SetLegacyFilename( const wxString& aFilename ) { m_legacy_filename = aFilename; } diff --git a/include/settings/settings_manager.h b/include/settings/settings_manager.h index 0d96ca5b1a..b11ef412ee 100644 --- a/include/settings/settings_manager.h +++ b/include/settings/settings_manager.h @@ -390,7 +390,7 @@ private: */ COLOR_SETTINGS* loadColorSettingsByName( const wxString& aName ); - COLOR_SETTINGS* registerColorSettings( const wxString& aFilename ); + COLOR_SETTINGS* registerColorSettings( const wxString& aFilename, bool aAbsolutePath = false ); void loadAllColorSettings();