Refresh schematic's copy of template fieldnames after preferences.
Fixes https://gitlab.com/kicad/code/kicad/issues/13203
This commit is contained in:
parent
4de64b607a
commit
220c5a259b
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 2015-2022 KiCad Developers, see AUTHORS.TXT for contributors.
|
* Copyright (C) 2015-2023 KiCad Developers, see AUTHORS.TXT for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -135,7 +135,7 @@ void TEMPLATES::Format( OUTPUTFORMATTER* out, int nestLevel, bool aGlobal ) cons
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TEMPLATES::Parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal )
|
void TEMPLATES::parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal )
|
||||||
{
|
{
|
||||||
T tok;
|
T tok;
|
||||||
|
|
||||||
|
@ -229,6 +229,20 @@ void TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TEMPLATES::AddTemplateFieldNames( const wxString& aSerializedFieldNames )
|
||||||
|
{
|
||||||
|
TEMPLATE_FIELDNAMES_LEXER field_lexer( TO_UTF8( aSerializedFieldNames ) );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
parse( &field_lexer, true );
|
||||||
|
}
|
||||||
|
catch( const IO_ERROR& )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TEMPLATES::DeleteAllFieldNameTemplates( bool aGlobal )
|
void TEMPLATES::DeleteAllFieldNameTemplates( bool aGlobal )
|
||||||
{
|
{
|
||||||
if( aGlobal )
|
if( aGlobal )
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
|
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
|
||||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -50,24 +50,8 @@ PANEL_TEMPLATE_FIELDNAMES::PANEL_TEMPLATE_FIELDNAMES( wxWindow* aWindow,
|
||||||
|
|
||||||
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
||||||
|
|
||||||
if( cfg )
|
if( cfg && !cfg->m_Drawing.field_names.IsEmpty() )
|
||||||
{
|
m_templateMgr->AddTemplateFieldNames( cfg->m_Drawing.field_names );
|
||||||
// Read global fieldname templates
|
|
||||||
wxString templateFieldNames = cfg->m_Drawing.field_names;
|
|
||||||
|
|
||||||
if( !templateFieldNames.IsEmpty() )
|
|
||||||
{
|
|
||||||
TEMPLATE_FIELDNAMES_LEXER field_lexer( TO_UTF8( templateFieldNames ) );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_templateMgr->Parse( &field_lexer, true );
|
|
||||||
}
|
|
||||||
catch( const IO_ERROR& )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_addFieldButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
|
m_addFieldButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -1530,9 +1530,10 @@ void SCH_EDIT_FRAME::ShowAllIntersheetRefs( bool aShow )
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
||||||
{
|
{
|
||||||
|
SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
||||||
|
|
||||||
SCHEMATIC_SETTINGS& settings = Schematic().Settings();
|
SCHEMATIC_SETTINGS& settings = Schematic().Settings();
|
||||||
|
|
||||||
SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
|
||||||
settings.m_JunctionSize = GetSchematicJunctionSize();
|
settings.m_JunctionSize = GetSchematicJunctionSize();
|
||||||
|
|
||||||
ShowAllIntersheetRefs( settings.m_IntersheetRefsShow );
|
ShowAllIntersheetRefs( settings.m_IntersheetRefsShow );
|
||||||
|
@ -1546,6 +1547,11 @@ void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
|
||||||
view->SetLayerVisible( LAYER_ERC_WARN, cfg->m_Appearance.show_erc_warnings );
|
view->SetLayerVisible( LAYER_ERC_WARN, cfg->m_Appearance.show_erc_warnings );
|
||||||
view->SetLayerVisible( LAYER_ERC_EXCLUSION, cfg->m_Appearance.show_erc_exclusions );
|
view->SetLayerVisible( LAYER_ERC_EXCLUSION, cfg->m_Appearance.show_erc_exclusions );
|
||||||
|
|
||||||
|
settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
|
||||||
|
|
||||||
|
if( !cfg->m_Drawing.field_names.IsEmpty() )
|
||||||
|
settings.m_TemplateFieldNames.AddTemplateFieldNames( cfg->m_Drawing.field_names );
|
||||||
|
|
||||||
SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
|
SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
|
||||||
|
|
||||||
for( SCH_ITEM* item : screen->Items() )
|
for( SCH_ITEM* item : screen->Items() )
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 CERN
|
* Copyright (C) 2020 CERN
|
||||||
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
* @author Jon Evans <jon@craftyjon.com>
|
* @author Jon Evans <jon@craftyjon.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
@ -163,26 +163,11 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read global fieldname templates
|
||||||
auto* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
auto* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
||||||
|
|
||||||
if( cfg )
|
if( cfg && !cfg->m_Drawing.field_names.IsEmpty() )
|
||||||
{
|
m_TemplateFieldNames.AddTemplateFieldNames( cfg->m_Drawing.field_names );
|
||||||
// Read global fieldname templates
|
|
||||||
wxString templateFieldNames = cfg->m_Drawing.field_names;
|
|
||||||
|
|
||||||
if( !templateFieldNames.IsEmpty() )
|
|
||||||
{
|
|
||||||
TEMPLATE_FIELDNAMES_LEXER field_lexer( TO_UTF8( templateFieldNames ) );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_TemplateFieldNames.Parse( &field_lexer, true );
|
|
||||||
}
|
|
||||||
catch( const IO_ERROR& )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {} ) );
|
}, {} ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<wxString>( "page_layout_descr_file",
|
m_params.emplace_back( new PARAM<wxString>( "page_layout_descr_file",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.TXT for contributors.
|
* Copyright (C) 2014-2023 KiCad Developers, see AUTHORS.TXT for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -131,13 +131,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void Format( OUTPUTFORMATTER* out, int nestLevel, bool aGlobal ) const ;
|
void Format( OUTPUTFORMATTER* out, int nestLevel, bool aGlobal ) const ;
|
||||||
|
|
||||||
/**
|
|
||||||
* Fill this object from information in the input stream handled by
|
|
||||||
* #TEMPLATE_FIELDNAMES_LEXER.
|
|
||||||
*/
|
|
||||||
void Parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert or append a wanted symbol field name into the field names template.
|
* Insert or append a wanted symbol field name into the field names template.
|
||||||
*
|
*
|
||||||
|
@ -150,6 +143,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool aGlobal );
|
void AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool aGlobal );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a serialized list of template field names.
|
||||||
|
*/
|
||||||
|
void AddTemplateFieldNames( const wxString& aSerializedFieldNames );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the entire contents.
|
* Delete the entire contents.
|
||||||
*/
|
*/
|
||||||
|
@ -176,6 +174,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void resolveTemplates();
|
void resolveTemplates();
|
||||||
|
|
||||||
|
void parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TEMPLATE_FIELDNAMES m_globals;
|
TEMPLATE_FIELDNAMES m_globals;
|
||||||
TEMPLATE_FIELDNAMES m_project;
|
TEMPLATE_FIELDNAMES m_project;
|
||||||
|
|
Loading…
Reference in New Issue