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::ADVANCED_CFG ( )
private

Definition at line 139 of file advanced_config.cpp.

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

References AdvancedConfigMask, loadFromConfigFile(), m_allowLegacyCanvasInGtk3, and m_enableSvgImport.

Member Function Documentation

◆ AllowLegacyCanvas()

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 192 of file advanced_config.cpp.

193 {
194  // default is to allow
195  bool allow = true;
196 
197  // on GTK3, check the config
198 #ifdef __WXGTK3__
200 #endif
201 
202  return allow;
203 }
bool m_allowLegacyCanvasInGtk3

References m_allowLegacyCanvasInGtk3.

◆ GetCfg()

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 152 of file advanced_config.cpp.

153 {
154  static ADVANCED_CFG instance;
155  return instance;
156 }
Class containing "advanced" configuration options.

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

◆ loadFromConfigFile()

void ADVANCED_CFG::loadFromConfigFile ( )
private

Load the config from the normal config file.

Definition at line 159 of file advanced_config.cpp.

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

References AdvancedConfigMask, getAdvancedCfgFilename(), and loadSettings().

Referenced by ADVANCED_CFG().

◆ loadSettings()

void ADVANCED_CFG::loadSettings ( wxConfigBase &  aCfg)
private

Definition at line 176 of file advanced_config.cpp.

177 {
178  PARAM_CFG_ARRAY configParams;
179 
180  configParams.push_back(
182 
183  configParams.push_back( new PARAM_CFG_BOOL(
185 
186  wxConfigLoadSetups( &aCfg, configParams );
187 
188  dumpCfg( configParams );
189 }
A list of parameters type.
bool m_allowLegacyCanvasInGtk3
static const wxChar AllowLegacyCanvasInGtk3[]
Allow legacy canvas to be shown in GTK3.
static const wxChar EnableSvgImport[]
SVG needs some enhancements.
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.

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

Referenced by loadFromConfigFile().

Member Data Documentation

◆ m_allowLegacyCanvasInGtk3

bool ADVANCED_CFG::m_allowLegacyCanvasInGtk3
private

Definition at line 89 of file advanced_config.h.

Referenced by ADVANCED_CFG(), AllowLegacyCanvas(), and loadSettings().

◆ m_enableSvgImport

bool ADVANCED_CFG::m_enableSvgImport

Enable SVG import.

Definition at line 74 of file advanced_config.h.

Referenced by ADVANCED_CFG(), and loadSettings().


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