101 "design_block_chooser.lib_tree.column_widths",
102 [&]() -> nlohmann::json
104 nlohmann::json ret = {};
107 ret[std::string(
name.ToUTF8() )] = width;
111 [&](
const nlohmann::json& aJson )
113 if( !aJson.is_object() )
116 m_DesignBlockChooserPanel.tree.column_widths.clear();
118 for(
const auto& entry : aJson.items() )
120 if( !entry.value().is_number_integer() )
123 m_DesignBlockChooserPanel.tree.column_widths[entry.key()] = entry.value().get<
int>();
128 m_params.emplace_back(
new PARAM<float>(
"graphics.highlight_factor",
129 &m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) );
131 m_params.emplace_back(
new PARAM<float>(
"graphics.select_factor",
132 &m_Graphics.select_factor, 0.75f, 0.0, 1.0f ) );
134 m_params.emplace_back(
new PARAM<int>(
"color_picker.default_tab",
135 &m_ColorPicker.default_tab, 0 ) );
137 m_params.emplace_back(
new PARAM_LIST<wxString>(
"lib_tree.columns", &m_LibTree.columns, {} ) );
140 [&]() -> nlohmann::json
142 nlohmann::json ret = {};
144 for(
const std::pair<const wxString, int>& pair : m_LibTree.column_widths )
145 ret[std::string( pair.first.ToUTF8() )] = pair.second;
149 [&](
const nlohmann::json& aJson )
151 if( !aJson.is_object() )
154 m_LibTree.column_widths.clear();
156 for(
const auto& entry : aJson.items() )
158 if( !entry.value().is_number_integer() )
161 m_LibTree.column_widths[ entry.key() ] = entry.value().get<
int>();
166 m_params.emplace_back(
169 m_params.emplace_back(
new PARAM<bool>(
"printing.background",
170 &m_Printing.background,
false ) );
172 m_params.emplace_back(
new PARAM<bool>(
"printing.monochrome",
173 &m_Printing.monochrome,
true ) );
176 &m_Printing.scale, 1.0 ) );
178 m_params.emplace_back(
new PARAM<bool>(
"printing.use_theme",
179 &m_Printing.use_theme,
false ) );
182 &m_Printing.color_theme, wxS(
"" ) ) );
184 m_params.emplace_back(
new PARAM<bool>(
"printing.title_block",
185 &m_Printing.title_block,
false ) );
188 &m_Printing.layers, {} ) );
190 m_params.emplace_back(
new PARAM<int>(
"search_pane.selection_zoom",
191 reinterpret_cast<int*
>( &m_SearchPane.selection_zoom ),
192 static_cast<int>( SEARCH_PANE::SELECTION_ZOOM::PAN ) ) );
194 m_params.emplace_back(
new PARAM<bool>(
"search_pane.search_hidden_fields",
195 &m_SearchPane.search_hidden_fields,
true ) );
197 m_params.emplace_back(
new PARAM<bool>(
"search_pane.search_metadata",
198 &m_SearchPane.search_metadata,
false ) );
200 m_params.emplace_back(
new PARAM<bool>(
"system.first_run_shown",
201 &m_System.first_run_shown,
false ) );
203 m_params.emplace_back(
new PARAM<int>(
"system.max_undo_items",
204 &m_System.max_undo_items, 0 ) );
208 &m_System.file_history, {} ) );
210 if( m_filename == wxS(
"pl_editor" )
211 || ( m_filename == wxS(
"eeschema" ) || m_filename == wxS(
"symbol_editor" ) ) )
213 m_params.emplace_back(
new PARAM<int>(
"system.units",
218 m_params.emplace_back(
new PARAM<int>(
"system.units",
222 m_params.emplace_back(
new PARAM<int>(
"system.last_metric_units",
223 &m_System.last_metric_units,
static_cast<int>(
EDA_UNITS::MM ) ) );
225 m_params.emplace_back(
new PARAM<int>(
"system.last_imperial_units",
226 &m_System.last_imperial_units,
static_cast<int>(
EDA_UNITS::MILS ) ) );
228 m_params.emplace_back(
new PARAM<bool>(
"system.show_import_issues",
229 &m_System.show_import_issues,
true ) );
232 [&]() -> nlohmann::json
234 nlohmann::json js = nlohmann::json::array();
236 for( const auto& [identifier, visible] : m_Plugins.actions )
237 js.push_back( nlohmann::json( { { identifier.ToUTF8(), visible } } ) );
241 [&](
const nlohmann::json& aObj )
243 m_Plugins.actions.clear();
245 if( !aObj.is_array() )
250 for(
const auto& entry : aObj )
252 if( entry.empty() || !entry.is_object() )
255 for(
const auto& pair : entry.items() )
257 m_Plugins.actions.emplace_back( std::make_pair(
258 wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) );
262 nlohmann::json::array() ) );
267 m_params.emplace_back(
new PARAM<bool>(
"appearance.custom_toolbars",
268 &m_CustomToolbars,
false ) );
270 addParamsForWindow( &m_Window,
"window" );
272 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.on_selection",
273 &m_CrossProbing.on_selection,
true ) );
275 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.center_on_items",
276 &m_CrossProbing.center_on_items,
true ) );
278 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.zoom_to_fit",
279 &m_CrossProbing.zoom_to_fit,
true ) );
281 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.auto_highlight",
282 &m_CrossProbing.auto_highlight,
true ) );
284 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.flash_selection",
285 &m_CrossProbing.flash_selection,
false ) );
295 ret &=
fromLegacyString( aCfg,
"LastFindString",
"find_replace.find_string" );
296 ret &=
fromLegacyString( aCfg,
"LastReplaceString",
"find_replace.replace_string" );
300 ret &=
fromLegacy<int>( aCfg,
"P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth",
301 "lib_tree.column_width" );
308 nlohmann::json js = nlohmann::json::array();
314 key.Printf( wxT(
"PlotLayer_%d" ), i );
316 if( aCfg->Read( key, &val ) && val )
320 Set(
"printing.layers", js );
323 ret &=
fromLegacy<bool>( aCfg, f +
"FirstRunShown",
"system.first_run_shown" );
324 ret &=
fromLegacy<int>( aCfg, f +
"DevelMaxUndoItems",
"system.max_undo_items" );
330 nlohmann::json js = nlohmann::json::array();
332 for(
int i = 1; i <= max_history_size; i++ )
334 key.Printf(
"file%d", i );
335 file = aCfg->Read( key, wxEmptyString );
337 if( !file.IsEmpty() )
338 js.push_back( file.ToStdString() );
341 Set(
"system.file_history", js );
352 const int find_replace_history_size = 10;
353 nlohmann::json find_history = nlohmann::json::array();
354 nlohmann::json replace_history = nlohmann::json::array();
355 wxString tmp, find_key, replace_key;
357 for(
int i = 0; i < find_replace_history_size; ++i )
359 find_key.Printf(
"FindStringHistoryList%d", i );
360 replace_key.Printf(
"ReplaceStringHistoryList%d", i );
362 if( aCfg->Read( find_key, &tmp ) )
363 find_history.push_back( tmp.ToStdString() );
365 if( aCfg->Read( replace_key, &tmp ) )
366 replace_history.push_back( tmp.ToStdString() );
369 Set(
"find_replace.find_history", find_history );
370 Set(
"find_replace.replace_history", replace_history );
375 const std::string& aJsonPath )
379 const std::string frameGDO = aFrame +
"GalDisplayOptions";
380 const std::string cursorPath = aJsonPath +
".cursor";
381 const std::string gridPath = aJsonPath +
".grid";
383 ret &=
fromLegacy<bool>( aCfg, aFrame +
"Maximized", aJsonPath +
".maximized" );
384 ret &=
fromLegacyString( aCfg, aFrame +
"MostRecentlyUsedPath", aJsonPath +
".mru_path" );
385 ret &=
fromLegacy<int>( aCfg, aFrame +
"Size_x", aJsonPath +
".size_x" );
386 ret &=
fromLegacy<int>( aCfg, aFrame +
"Size_y", aJsonPath +
".size_y" );
387 ret &=
fromLegacyString( aCfg, aFrame +
"Perspective", aJsonPath +
".perspective" );
388 ret &=
fromLegacy<int>( aCfg, aFrame +
"Pos_x", aJsonPath +
".pos_x" );
389 ret &=
fromLegacy<int>( aCfg, aFrame +
"Pos_y", aJsonPath +
".pos_y" );
392 cursorPath +
".always_show_cursor" );
394 cursorPath +
".cross_hair_mode" );
396 ret &=
fromLegacy<int>( aCfg, aFrame +
"_LastGridSize", gridPath +
".last_size" );
398 ret &=
fromLegacy<int>( aCfg, aFrame +
"FastGrid1", gridPath +
".fast_grid_1" );
399 ret &=
fromLegacy<int>( aCfg, aFrame +
"FastGrid2", gridPath +
".fast_grid_2" );
401 ret &=
fromLegacy<bool>( aCfg, frameGDO +
"GridAxesEnabled", gridPath +
".axes_enabled" );
402 ret &=
fromLegacy<double>( aCfg, frameGDO +
"GridLineWidth", gridPath +
".line_width" );
403 ret &=
fromLegacy<double>( aCfg, frameGDO +
"GridMaxDensity", gridPath +
".min_spacing" );
405 ret &=
fromLegacy<int>( aCfg, frameGDO +
"GridStyle", gridPath +
".style" );
406 ret &=
fromLegacyColor( aCfg, frameGDO +
"GridColor", gridPath +
".color" );
413 int aDefaultWidth,
int aDefaultHeight )
579 return {
GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
580 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
581 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
582 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) } };
586 return {
GRID{ wxEmptyString, wxS(
"5.00 mm" ), wxS(
"5.00 mm" ) },
587 GRID{ wxEmptyString, wxS(
"2.50 mm" ), wxS(
"2.50 mm" ) },
588 GRID{ wxEmptyString, wxS(
"2.00 mm" ), wxS(
"2.00 mm" ) },
589 GRID{ wxEmptyString, wxS(
"1.00 mm" ), wxS(
"1.00 mm" ) },
590 GRID{ wxEmptyString, wxS(
"0.50 mm" ), wxS(
"0.50 mm" ) },
591 GRID{ wxEmptyString, wxS(
"0.25 mm" ), wxS(
"0.25 mm" ) },
592 GRID{ wxEmptyString, wxS(
"0.20 mm" ), wxS(
"0.20 mm" ) },
593 GRID{ wxEmptyString, wxS(
"0.10 mm" ), wxS(
"0.10 mm" ) } };
597 return {
GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
598 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
599 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
600 GRID{ wxEmptyString, wxS(
"20 mil" ), wxS(
"20 mil" ) },
601 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) },
602 GRID{ wxEmptyString, wxS(
"5 mil" ), wxS(
"5 mil" ) },
603 GRID{ wxEmptyString, wxS(
"2.5 mil" ), wxS(
"2.5 mil" ) },
604 GRID{ wxEmptyString, wxS(
"2 mil" ), wxS(
"2 mil" ) },
605 GRID{ wxEmptyString, wxS(
"1 mil" ), wxS(
"1 mil" ) },
606 GRID{ wxEmptyString, wxS(
"0.5 mil" ), wxS(
"0.5 mil" ) },
607 GRID{ wxEmptyString, wxS(
"0.2 mil" ), wxS(
"0.2 mil" ) },
608 GRID{ wxEmptyString, wxS(
"0.1 mil" ), wxS(
"0.1 mil" ) },
609 GRID{ wxEmptyString, wxS(
"5.0 mm" ), wxS(
"5.0 mm" ) },
610 GRID{ wxEmptyString, wxS(
"1.5 mm" ), wxS(
"2.5 mm" ) },
611 GRID{ wxEmptyString, wxS(
"1.0 mm" ), wxS(
"1.0 mm" ) },
612 GRID{ wxEmptyString, wxS(
"0.5 mm" ), wxS(
"0.5 mm" ) },
613 GRID{ wxEmptyString, wxS(
"0.25 mm" ), wxS(
"0.25 mm" ) },
614 GRID{ wxEmptyString, wxS(
"0.2 mm" ), wxS(
"0.2 mm" ) },
615 GRID{ wxEmptyString, wxS(
"0.1 mm" ), wxS(
"0.1 mm" ) },
616 GRID{ wxEmptyString, wxS(
"0.05 mm" ), wxS(
"0.0 mm" ) },
617 GRID{ wxEmptyString, wxS(
"0.025 mm" ), wxS(
"0.0 mm" ) },
618 GRID{ wxEmptyString, wxS(
"0.01 mm" ), wxS(
"0.0 mm" ) } };
622 return {
GRID{ wxEmptyString, wxS(
"1000 mil" ), wxS(
"1000 mil" ) },
623 GRID{ wxEmptyString, wxS(
"500 mil" ), wxS(
"500 mil" ) },
624 GRID{ wxEmptyString, wxS(
"250 mil" ), wxS(
"250 mil" ) },
625 GRID{ wxEmptyString, wxS(
"200 mil" ), wxS(
"200 mil" ) },
626 GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
627 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
628 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
629 GRID{ wxEmptyString, wxS(
"20 mil" ), wxS(
"20 mil" ) },
630 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) },
631 GRID{ wxEmptyString, wxS(
"5 mil" ), wxS(
"5 mil" ) },
632 GRID{ wxEmptyString, wxS(
"2 mil" ), wxS(
"2 mil" ) },
633 GRID{ wxEmptyString, wxS(
"1 mil" ), wxS(
"1 mil" ) },
634 GRID{ wxEmptyString, wxS(
"5.0 mm" ), wxS(
"5.0 mm" ) },
635 GRID{ wxEmptyString, wxS(
"2.5 mm" ), wxS(
"2.5 mm" ) },
636 GRID{ wxEmptyString, wxS(
"1.0 mm" ), wxS(
"1.0 mm" ) },
637 GRID{ wxEmptyString, wxS(
"0.5 mm" ), wxS(
"0.5 mm" ) },
638 GRID{ wxEmptyString, wxS(
"0.25 mm" ), wxS(
"0.25 mm" ) },
639 GRID{ wxEmptyString, wxS(
"0.2 mm" ), wxS(
"0.2 mm" ) },
640 GRID{ wxEmptyString, wxS(
"0.1 mm" ), wxS(
"0.1 mm" ) },
641 GRID{ wxEmptyString, wxS(
"0.05 mm" ), wxS(
"0.05 mm" ) },
642 GRID{ wxEmptyString, wxS(
"0.025 mm" ), wxS(
"0.025 mm" ) },
643 GRID{ wxEmptyString, wxS(
"0.01 mm" ), wxS(
"0.01 mm" ) } };
652 if( std::optional<int> optWidth =
Get<int>(
"lib_tree.column_width" ) )
655 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.
bool m_CustomToolbars
Use custom toolbars.
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.
CROSS_PROBING_SETTINGS m_CrossProbing
bool migrateLibTreeWidth()
Migrate the library tree width setting from a single column (Item) to multi-column.
int m_appSettingsSchemaVersion
! Local schema version for common app settings.
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.
bool fromLegacy(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig 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::optional< ValueType > Get(const std::string &aPath) const
Fetches a value from within the JSON document.
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...
JSON_SETTINGS(const wxString &aFilename, SETTINGS_LOC aLocation, int aSchemaVersion)
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.
KIGFX::CROSS_HAIR_MODE cross_hair_mode
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