KiCad PCB EDA Suite
ADVANCED_CFG Class Reference

Class containing "advanced" configuration options. More...

#include <advanced_config.h>

Public Member Functions

bool AllowLegacyCanvas () const
 Helper to determine if legacy canvas is allowed (according to platform and config) More...
 

Static Public Member Functions

static const ADVANCED_CFGGetCfg ()
 Get the singleton instance's config, which is shared by all consumers of advanced config. More...
 

Public Attributes

bool m_enableSvgImport
 Enable SVG import. More...
 

Private Member Functions

 ADVANCED_CFG ()
 
void loadFromConfigFile ()
 Load the config from the normal config file. More...
 
void loadSettings (wxConfigBase &aCfg)
 

Private Attributes

bool m_allowLegacyCanvasInGtk3
 

Detailed Description

Class containing "advanced" configuration options.

Options set here are for developer or advanced users only. If a general user needs to set one of these for normal KiCad use, either:

  • They are working around some bug that should be fixed, or
  • The parameter they are setting is of general interest and should be in the main application config, with UI provided.

Options in this class are, in general, preferable to #defines, as they allow more flexible configuration by developers, and don't hide code from the compiler on other configurations, which can result in broken builds.

Never use advanced configs in an untestable way. If a function depends on advanced config such that you cannot test it without changing the config, "lift" the config to a higher level and make pass it as parameter of the code under test. The tests can pass their own values as needed.

This also applies to code that does not depend on "common" - it cannot use this class, so you must pass configuration in as proper parameters.

Sometimes you can just use values directly, and sometimes helper functions might be provided to allow extra logic (for example when a advanced config applies only on certain platforms).

For more information on what config keys set these parameters in the config files, and why you might want to set them, see AC_KEYS

Definition at line 58 of file advanced_config.h.

Constructor & Destructor Documentation

ADVANCED_CFG::ADVANCED_CFG ( )
private

Definition at line 142 of file advanced_config.cpp.

References AdvancedConfigMask.

143 {
144  wxLogTrace( AdvancedConfigMask, "Init advanced config" );
145 
146  // Init defaults - this is done in case the config doesn't exist,
147  // then the values will remain as set here.
148  m_enableSvgImport = false;
150 
152 }
bool m_allowLegacyCanvasInGtk3
void loadFromConfigFile()
Load the config from the normal config file.
bool m_enableSvgImport
Enable SVG import.
static const wxChar AdvancedConfigMask[]

Member Function Documentation

bool ADVANCED_CFG::AllowLegacyCanvas ( ) const

Helper to determine if legacy canvas is allowed (according to platform and config)

Returns
true if legacy canvas should be shown

Definition at line 195 of file advanced_config.cpp.

196 {
197  // default is to allow
198  bool allow = true;
199 
200  // on GTK3, check the config
201 #ifdef __WXGTK3__
203 #endif
204 
205  return allow;
206 }
bool m_allowLegacyCanvasInGtk3
const ADVANCED_CFG & ADVANCED_CFG::GetCfg ( )
static

Get the singleton instance's config, which is shared by all consumers of advanced config.

This configuration is read-only - to set options, users should add the parameters to their config files at ~/.config/kicad/advanced, or the platform equivalent.

Definition at line 155 of file advanced_config.cpp.

Referenced by DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX(), EDA_DRAW_FRAME::LoadCanvasTypeSetting(), preparePreferencesMenu(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), and GERBVIEW_FRAME::ReCreateMenuBar().

156 {
157  static ADVANCED_CFG instance;
158  return instance;
159 }
Class containing "advanced" configuration options.
void ADVANCED_CFG::loadFromConfigFile ( )
private

Load the config from the normal config file.

Definition at line 162 of file advanced_config.cpp.

References AdvancedConfigMask, and getAdvancedCfgFilename().

163 {
164  const auto k_advanced = getAdvancedCfgFilename();
165 
166  if( !k_advanced.FileExists() )
167  {
168  wxLogTrace( AdvancedConfigMask, "File does not exist %s", k_advanced.GetFullPath() );
169  return;
170  }
171 
172  wxLogTrace( AdvancedConfigMask, "Loading advanced config from: %s", k_advanced.GetFullPath() );
173 
174  wxFileConfig file_cfg( "", "", k_advanced.GetFullPath() );
175  loadSettings( file_cfg );
176 }
void loadSettings(wxConfigBase &aCfg)
static wxFileName getAdvancedCfgFilename()
Get the filename for the advanced config file.
static const wxChar AdvancedConfigMask[]
void ADVANCED_CFG::loadSettings ( wxConfigBase &  aCfg)
private

Definition at line 179 of file advanced_config.cpp.

References AC_KEYS::AllowLegacyCanvasInGtk3, dumpCfg(), AC_KEYS::EnableSvgImport, and wxConfigLoadSetups().

180 {
181  PARAM_CFG_ARRAY configParams;
182 
183  configParams.push_back(
185 
186  configParams.push_back( new PARAM_CFG_BOOL(
188 
189  wxConfigLoadSetups( &aCfg, configParams );
190 
191  dumpCfg( configParams );
192 }
A list of parameters type.
bool m_allowLegacyCanvasInGtk3
static const wxChar AllowLegacyCanvasInGtk3[]
Allow legacy canvas to be shown in GTK3.
static const wxChar EnableSvgImport[]
Currently (Version 5.1) SVG import is disabled by default, to avoid issues SVG needs some enhancement...
Configuration parameter - Boolean Class.
static void dumpCfg(const PARAM_CFG_ARRAY &aArray)
Dump the configs in the given array to trace.
void wxConfigLoadSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigLoadSetups uses aList of PARAM_CFG_ARRAY elements to load configuration values from ...
bool m_enableSvgImport
Enable SVG import.

Member Data Documentation

bool ADVANCED_CFG::m_allowLegacyCanvasInGtk3
private

Definition at line 89 of file advanced_config.h.

bool ADVANCED_CFG::m_enableSvgImport

Enable SVG import.

Definition at line 74 of file advanced_config.h.

Referenced by DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX().


The documentation for this class was generated from the following files: