47 m_CustomToolbars( false ),
48 m_appSettingsSchemaVersion( aSchemaVersion )
97 "design_block_chooser.lib_tree.column_widths",
98 [&]() -> nlohmann::json
100 nlohmann::json ret = {};
103 ret[std::string(
name.ToUTF8() )] = width;
107 [&](
const nlohmann::json& aJson )
109 if( !aJson.is_object() )
114 for(
const auto& entry : aJson.items() )
116 if( !entry.value().is_number_integer() )
119 m_DesignBlockChooserPanel.tree.column_widths[entry.key()] = entry.value().get<int>();
136 [&]() -> nlohmann::json
138 nlohmann::json ret = {};
141 ret[std::string( pair.first.ToUTF8() )] = pair.second;
145 [&](
const nlohmann::json& aJson )
147 if( !aJson.is_object() )
152 for(
const auto& entry : aJson.items() )
154 if( !entry.value().is_number_integer() )
165 m_params.emplace_back(
new PARAM<bool>(
"printing.background",
166 &m_Printing.background,
false ) );
168 m_params.emplace_back(
new PARAM<bool>(
"printing.monochrome",
169 &m_Printing.monochrome,
true ) );
172 &m_Printing.scale, 1.0 ) );
174 m_params.emplace_back(
new PARAM<bool>(
"printing.use_theme",
175 &m_Printing.use_theme,
false ) );
178 &m_Printing.color_theme, wxS(
"" ) ) );
180 m_params.emplace_back(
new PARAM<bool>(
"printing.title_block",
181 &m_Printing.title_block,
false ) );
184 &m_Printing.layers, {} ) );
186 m_params.emplace_back(
new PARAM<int>(
"search_pane.selection_zoom",
187 reinterpret_cast<int*
>( &m_SearchPane.selection_zoom ),
188 static_cast<int>( SEARCH_PANE::SELECTION_ZOOM::PAN ) ) );
190 m_params.emplace_back(
new PARAM<bool>(
"search_pane.search_hidden_fields",
191 &m_SearchPane.search_hidden_fields,
true ) );
193 m_params.emplace_back(
new PARAM<bool>(
"search_pane.search_metadata",
194 &m_SearchPane.search_metadata,
false ) );
196 m_params.emplace_back(
new PARAM<bool>(
"system.first_run_shown",
197 &m_System.first_run_shown,
false ) );
199 m_params.emplace_back(
new PARAM<int>(
"system.max_undo_items",
200 &m_System.max_undo_items, 0 ) );
203 &m_System.file_history, {} ) );
205 if( m_filename == wxS(
"pl_editor" )
206 || ( m_filename == wxS(
"eeschema" ) || m_filename == wxS(
"symbol_editor" ) ) )
208 m_params.emplace_back(
new PARAM<int>(
"system.units",
213 m_params.emplace_back(
new PARAM<int>(
"system.units",
217 m_params.emplace_back(
new PARAM<int>(
"system.last_metric_units",
218 &m_System.last_metric_units,
static_cast<int>(
EDA_UNITS::MM ) ) );
220 m_params.emplace_back(
new PARAM<int>(
"system.last_imperial_units",
221 &m_System.last_imperial_units,
static_cast<int>(
EDA_UNITS::MILS ) ) );
223 m_params.emplace_back(
new PARAM<bool>(
"system.show_import_issues",
224 &m_System.show_import_issues,
true ) );
227 [&]() -> nlohmann::json
229 nlohmann::json js = nlohmann::json::array();
231 for(
const auto& [identifier, visible] : m_Plugins.actions )
232 js.push_back( nlohmann::json( { { identifier.ToUTF8(), visible } } ) );
236 [&](
const nlohmann::json& aObj )
238 m_Plugins.actions.clear();
240 if( !aObj.is_array() )
245 for(
const auto& entry : aObj )
247 if( entry.empty() || !entry.is_object() )
250 for(
const auto& pair : entry.items() )
252 m_Plugins.actions.emplace_back( std::make_pair(
253 wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) );
257 nlohmann::json::array() ) );
262 m_params.emplace_back(
new PARAM<bool>(
"appearance.custom_toolbars",
263 &m_CustomToolbars,
false ) );
265 addParamsForWindow( &m_Window,
"window" );
267 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.on_selection",
268 &m_CrossProbing.on_selection,
true ) );
270 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.center_on_items",
271 &m_CrossProbing.center_on_items,
true ) );
273 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.zoom_to_fit",
274 &m_CrossProbing.zoom_to_fit,
true ) );
276 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.auto_highlight",
277 &m_CrossProbing.auto_highlight,
true ) );
287 ret &=
fromLegacyString( aCfg,
"LastFindString",
"find_replace.find_string" );
288 ret &=
fromLegacyString( aCfg,
"LastReplaceString",
"find_replace.replace_string" );
292 ret &= fromLegacy<int>( aCfg,
"P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth",
293 "lib_tree.column_width" );
295 ret &= fromLegacy<bool>( aCfg,
"PrintMonochrome",
"printing.monochrome" );
296 ret &= fromLegacy<double>( aCfg,
"PrintScale",
"printing.scale" );
297 ret &= fromLegacy<bool>( aCfg,
"PrintPageFrame",
"printing.title_block" );
300 nlohmann::json js = nlohmann::json::array();
306 key.Printf( wxT(
"PlotLayer_%d" ), i );
308 if( aCfg->Read( key, &val ) && val )
312 Set(
"printing.layers", js );
315 ret &= fromLegacy<bool>( aCfg, f +
"FirstRunShown",
"system.first_run_shown" );
316 ret &= fromLegacy<int>( aCfg, f +
"DevelMaxUndoItems",
"system.max_undo_items" );
317 ret &= fromLegacy<int>( aCfg, f +
"Units",
"system.units" );
322 nlohmann::json js = nlohmann::json::array();
324 for(
int i = 1; i <= max_history_size; i++ )
326 key.Printf(
"file%d", i );
327 file = aCfg->Read( key, wxEmptyString );
329 if( !file.IsEmpty() )
330 js.push_back( file.ToStdString() );
333 Set(
"system.file_history", js );
344 const int find_replace_history_size = 10;
345 nlohmann::json find_history = nlohmann::json::array();
346 nlohmann::json replace_history = nlohmann::json::array();
347 wxString tmp, find_key, replace_key;
349 for(
int i = 0; i < find_replace_history_size; ++i )
351 find_key.Printf(
"FindStringHistoryList%d", i );
352 replace_key.Printf(
"ReplaceStringHistoryList%d", i );
354 if( aCfg->Read( find_key, &tmp ) )
355 find_history.push_back( tmp.ToStdString() );
357 if( aCfg->Read( replace_key, &tmp ) )
358 replace_history.push_back( tmp.ToStdString() );
361 Set(
"find_replace.find_history", find_history );
362 Set(
"find_replace.replace_history", replace_history );
367 const std::string& aJsonPath )
371 const std::string frameGDO = aFrame +
"GalDisplayOptions";
372 const std::string cursorPath = aJsonPath +
".cursor";
373 const std::string gridPath = aJsonPath +
".grid";
375 ret &= fromLegacy<bool>( aCfg, aFrame +
"Maximized", aJsonPath +
".maximized" );
376 ret &=
fromLegacyString( aCfg, aFrame +
"MostRecentlyUsedPath", aJsonPath +
".mru_path" );
377 ret &= fromLegacy<int>( aCfg, aFrame +
"Size_x", aJsonPath +
".size_x" );
378 ret &= fromLegacy<int>( aCfg, aFrame +
"Size_y", aJsonPath +
".size_y" );
379 ret &=
fromLegacyString( aCfg, aFrame +
"Perspective", aJsonPath +
".perspective" );
380 ret &= fromLegacy<int>( aCfg, aFrame +
"Pos_x", aJsonPath +
".pos_x" );
381 ret &= fromLegacy<int>( aCfg, aFrame +
"Pos_y", aJsonPath +
".pos_y" );
383 ret &= fromLegacy<bool>( aCfg, frameGDO +
"ForceDisplayCursor",
384 cursorPath +
".always_show_cursor" );
385 ret &= fromLegacy<bool>( aCfg, frameGDO +
"CursorFullscreen",
386 cursorPath +
".fullscreen_cursor" );
388 ret &= fromLegacy<int>( aCfg, aFrame +
"_LastGridSize", gridPath +
".last_size" );
390 ret &= fromLegacy<int>( aCfg, aFrame +
"FastGrid1", gridPath +
".fast_grid_1" );
391 ret &= fromLegacy<int>( aCfg, aFrame +
"FastGrid2", gridPath +
".fast_grid_2" );
393 ret &= fromLegacy<bool>( aCfg, frameGDO +
"GridAxesEnabled", gridPath +
".axes_enabled" );
394 ret &= fromLegacy<double>( aCfg, frameGDO +
"GridLineWidth", gridPath +
".line_width" );
395 ret &= fromLegacy<double>( aCfg, frameGDO +
"GridMaxDensity", gridPath +
".min_spacing" );
396 ret &= fromLegacy<bool>( aCfg, frameGDO +
"ShowGrid", gridPath +
".show" );
397 ret &= fromLegacy<int>( aCfg, frameGDO +
"GridStyle", gridPath +
".style" );
398 ret &=
fromLegacyColor( aCfg, frameGDO +
"GridColor", gridPath +
".color" );
405 int aDefaultWidth,
int aDefaultHeight )
571 return {
GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
572 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
573 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
574 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) } };
578 return {
GRID{ wxEmptyString, wxS(
"5.00 mm" ), wxS(
"5.00 mm" ) },
579 GRID{ wxEmptyString, wxS(
"2.50 mm" ), wxS(
"2.50 mm" ) },
580 GRID{ wxEmptyString, wxS(
"2.00 mm" ), wxS(
"2.00 mm" ) },
581 GRID{ wxEmptyString, wxS(
"1.00 mm" ), wxS(
"1.00 mm" ) },
582 GRID{ wxEmptyString, wxS(
"0.50 mm" ), wxS(
"0.50 mm" ) },
583 GRID{ wxEmptyString, wxS(
"0.25 mm" ), wxS(
"0.25 mm" ) },
584 GRID{ wxEmptyString, wxS(
"0.20 mm" ), wxS(
"0.20 mm" ) },
585 GRID{ wxEmptyString, wxS(
"0.10 mm" ), wxS(
"0.10 mm" ) } };
589 return {
GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
590 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
591 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
592 GRID{ wxEmptyString, wxS(
"20 mil" ), wxS(
"20 mil" ) },
593 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) },
594 GRID{ wxEmptyString, wxS(
"5 mil" ), wxS(
"5 mil" ) },
595 GRID{ wxEmptyString, wxS(
"2.5 mil" ), wxS(
"2.5 mil" ) },
596 GRID{ wxEmptyString, wxS(
"2 mil" ), wxS(
"2 mil" ) },
597 GRID{ wxEmptyString, wxS(
"1 mil" ), wxS(
"1 mil" ) },
598 GRID{ wxEmptyString, wxS(
"0.5 mil" ), wxS(
"0.5 mil" ) },
599 GRID{ wxEmptyString, wxS(
"0.2 mil" ), wxS(
"0.2 mil" ) },
600 GRID{ wxEmptyString, wxS(
"0.1 mil" ), wxS(
"0.1 mil" ) },
601 GRID{ wxEmptyString, wxS(
"5.0 mm" ), wxS(
"5.0 mm" ) },
602 GRID{ wxEmptyString, wxS(
"1.5 mm" ), wxS(
"2.5 mm" ) },
603 GRID{ wxEmptyString, wxS(
"1.0 mm" ), wxS(
"1.0 mm" ) },
604 GRID{ wxEmptyString, wxS(
"0.5 mm" ), wxS(
"0.5 mm" ) },
605 GRID{ wxEmptyString, wxS(
"0.25 mm" ), wxS(
"0.25 mm" ) },
606 GRID{ wxEmptyString, wxS(
"0.2 mm" ), wxS(
"0.2 mm" ) },
607 GRID{ wxEmptyString, wxS(
"0.1 mm" ), wxS(
"0.1 mm" ) },
608 GRID{ wxEmptyString, wxS(
"0.05 mm" ), wxS(
"0.0 mm" ) },
609 GRID{ wxEmptyString, wxS(
"0.025 mm" ), wxS(
"0.0 mm" ) },
610 GRID{ wxEmptyString, wxS(
"0.01 mm" ), wxS(
"0.0 mm" ) } };
614 return {
GRID{ wxEmptyString, wxS(
"1000 mil" ), wxS(
"1000 mil" ) },
615 GRID{ wxEmptyString, wxS(
"500 mil" ), wxS(
"500 mil" ) },
616 GRID{ wxEmptyString, wxS(
"250 mil" ), wxS(
"250 mil" ) },
617 GRID{ wxEmptyString, wxS(
"200 mil" ), wxS(
"200 mil" ) },
618 GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
619 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
620 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
621 GRID{ wxEmptyString, wxS(
"20 mil" ), wxS(
"20 mil" ) },
622 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) },
623 GRID{ wxEmptyString, wxS(
"5 mil" ), wxS(
"5 mil" ) },
624 GRID{ wxEmptyString, wxS(
"2 mil" ), wxS(
"2 mil" ) },
625 GRID{ wxEmptyString, wxS(
"1 mil" ), wxS(
"1 mil" ) },
626 GRID{ wxEmptyString, wxS(
"5.0 mm" ), wxS(
"5.0 mm" ) },
627 GRID{ wxEmptyString, wxS(
"2.5 mm" ), wxS(
"2.5 mm" ) },
628 GRID{ wxEmptyString, wxS(
"1.0 mm" ), wxS(
"1.0 mm" ) },
629 GRID{ wxEmptyString, wxS(
"0.5 mm" ), wxS(
"0.5 mm" ) },
630 GRID{ wxEmptyString, wxS(
"0.25 mm" ), wxS(
"0.25 mm" ) },
631 GRID{ wxEmptyString, wxS(
"0.2 mm" ), wxS(
"0.2 mm" ) },
632 GRID{ wxEmptyString, wxS(
"0.1 mm" ), wxS(
"0.1 mm" ) },
633 GRID{ wxEmptyString, wxS(
"0.05 mm" ), wxS(
"0.05 mm" ) },
634 GRID{ wxEmptyString, wxS(
"0.025 mm" ), wxS(
"0.025 mm" ) },
635 GRID{ wxEmptyString, wxS(
"0.01 mm" ), wxS(
"0.01 mm" ) } };
644 if( std::optional<int> optWidth = Get<int>(
"lib_tree.column_width" ) )
647 At(
"lib_tree" ).erase(
"column_width" );
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
APP_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
FIND_REPLACE m_FindReplace
bool migrateWindowConfig(wxConfigBase *aCfg, const std::string &aFrameName, const std::string &aJsonPath)
Migrate legacy window settings into the JSON document.
const std::vector< GRID > DefaultGridSizeList() const
void migrateFindReplace(wxConfigBase *aCfg)
! Migrates the find/replace history string list.s
PANEL_DESIGN_BLOCK_CHOOSER m_DesignBlockChooserPanel
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath, int aDefaultWidth=0, int aDefaultHeight=0)
Add parameters for the given window object.
const std::vector< double > DefaultZoomList() const
COLOR_PICKER m_ColorPicker
virtual std::string getLegacyFrameName() const
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
bool migrateLibTreeWidth()
Migrate the library tree width setting from a single column (Item) to multi-column.
static const wxString COLOR_BUILTIN_DEFAULT
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
void Set(const std::string &aPath, ValueType aVal)
Stores a value into the JSON document Will throw an exception if ValueType isn't something that the l...
wxString m_filename
The filename (not including path) of this settings file (inicode)
bool fromLegacyColor(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy COLOR4D stored in a wxConfig string to a given JSON pointer value.
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
nlohmann::json & At(const std::string &aPath)
Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these function...
Like a normal param, but with custom getter and setter functions.
virtual COMMON_SETTINGS * GetCommonSettings() const
template KICOMMON_API void JSON_SETTINGS::Set< nlohmann::json >(const std::string &aPath, nlohmann::json aValue)
@ USER
The main config directory (e.g. ~/.config/kicad/)
PGM_BASE & Pgm()
The global program "get" accessor.
std::vector< wxString > replace_history
std::vector< wxString > find_history
float highlight_factor
How much to brighten highlighted objects by.
float select_factor
How much to brighten selected objects by.
std::vector< wxString > columns
Ordered list of visible columns in the tree.
std::map< wxString, int > column_widths
Column widths, keyed by header name.
std::vector< wxString > open_libs
list of libraries the user has open in the tree.
int override_connected_idx
std::vector< GRID > grids
int override_graphics_idx
Common grid settings, available to every frame.
Store the common settings that are saved and loaded for each window / frame.
std::vector< double > zoom_factors
#define ZOOM_LIST_PL_EDITOR
#define ZOOM_LIST_PCBNEW_HYPER
#define ZOOM_LIST_EESCHEMA
#define ZOOM_LIST_GERBVIEW