Attempt to select PCM themes for cli by their display name

Fixes https://gitlab.com/kicad/code/kicad/-/issues/13648
This commit is contained in:
Marek Roszko 2023-01-28 17:07:06 -05:00
parent 68decdd4f2
commit 088cadfefc
1 changed files with 14 additions and 0 deletions

View File

@ -179,9 +179,23 @@ void SETTINGS_MANAGER::FlushAndRelease( JSON_SETTINGS* aSettings, bool aSave )
COLOR_SETTINGS* SETTINGS_MANAGER::GetColorSettings( const wxString& aName )
{
// Find settings the fast way
if( m_color_settings.count( aName ) )
return m_color_settings.at( aName );
// Maybe it's the display name (cli is one method of invoke)
auto it = std::find_if( m_color_settings.begin(), m_color_settings.end(),
[&aName]( const std::pair<wxString, COLOR_SETTINGS*>& p )
{
return p.second->GetName().Lower() == aName.Lower();
} );
if( it != m_color_settings.end() )
{
return it->second;
}
// No match? See if we can load it
if( !aName.empty() )
{
COLOR_SETTINGS* ret = loadColorSettingsByName( aName );