Support system-installed color themes

Install to ${KICAD_DATA}/colors/

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15920
This commit is contained in:
Jon Evans 2023-10-31 23:05:08 -04:00
parent 9271fde71d
commit c6c808a7fa
1 changed files with 14 additions and 9 deletions

View File

@ -341,8 +341,14 @@ void SETTINGS_MANAGER::loadAllColorSettings()
third_party_path.AppendDir( wxS( "colors" ) );
// PCM-managed themes
wxDir third_party_colors_dir( third_party_path.GetFullPath() );
wxString color_settings_path = GetColorSettingsPath();
// System-installed themes
wxDir system_colors_dir( PATHS::GetStockDataPath( false ) + "/colors" );
// User-created themes
wxDir colors_dir( GetColorSettingsPath() );
// Search for and load any other settings
JSON_DIR_TRAVERSER loader( [&]( const wxFileName& aFilename )
@ -350,23 +356,22 @@ void SETTINGS_MANAGER::loadAllColorSettings()
registerColorSettings( aFilename.GetName() );
} );
JSON_DIR_TRAVERSER thirdPartyLoader(
JSON_DIR_TRAVERSER readOnlyLoader(
[&]( const wxFileName& aFilename )
{
COLOR_SETTINGS* settings = registerColorSettings( aFilename.GetFullPath(), true );
settings->SetReadOnly( true );
} );
wxDir colors_dir( color_settings_path );
if( system_colors_dir.IsOpened() )
system_colors_dir.Traverse( readOnlyLoader );
if( third_party_colors_dir.IsOpened() )
third_party_colors_dir.Traverse( readOnlyLoader );
if( colors_dir.IsOpened() )
{
if( third_party_colors_dir.IsOpened() )
third_party_colors_dir.Traverse( thirdPartyLoader );
colors_dir.Traverse( loader );
}
}
void SETTINGS_MANAGER::ReloadColorSettings()