Use constants for the names of the built-in colors
- Avoid repetition and errors from typos
- Allow simple changes
- Simpler data type handling, the constants are wxString
(Cherry-picked from f135881bd6
in 7.0)
This commit is contained in:
parent
5735a57504
commit
13de3c0656
|
@ -25,6 +25,7 @@
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <settings/app_settings.h>
|
#include <settings/app_settings.h>
|
||||||
#include <settings/json_settings_internals.h>
|
#include <settings/json_settings_internals.h>
|
||||||
|
#include <settings/color_settings.h>
|
||||||
#include <settings/common_settings.h>
|
#include <settings/common_settings.h>
|
||||||
#include <settings/parameters.h>
|
#include <settings/parameters.h>
|
||||||
|
|
||||||
|
@ -147,7 +148,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV
|
||||||
&m_System.last_imperial_units, static_cast<int>( EDA_UNITS::INCHES ) ) );
|
&m_System.last_imperial_units, static_cast<int>( EDA_UNITS::INCHES ) ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<wxString>( "appearance.color_theme",
|
m_params.emplace_back( new PARAM<wxString>( "appearance.color_theme",
|
||||||
&m_ColorTheme, wxS( "_builtin_default" ) ) );
|
&m_ColorTheme, COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT ) );
|
||||||
|
|
||||||
addParamsForWindow( &m_Window, "window" );
|
addParamsForWindow( &m_Window, "window" );
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
///! Update the schema version whenever a migration is required
|
///! Update the schema version whenever a migration is required
|
||||||
const int colorsSchemaVersion = 5;
|
const int colorsSchemaVersion = 5;
|
||||||
|
const wxString COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT = "_builtin_default";
|
||||||
|
const wxString COLOR_SETTINGS::COLOR_BUILTIN_CLASSIC = "_builtin_classic";
|
||||||
|
|
||||||
|
|
||||||
COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath ) :
|
COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath ) :
|
||||||
|
@ -380,12 +382,12 @@ void COLOR_SETTINGS::SetColor( int aLayer, const COLOR4D& aColor )
|
||||||
|
|
||||||
std::vector<COLOR_SETTINGS*> COLOR_SETTINGS::CreateBuiltinColorSettings()
|
std::vector<COLOR_SETTINGS*> COLOR_SETTINGS::CreateBuiltinColorSettings()
|
||||||
{
|
{
|
||||||
COLOR_SETTINGS* defaultTheme = new COLOR_SETTINGS( wxT( "_builtin_default" ) );
|
COLOR_SETTINGS* defaultTheme = new COLOR_SETTINGS( COLOR_BUILTIN_DEFAULT );
|
||||||
defaultTheme->SetName( _( "KiCad Default" ) );
|
defaultTheme->SetName( _( "KiCad Default" ) );
|
||||||
defaultTheme->m_writeFile = false;
|
defaultTheme->m_writeFile = false;
|
||||||
defaultTheme->Load(); // We can just get the colors out of the param defaults for this one
|
defaultTheme->Load(); // We can just get the colors out of the param defaults for this one
|
||||||
|
|
||||||
COLOR_SETTINGS* classicTheme = new COLOR_SETTINGS( wxT( "_builtin_classic" ) );
|
COLOR_SETTINGS* classicTheme = new COLOR_SETTINGS( COLOR_BUILTIN_CLASSIC );
|
||||||
classicTheme->SetName( _( "KiCad Classic" ) );
|
classicTheme->SetName( _( "KiCad Classic" ) );
|
||||||
classicTheme->m_writeFile = false;
|
classicTheme->m_writeFile = false;
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ COLOR_SETTINGS* SETTINGS_MANAGER::GetColorSettings( const wxString& aName )
|
||||||
if( !ret )
|
if( !ret )
|
||||||
{
|
{
|
||||||
ret = registerColorSettings( aName );
|
ret = registerColorSettings( aName );
|
||||||
*ret = *m_color_settings.at( "_builtin_default" );
|
*ret = *m_color_settings.at( COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT );
|
||||||
ret->SetFilename( wxT( "user" ) );
|
ret->SetFilename( wxT( "user" ) );
|
||||||
ret->SetReadOnly( false );
|
ret->SetReadOnly( false );
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ COLOR_SETTINGS* SETTINGS_MANAGER::GetColorSettings( const wxString& aName )
|
||||||
}
|
}
|
||||||
|
|
||||||
// This had better work
|
// This had better work
|
||||||
return m_color_settings.at( "_builtin_default" );
|
return m_color_settings.at( COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,10 @@ COLOR_SETTINGS* DIALOG_PLOT_SCHEMATIC::getColorSettings()
|
||||||
int selection = m_colorTheme->GetSelection();
|
int selection = m_colorTheme->GetSelection();
|
||||||
|
|
||||||
if( selection < 0 )
|
if( selection < 0 )
|
||||||
return m_parent->GetSettingsManager()->GetColorSettings( "_builtin_default" );
|
{
|
||||||
|
return m_parent->GetSettingsManager()->GetColorSettings(
|
||||||
|
COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT );
|
||||||
|
}
|
||||||
|
|
||||||
return static_cast<COLOR_SETTINGS*>( m_colorTheme->GetClientData( selection ) );
|
return static_cast<COLOR_SETTINGS*>( m_colorTheme->GetClientData( selection ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,10 @@ public:
|
||||||
*/
|
*/
|
||||||
static std::vector<COLOR_SETTINGS*> CreateBuiltinColorSettings();
|
static std::vector<COLOR_SETTINGS*> CreateBuiltinColorSettings();
|
||||||
|
|
||||||
|
// Names for the built-in color settings
|
||||||
|
static const wxString COLOR_BUILTIN_DEFAULT;
|
||||||
|
static const wxString COLOR_BUILTIN_CLASSIC;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool migrateSchema0to1();
|
bool migrateSchema0to1();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue