KiCad PCB EDA Suite
eeschema_settings.cpp
Go to the documentation of this file.
1 /*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23 
24 #include <eeschema_settings.h>
26 #include <libedit_settings.h>
27 #include <pgm_base.h>
29 #include <settings/parameters.h>
31 #include <wx/config.h>
32 #include <widgets/ui_common.h>
33 #include <default_values.h> // For some default values
34 
36 const int eeschemaSchemaVersion = 0;
37 
38 
41  m_Appearance(),
42  m_AutoplaceFields(),
43  m_Drawing(),
44  m_Input(),
45  m_PageSettings(),
46  m_AnnotatePanel(),
47  m_BomPanel(),
48  m_FieldEditorPanel(),
49  m_LibViewPanel(),
50  m_NetlistPanel(),
51  m_SymChooserPanel(),
52  m_Selection(),
53  m_Simulator(),
54  m_RescueNeverShow( false )
55 {
56  m_params.emplace_back( new PARAM<wxString>( "appearance.edit_component_visible_columns",
57  &m_Appearance.edit_component_visible_columns, "0 1 2 3 4 5 6 7" ) );
58 
59  m_params.emplace_back( new PARAM<wxString>( "appearance.edit_sheet_visible_columns",
60  &m_Appearance.edit_sheet_visible_columns, "0 1 2 3 4 5 6 7" ) );
61 
62  m_params.emplace_back( new PARAM<int>( "appearance.erc_severities",
64 
65  m_params.emplace_back( new PARAM<bool>( "appearance.footprint_preview",
67 
68  m_params.emplace_back( new PARAM<bool>( "appearance.navigator_stays_open",
70 
71  m_params.emplace_back( new PARAM<bool>( "appearance.print_sheet_reference",
73 
74  m_params.emplace_back( new PARAM<bool>( "appearance.show_hidden_pins",
75  &m_Appearance.show_hidden_pins, false ) );
76 
77  m_params.emplace_back( new PARAM<bool>( "appearance.show_hidden_fields",
78  &m_Appearance.show_hidden_fields, false ) );
79 
80  m_params.emplace_back( new PARAM<bool>( "appearance.show_illegal_symbol_lib_dialog",
82 
83  m_params.emplace_back( new PARAM<bool>( "appearance.show_page_limits",
84  &m_Appearance.show_page_limits, true ) );
85 
86  m_params.emplace_back( new PARAM<bool>( "appearance.show_sexpr_file_convert_warning",
88 
89  m_params.emplace_back(
90  new PARAM<bool>( "appearance.show_sheet_filename_case_sensitivity_dialog",
92 
93  m_params.emplace_back( new PARAM<bool>( "autoplace_fields.enable",
94  &m_AutoplaceFields.enable, true ) );
95 
96  m_params.emplace_back( new PARAM<bool>( "autoplace_fields.allow_rejustify",
98 
99  m_params.emplace_back( new PARAM<bool>( "autoplace_fields.align_to_grid",
100  &m_AutoplaceFields.align_to_grid, true ) );
101 
102  m_params.emplace_back( new PARAM<int>( "drawing.default_bus_thickness",
104 
105  m_params.emplace_back( new PARAM<int>( "drawing.default_junction_size",
107 
108  m_params.emplace_back( new PARAM<int>( "drawing.pin_symbol_size",
110 
111  m_params.emplace_back(
112  new PARAM<double>( "drawing.text_offset_ratio", &m_Drawing.text_offset_ratio, 0.08 ) );
113 
114  m_params.emplace_back( new PARAM<int>( "drawing.default_line_thickness",
116 
117  m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_x",
119 
120  m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_y",
122 
123  m_params.emplace_back( new PARAM<int>( "drawing.default_wire_thickness",
125 
126  m_params.emplace_back( new PARAM<int>(
127  "drawing.default_text_size", &m_Drawing.default_text_size, DEFAULT_TEXT_SIZE ) );
128 
129  m_params.emplace_back( new PARAM<wxString>( "drawing.field_names",
130  &m_Drawing.field_names, "" ) );
131 
132  m_params.emplace_back( new PARAM<bool>( "drawing.hv_lines_only",
133  &m_Drawing.hv_lines_only, true ) );
134 
135  m_params.emplace_back( new PARAM<int>( "drawing.repeat_label_increment",
136  &m_Drawing.repeat_label_increment, 1, -10, 10 ) );
137 
138  m_params.emplace_back( new PARAM<COLOR4D>( "drawing.default_sheet_border_color",
140 
141  m_params.emplace_back( new PARAM<COLOR4D>( "drawing.default_sheet_background_color",
142  &m_Drawing.default_sheet_background_color, COLOR4D( WHITE ).WithAlpha( 0.0 ) ) );
143 
144  m_params.emplace_back( new PARAM<bool>( "input.drag_is_move",
145  &m_Input.drag_is_move, true ) );
146 
147  m_params.emplace_back( new PARAM<int>( "selection.thickness",
148  &m_Selection.thickness, 3 ) );
149 
150  m_params.emplace_back( new PARAM<bool>( "selection.draw_selected_children",
152 
153  m_params.emplace_back( new PARAM<bool>( "selection.fill_shapes",
154  &m_Selection.fill_shapes, false ) );
155 
156  m_params.emplace_back( new PARAM<bool>( "selection.select_pin_selects_symbol",
158 
159  m_params.emplace_back( new PARAM<bool>( "selection.text_as_box",
160  &m_Selection.text_as_box, false ) );
161 
162  m_params.emplace_back( new PARAM<int>( "annotation.method",
163  &m_AnnotatePanel.method, 0, 0, 2 ) );
164 
165  m_params.emplace_back( new PARAM<int>( "annotation.messages_filter",
167 
168  m_params.emplace_back( new PARAM<int>( "annotation.sort_order",
169  &m_AnnotatePanel.sort_order, 0, 0, 1 ) );
170 
171  m_params.emplace_back( new PARAM<wxString>( "bom.selected_plugin",
172  &m_BomPanel.selected_plugin, "" ) );
173 
174  m_params.emplace_back( new PARAM<wxString>( "bom.plugins",
175  &m_BomPanel.plugins, "" ) );
176 
177  m_params.emplace_back( new PARAM<bool>( "page_settings.export_paper",
178  &m_PageSettings.export_paper, false ) );
179 
180  m_params.emplace_back( new PARAM<bool>( "page_settings.export_revision",
181  &m_PageSettings.export_revision, false ) );
182 
183  m_params.emplace_back( new PARAM<bool>( "page_settings.export_date",
184  &m_PageSettings.export_date, false ) );
185 
186  m_params.emplace_back( new PARAM<bool>( "page_settings.export_title",
187  &m_PageSettings.export_title, false ) );
188 
189  m_params.emplace_back( new PARAM<bool>( "page_settings.export_company",
190  &m_PageSettings.export_company, false ) );
191 
192  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment1",
193  &m_PageSettings.export_comment1, false ) );
194 
195  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment2",
196  &m_PageSettings.export_comment2, false ) );
197 
198  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment3",
199  &m_PageSettings.export_comment3, false ) );
200 
201  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment4",
202  &m_PageSettings.export_comment4, false ) );
203 
204  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment5",
205  &m_PageSettings.export_comment5, false ) );
206 
207  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment6",
208  &m_PageSettings.export_comment6, false ) );
209 
210  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment7",
211  &m_PageSettings.export_comment7, false ) );
212 
213  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment8",
214  &m_PageSettings.export_comment8, false ) );
215 
216  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment9",
217  &m_PageSettings.export_comment9, false ) );
218 
219  m_params.emplace_back( new PARAM_MAP<bool>( "field_editor.fields_show",
221 
222  m_params.emplace_back( new PARAM_MAP<bool>( "field_editor.fields_group_by",
224 
225  m_params.emplace_back( new PARAM_MAP<int>( "field_editor.column_widths",
227 
228  m_params.emplace_back( new PARAM<bool>( "plot.background_color",
229  &m_PlotPanel.background_color, false ) );
230 
231  m_params.emplace_back( new PARAM<bool>( "plot.color",
232  &m_PlotPanel.color, true ) );
233 
234  m_params.emplace_back( new PARAM<wxString>( "plot.color_theme",
235  &m_PlotPanel.color_theme, wxT( "user" ) ) );
236 
237  m_params.emplace_back( new PARAM<int>( "plot.format",
238  &m_PlotPanel.format, 0 ) );
239 
240  m_params.emplace_back( new PARAM<bool>( "plot.frame_reference",
241  &m_PlotPanel.frame_reference, true ) );
242 
243  m_params.emplace_back( new PARAM<int>( "plot.hpgl_paper_size",
245 
246  m_params.emplace_back( new PARAM<double>( "plot.hpgl_pen_size",
247  &m_PlotPanel.hpgl_pen_size, 0.5 ) );
248 
249  m_params.emplace_back( new PARAM<bool>( "plot.hpgl_origin",
250  &m_PlotPanel.hpgl_origin, false ) );
251 
252  m_params.emplace_back( new PARAM<int>( "simulator.window.pos_x",
253  &m_Simulator.window.pos_x, 0 ) );
254 
255  m_params.emplace_back( new PARAM<int>( "simulator.window.pos_y",
256  &m_Simulator.window.pos_y, 0 ) );
257 
258  m_params.emplace_back( new PARAM<int>( "simulator.window.size_x",
259  &m_Simulator.window.size_x, 500 ) );
260 
261  m_params.emplace_back( new PARAM<int>( "simulator.window.size_y",
262  &m_Simulator.window.size_y, 400 ) );
263 
264  m_params.emplace_back( new PARAM<unsigned int>( "simulator.window.display",
265  &m_Simulator.window.display, 0 ) );
266 
267  m_params.emplace_back( new PARAM<bool>( "simulator.window.maximized",
268  &m_Simulator.window.maximized, false ) );
269 
270  m_params.emplace_back( new PARAM<wxString>( "simulator.window.perspective",
271  &m_Simulator.window.perspective, "" ) );
272 
273  m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_width",
275 
276  m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_height",
278 
279  m_params.emplace_back( new PARAM<int>( "simulator.signal_panel_height",
281 
282  m_params.emplace_back( new PARAM<int>( "simulator.cursors_panel_height",
284 
285  m_params.emplace_back( new PARAM<bool>( "simulator.white_background",
286  &m_Simulator.white_background, false ) );
287 
288  m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_h",
289  &m_SymChooserPanel.sash_pos_h, -1 ) );
290 
291  m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_v",
292  &m_SymChooserPanel.sash_pos_v, -1 ) );
293 
294  m_params.emplace_back( new PARAM<int>( "symbol_chooser.width",
295  &m_SymChooserPanel.width, -1 ) );
296 
297  m_params.emplace_back( new PARAM<int>( "symbol_chooser.height",
298  &m_SymChooserPanel.height, -1 ) );
299 
300  m_params.emplace_back( new PARAM<bool>( "symbol_chooser.keep_symbol",
301  &m_SymChooserPanel.keep_symbol, false ) );
302 
303  m_params.emplace_back( new PARAM<bool>( "symbol_chooser.place_all_units",
305 
306  m_params.emplace_back( new PARAM<bool>( "system.never_show_rescue_dialog",
307  &m_RescueNeverShow, false ) );
308 
309  m_params.emplace_back( new PARAM<int>( "lib_view.window.pos_x",
310  &m_LibViewPanel.window.pos_x, 0 ) );
311 
312  m_params.emplace_back( new PARAM<int>( "lib_view.window.pos_y",
313  &m_LibViewPanel.window.pos_y, 0 ) );
314 
315  m_params.emplace_back( new PARAM<int>( "lib_view.window.size_x",
316  &m_LibViewPanel.window.size_x, 500 ) );
317 
318  m_params.emplace_back( new PARAM<int>( "lib_view.window.size_y",
319  &m_LibViewPanel.window.size_y, 400 ) );
320 
321  m_params.emplace_back( new PARAM<unsigned int>( "lib_view.window.display",
322  &m_LibViewPanel.window.display, 0 ) );
323 
324  m_params.emplace_back( new PARAM<bool>( "lib_view.window.maximized",
325  &m_LibViewPanel.window.maximized, false ) );
326 
327  m_params.emplace_back( new PARAM<wxString>( "lib_view.window.perspective",
329 
330  m_params.emplace_back( new PARAM<int>( "lib_view.lib_list_width",
331  &m_LibViewPanel.lib_list_width, 150 ) );
332 
333  m_params.emplace_back( new PARAM<int>( "lib_view.cmp_list_width",
334  &m_LibViewPanel.cmp_list_width, 150 ) );
335 
336  m_params.emplace_back( new PARAM<bool>( "lib_view.show_pin_electrical_type",
338 }
339 
340 
341 bool EESCHEMA_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
342 {
343  bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
344 
345  ret &= fromLegacy<bool>( aCfg, "FootprintPreview", "appearance.footprint_preview" );
346  ret &= fromLegacy<bool>( aCfg, "NavigatorStaysOpen", "appearance.navigator_stays_open" );
347  ret &= fromLegacy<bool>( aCfg, "PrintSheetReferenceAndTitleBlock",
348  "appearance.print_sheet_reference" );
349  ret &= fromLegacy<bool>( aCfg, "ShowHiddenPins", "appearance.show_hidden_pins" );
350  ret &= fromLegacy<bool>( aCfg, "ShowIllegalSymbolLibDialog",
351  "appearance.show_illegal_symbol_lib_dialog" );
352  ret &= fromLegacy<bool>( aCfg, "ShowPageLimits", "appearance.show_page_limits" );
353  ret &= fromLegacy<bool>( aCfg, "ShowSheetFileNameCaseSensitivityDlg",
354  "appearance.show_sheet_filename_case_sensitivity_dialog" );
355 
356  ret &= fromLegacy<bool>( aCfg, "AutoplaceFields", "autoplace_fields.enable" );
357  ret &= fromLegacy<bool>( aCfg, "AutoplaceJustify", "autoplace_fields.allow_rejustify" );
358  ret &= fromLegacy<bool>( aCfg, "AutoplaceAlign", "autoplace_fields.align_to_grid" );
359 
360  ret &= fromLegacy<int>( aCfg, "DefaultBusWidth", "drawing.default_bus_thickness" );
361  ret &= fromLegacy<int>( aCfg, "DefaultJunctionSize", "drawing.default_junction_size" );
362  ret &= fromLegacy<int>( aCfg, "DefaultDrawLineWidth", "drawing.default_line_thickness" );
363  ret &= fromLegacy<int>( aCfg, "RepeatStepX", "drawing.default_repeat_offset_x" );
364  ret &= fromLegacy<int>( aCfg, "RepeatStepY", "drawing.default_repeat_offset_y" );
365  ret &= fromLegacy<int>( aCfg, "DefaultWireWidth", "drawing.default_wire_thickness" );
366  ret &= fromLegacyString( aCfg, "FieldNames", "drawing.field_names" );
367  ret &= fromLegacy<bool>( aCfg, "HorizVertLinesOnly", "drawing.hv_lines_only" );
368  ret &= fromLegacy<int>( aCfg, "RepeatLabelIncrement", "drawing.repeat_label_increment" );
369 
370  ret &= fromLegacy<bool>( aCfg, "DragActionIsMove", "input.drag_is_move" );
371 
372  ret &= fromLegacy<int>( aCfg, "SelectionThickness", "selection.thickness" );
373  ret &= fromLegacy<bool>( aCfg, "SelectionDrawChildItems", "selection.draw_selected_children" );
374  ret &= fromLegacy<bool>( aCfg, "SelectionFillShapes", "selection.fill_shapes" );
375  ret &= fromLegacy<bool>( aCfg, "SelectPinSelectSymbolOpt",
376  "selection.select_pin_selects_symbol" );
377  ret &= fromLegacy<bool>( aCfg, "SelectionTextAsBox", "selection.text_as_box" );
378 
379  ret &= fromLegacy<int>( aCfg, "AnnotateAlgoOption", "annotation.method" );
380  ret &= fromLegacy<int>( aCfg, "AnnotateFilterMsg", "annotation.messages_filter" );
381  ret &= fromLegacy<int>( aCfg, "AnnotateSortOption", "annotation.sort_order" );
382 
383  ret &= fromLegacyString( aCfg, "bom_plugin_selected", "bom.selected_plugin" );
384  ret &= fromLegacyString( aCfg, "bom_plugins", "bom.plugins" );
385 
386  ret &= fromLegacyString( aCfg, "SymbolFieldsShownColumns",
387  "edit_sch_component.visible_columns" );
388 
389  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportRevision", "page_settings.export_revision" );
390  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportDate", "page_settings.export_date" );
391  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportTitle", "page_settings.export_title" );
392  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportCompany", "page_settings.export_company" );
393  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment1", "page_settings.export_comment1" );
394  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment2", "page_settings.export_comment2" );
395  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment3", "page_settings.export_comment3" );
396  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment4", "page_settings.export_comment4" );
397  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment5", "page_settings.export_comment5" );
398  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment6", "page_settings.export_comment6" );
399  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment7", "page_settings.export_comment7" );
400  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment8", "page_settings.export_comment8" );
401  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment9", "page_settings.export_comment9" );
402 
403  {
404  constexpr int max_custom_commands = 8; // from DIALOG_NETLIST
405  nlohmann::json js_cmd = nlohmann::json::array();
406  nlohmann::json js_title = nlohmann::json::array();
407  wxString cmd_key, title_key, cmd, title;
408 
409  for( int i = 1; i <= max_custom_commands; ++i )
410  {
411  // Only migrate if both title and command are specified
412  cmd_key.Printf( "CustomNetlistCommand%d", i );
413  title_key.Printf( "CustomNetlistTitle%d", i );
414 
415  if( aCfg->Read( cmd_key, &cmd ) && aCfg->Read( title_key, &title )
416  && !cmd.IsEmpty() && !title.IsEmpty() )
417  {
418  js_cmd.push_back( cmd.ToUTF8() );
419  js_title.push_back( title.ToUTF8() );
420  }
421  }
422 
423  ( *this )[PointerFromString( "netlist.custom_command_titles" )] = js_title;
424  ( *this )[PointerFromString( "netlist.custom_command_paths" )] = js_cmd;
425  }
426 
427  {
428  // NOTE(JE) These parameters should move to project-local storage before V6, but we are
429  // migrating them here in order to preserve data. There is a bug here that is preserved:
430  // keys are taken directly from the (translated) UI and stored in the config, so if the user
431  // changes languages the keys will no longer work.
432  aCfg->SetPath( "SymbolFieldEditor/Show/" );
433 
434  nlohmann::json js = nlohmann::json( {} );
435  wxString key;
436  bool value = false;
437  long index = 0;
438 
439  while( aCfg->GetNextEntry( key, index ) )
440  {
441  if( aCfg->Read( key, &value ) )
442  {
443  std::string key_utf( key.ToUTF8() );
444  js[PointerFromString( key_utf )] = value;
445  }
446  }
447 
448  ( *this )[PointerFromString( "field_editor.fields_show" ) ] = js;
449 
450  aCfg->SetPath( "../GroupBy" );
451 
452  while( aCfg->GetNextEntry( key, index ) )
453  {
454  if( aCfg->Read( key, &value ) )
455  {
456  std::string key_utf( key.ToUTF8() );
457  js[PointerFromString( key_utf )] = value;
458  }
459  }
460 
461  ( *this )[PointerFromString( "field_editor.fields_group_by" ) ] = js;
462 
463  aCfg->SetPath( "../.." );
464  }
465 
466  ret &= fromLegacy<bool>( aCfg, "PlotModeColor", "plot.color" );
467  ret &= fromLegacy<int>( aCfg, "PlotFormat", "plot.format" );
468  ret &= fromLegacy<bool>( aCfg, "PlotFrameRef", "plot.frame_reference" );
469  ret &= fromLegacy<bool>( aCfg, "PlotHPGLOrg", "plot.hpgl_origin" );
470  ret &= fromLegacy<int>( aCfg, "PlotHPGLPaperSize", "plot.hpgl_paper_size" );
471  ret &= fromLegacy<double>( aCfg, "PlotHPGLPenSize", "plot.hpgl_pen_size" );
472 
473  ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_x", "simulator.window.pos_x" );
474  ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_y", "simulator.window.pos_y" );
475  ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_x", "simulator.window.size_x" );
476  ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_y", "simulator.window.size_y" );
477  ret &= fromLegacy<bool>( aCfg, "SIM_PLOT_FRAMEMaximized", "simulator.window.maximized" );
478  ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEPerspective", "simulator.window.perspective" );
479  ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEMostRecentlyUsedPath", "simulator.mru_path" );
480  ret &= fromLegacy<int>( aCfg, "SimPlotPanelWidth", "simulator.plot_panel_width" );
481  ret &= fromLegacy<int>( aCfg, "SimPlotPanelHeight", "simulator.plot_panel_height" );
482  ret &= fromLegacy<int>( aCfg, "SimSignalPanelHeight", "simulator.signal_panel_height" );
483  ret &= fromLegacy<int>( aCfg, "SimCursorsPanelHeight", "simulator.cursors_panel_height" );
484  ret &= fromLegacy<bool>( aCfg, "SimPlotWhiteBg", "simulator.white_background" );
485 
486  ret &= fromLegacy<int>( aCfg, "SymbolChooserHSashPosition", "symbol_chooser.sash_pos_h" );
487  ret &= fromLegacy<int>( aCfg, "SymbolChooserVSashPosition", "symbol_chooser.sash_pos_v" );
488  ret &= fromLegacy<int>( aCfg, "SymbolChooserWidth", "symbol_chooser.width" );
489  ret &= fromLegacy<int>( aCfg, "SymbolChooserHeight", "symbol_chooser.height" );
490  ret &= fromLegacy<bool>( aCfg, "SymbolChooserKeepSymbol", "symbol_chooser.keep_symbol" );
491  ret &= fromLegacy<bool>( aCfg, "SymbolChooserUseUnits", "symbol_chooser.place_all_units" );
492 
493  const std::string vlf = "ViewlibFrame";
494  ret &= fromLegacy<bool>( aCfg, vlf + "Maximized", "lib_view.window.maximized" );
495  ret &= fromLegacyString( aCfg, vlf + "MostRecentlyUsedPath", "lib_view.window.mru_path" );
496  ret &= fromLegacy<int>( aCfg, vlf + "Size_x", "lib_view.window.size_x" );
497  ret &= fromLegacy<int>( aCfg, vlf + "Size_y", "lib_view.window.size_y" );
498  ret &= fromLegacyString( aCfg, vlf + "Perspective", "lib_view.window.perspective" );
499  ret &= fromLegacy<int>( aCfg, vlf + "Pos_x", "lib_view.window.pos_x" );
500  ret &= fromLegacy<int>( aCfg, vlf + "Pos_y", "lib_view.window.pos_y" );
501  ret &= fromLegacy<int>( aCfg, "ViewLiblistWidth", "lib_view.lib_list_width" );
502  ret &= fromLegacy<int>( aCfg, "ViewCmplistWidth", "lib_view.cmp_list_width" );
503  ret &= fromLegacy<bool>( aCfg,
504  "ViewCmpShowPinElectricalType", "lib_view.show_pin_electrical_type" );
505  ret &= fromLegacy<bool>( aCfg, vlf + "ShowGrid", "lib_view.grid.show" );
506  ret &= fromLegacy<int>( aCfg, vlf + "_LastGridSize", "lib_view.grid.last_size" );
507 
508  ret &= fromLegacy<bool>( aCfg, "RescueNeverShow", "system.never_show_rescue_dialog" );
509 
510  // Legacy version stored this setting in eeschema, so move it to common if it exists
511  aCfg->Read( "MoveWarpsCursor", &Pgm().GetCommonSettings()->m_Input.warp_mouse_on_move );
512 
513  COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
514 
515  auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) {
516  wxString str;
517 
518  if( aCfg->Read( aKey, &str ) )
519  cs->SetColor( aLayerId, COLOR4D( str ) );
520  };
521 
522  migrateLegacyColor( "Color4DBgCanvasEx", LAYER_SCHEMATIC_BACKGROUND );
523  migrateLegacyColor( "Color4DBodyBgEx", LAYER_DEVICE_BACKGROUND );
524  migrateLegacyColor( "Color4DBodyEx", LAYER_DEVICE );
525  migrateLegacyColor( "Color4DBrightenedEx", LAYER_BRIGHTENED );
526  migrateLegacyColor( "Color4DBusEx", LAYER_BUS );
527  migrateLegacyColor( "Color4DConnEx", LAYER_JUNCTION );
528  migrateLegacyColor( "Color4DCursorEx", LAYER_SCHEMATIC_CURSOR );
529  migrateLegacyColor( "Color4DErcEEx", LAYER_ERC_ERR );
530  migrateLegacyColor( "Color4DErcWEx", LAYER_ERC_WARN );
531  migrateLegacyColor( "Color4DFieldEx", LAYER_FIELDS );
532  migrateLegacyColor( "Color4DGLabelEx", LAYER_GLOBLABEL );
533  migrateLegacyColor( "Color4DGridEx", LAYER_SCHEMATIC_GRID );
534  migrateLegacyColor( "Color4DHLabelEx", LAYER_HIERLABEL );
535  migrateLegacyColor( "Color4DHiddenEx", LAYER_HIDDEN );
536  migrateLegacyColor( "Color4DLLabelEx", LAYER_LOCLABEL );
537  migrateLegacyColor( "Color4DNetNameEx", LAYER_NETNAM );
538  migrateLegacyColor( "Color4DNoConnectEx", LAYER_NOCONNECT );
539  migrateLegacyColor( "Color4DNoteEx", LAYER_NOTES );
540  migrateLegacyColor( "Color4DPinEx", LAYER_PIN );
541  migrateLegacyColor( "Color4DPinNameEx", LAYER_PINNAM );
542  migrateLegacyColor( "Color4DPinNumEx", LAYER_PINNUM );
543  migrateLegacyColor( "Color4DReferenceEx", LAYER_REFERENCEPART );
544  migrateLegacyColor( "Color4DShadowEx", LAYER_SELECTION_SHADOWS );
545  migrateLegacyColor( "Color4DSheetEx", LAYER_SHEET );
546  migrateLegacyColor( "Color4DSheetFileNameEx", LAYER_SHEETFILENAME );
547  migrateLegacyColor( "Color4DSheetLabelEx", LAYER_SHEETLABEL );
548  migrateLegacyColor( "Color4DSheetNameEx", LAYER_SHEETNAME );
549  migrateLegacyColor( "Color4DValueEx", LAYER_VALUEPART );
550  migrateLegacyColor( "Color4DWireEx", LAYER_WIRE );
551  migrateLegacyColor( "Color4DWorksheetEx", LAYER_SCHEMATIC_WORKSHEET );
552 
553  Pgm().GetSettingsManager().SaveColorSettings( cs, "schematic" );
554 
555  // LibEdit settings were stored with eeschema. If eeschema is the first app to run,
556  // we need to migrate the LibEdit settings here
557 
558  auto libedit = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>( false );
559  libedit->MigrateFromLegacy( aCfg );
560  libedit->Load();
561 
562  return ret;
563 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
Represents a map of <std::string, Value>.
Definition: parameters.h:643
PANEL_ANNOTATE m_AnnotatePanel
#define DEFAULT_JUNCTION_DIAM
The default bus and wire enty size in mils.
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
nlohmann::json json
Definition: gerbview.cpp:40
PANEL_SYM_CHOOSER m_SymChooserPanel
PANEL_FIELD_EDITOR m_FieldEditorPanel
PAGE_SETTINGS m_PageSettings
wxString perspective
Definition: app_settings.h:74
AUTOPLACE_FIELDS m_AutoplaceFields
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:92
Functions to provide common constants and other functions to assist in making a consistent UI.
std::map< std::string, int > column_widths
#define DEFAULT_LINE_THICKNESS
The default wire width in mils. (can be changed in preference menu)
PANEL_LIB_VIEW m_LibViewPanel
#define DEFAULT_BUS_THICKNESS
The default noconnect size in mils.
Definition: color4d.h:48
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
see class PGM_BASE
Board layer functions and definitions.
#define DEFAULT_WIRE_THICKNESS
The default bus width in mils. (can be changed in preference menu)
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
Color settings are a bit different than most of the settings objects in that there can be more than o...
#define DEFAULT_TEXT_SIZE
const int eeschemaSchemaVersion
! Update the schema version whenever a migration is required
std::map< std::string, bool > fields_group_by
std::map< std::string, bool > fields_show
static nlohmann::json::json_pointer PointerFromString(std::string aPath)
Builds a JSON pointer based on a given string.
unsigned int display
Definition: app_settings.h:77
void SetColor(int aLayer, COLOR4D aColor)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99