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 
40 {
41  m_params.emplace_back( new PARAM<wxString>( "appearance.edit_component_visible_columns",
42  &m_Appearance.edit_component_visible_columns, "0 1 2 3 4 5 6 7" ) );
43 
44  m_params.emplace_back( new PARAM<wxString>( "appearance.edit_sheet_visible_columns",
45  &m_Appearance.edit_sheet_visible_columns, "0 1 2 3 4 5 6 7" ) );
46 
47  m_params.emplace_back( new PARAM<int>( "appearance.erc_severities",
49 
50  m_params.emplace_back( new PARAM<bool>( "appearance.footprint_preview",
52 
53  m_params.emplace_back( new PARAM<bool>( "appearance.navigator_stays_open",
55 
56  m_params.emplace_back( new PARAM<bool>( "appearance.print_sheet_reference",
58 
59  m_params.emplace_back( new PARAM<bool>( "appearance.show_hidden_pins",
60  &m_Appearance.show_hidden_pins, false ) );
61 
62  m_params.emplace_back( new PARAM<bool>( "appearance.show_hidden_fields",
63  &m_Appearance.show_hidden_fields, false ) );
64 
65  m_params.emplace_back( new PARAM<bool>( "appearance.show_illegal_symbol_lib_dialog",
67 
68  m_params.emplace_back( new PARAM<bool>( "appearance.show_page_limits",
69  &m_Appearance.show_page_limits, true ) );
70 
71  m_params.emplace_back( new PARAM<bool>( "appearance.show_sexpr_file_convert_warning",
73 
74  m_params.emplace_back(
75  new PARAM<bool>( "appearance.show_sheet_filename_case_sensitivity_dialog",
77 
78  m_params.emplace_back( new PARAM<bool>( "autoplace_fields.enable",
79  &m_AutoplaceFields.enable, true ) );
80 
81  m_params.emplace_back( new PARAM<bool>( "autoplace_fields.allow_rejustify",
83 
84  m_params.emplace_back( new PARAM<bool>( "autoplace_fields.align_to_grid",
86 
87  m_params.emplace_back( new PARAM<int>( "drawing.default_bus_thickness",
89 
90  m_params.emplace_back( new PARAM<int>( "drawing.default_junction_size",
92 
93  m_params.emplace_back( new PARAM<int>( "drawing.pin_symbol_size",
95 
96  m_params.emplace_back(
97  new PARAM<double>( "drawing.text_offset_ratio", &m_Drawing.text_offset_ratio, 0.08 ) );
98 
99  m_params.emplace_back( new PARAM<int>( "drawing.default_line_thickness",
101 
102  m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_x",
104 
105  m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_y",
107 
108  m_params.emplace_back( new PARAM<int>( "drawing.default_wire_thickness",
110 
111  m_params.emplace_back( new PARAM<int>(
112  "drawing.default_text_size", &m_Drawing.default_text_size, DEFAULT_TEXT_SIZE ) );
113 
114  m_params.emplace_back( new PARAM<wxString>( "drawing.field_names",
115  &m_Drawing.field_names, "" ) );
116 
117  m_params.emplace_back( new PARAM<bool>( "drawing.hv_lines_only",
118  &m_Drawing.hv_lines_only, true ) );
119 
120  m_params.emplace_back( new PARAM<int>( "drawing.repeat_label_increment",
121  &m_Drawing.repeat_label_increment, 1, -10, 10 ) );
122 
123  m_params.emplace_back( new PARAM<COLOR4D>( "drawing.default_sheet_border_color",
125 
126  m_params.emplace_back( new PARAM<COLOR4D>( "drawing.default_sheet_background_color",
127  &m_Drawing.default_sheet_background_color, COLOR4D( WHITE ).WithAlpha( 0.0 ) ) );
128 
129  m_params.emplace_back( new PARAM<bool>( "input.drag_is_move",
130  &m_Input.drag_is_move, true ) );
131 
132  m_params.emplace_back( new PARAM<int>( "selection.thickness",
133  &m_Selection.thickness, 3 ) );
134 
135  m_params.emplace_back( new PARAM<bool>( "selection.draw_selected_children",
137 
138  m_params.emplace_back( new PARAM<bool>( "selection.fill_shapes",
139  &m_Selection.fill_shapes, false ) );
140 
141  m_params.emplace_back( new PARAM<bool>( "selection.select_pin_selects_symbol",
143 
144  m_params.emplace_back( new PARAM<bool>( "selection.text_as_box",
145  &m_Selection.text_as_box, false ) );
146 
147  m_params.emplace_back( new PARAM<int>( "annotation.method",
148  &m_AnnotatePanel.method, 0, 0, 2 ) );
149 
150  m_params.emplace_back( new PARAM<int>( "annotation.messages_filter",
152 
153  m_params.emplace_back( new PARAM<int>( "annotation.sort_order",
154  &m_AnnotatePanel.sort_order, 0, 0, 1 ) );
155 
156  m_params.emplace_back( new PARAM<wxString>( "bom.selected_plugin",
157  &m_BomPanel.selected_plugin, "" ) );
158 
159  m_params.emplace_back( new PARAM<wxString>( "bom.plugins",
160  &m_BomPanel.plugins, "" ) );
161 
162  m_params.emplace_back( new PARAM<bool>( "page_settings.export_paper",
163  &m_PageSettings.export_paper, false ) );
164 
165  m_params.emplace_back( new PARAM<bool>( "page_settings.export_revision",
166  &m_PageSettings.export_revision, false ) );
167 
168  m_params.emplace_back( new PARAM<bool>( "page_settings.export_date",
169  &m_PageSettings.export_date, false ) );
170 
171  m_params.emplace_back( new PARAM<bool>( "page_settings.export_title",
172  &m_PageSettings.export_title, false ) );
173 
174  m_params.emplace_back( new PARAM<bool>( "page_settings.export_company",
175  &m_PageSettings.export_company, false ) );
176 
177  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment1",
178  &m_PageSettings.export_comment1, false ) );
179 
180  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment2",
181  &m_PageSettings.export_comment2, false ) );
182 
183  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment3",
184  &m_PageSettings.export_comment3, false ) );
185 
186  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment4",
187  &m_PageSettings.export_comment4, false ) );
188 
189  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment5",
190  &m_PageSettings.export_comment5, false ) );
191 
192  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment6",
193  &m_PageSettings.export_comment6, false ) );
194 
195  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment7",
196  &m_PageSettings.export_comment7, false ) );
197 
198  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment8",
199  &m_PageSettings.export_comment8, false ) );
200 
201  m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment9",
202  &m_PageSettings.export_comment9, false ) );
203 
204  m_params.emplace_back( new PARAM_MAP<bool>( "field_editor.fields_show",
206 
207  m_params.emplace_back( new PARAM_MAP<bool>( "field_editor.fields_group_by",
209 
210  m_params.emplace_back( new PARAM_MAP<int>( "field_editor.column_widths",
212 
213  m_params.emplace_back( new PARAM<bool>( "plot.background_color",
214  &m_PlotPanel.background_color, false ) );
215 
216  m_params.emplace_back( new PARAM<bool>( "plot.color",
217  &m_PlotPanel.color, true ) );
218 
219  m_params.emplace_back( new PARAM<wxString>( "plot.color_theme",
220  &m_PlotPanel.color_theme, wxT( "user" ) ) );
221 
222  m_params.emplace_back( new PARAM<int>( "plot.format",
223  &m_PlotPanel.format, 0 ) );
224 
225  m_params.emplace_back( new PARAM<bool>( "plot.frame_reference",
226  &m_PlotPanel.frame_reference, true ) );
227 
228  m_params.emplace_back( new PARAM<int>( "plot.hpgl_paper_size",
230 
231  m_params.emplace_back( new PARAM<double>( "plot.hpgl_pen_size",
232  &m_PlotPanel.hpgl_pen_size, 0.5 ) );
233 
234  m_params.emplace_back( new PARAM<bool>( "plot.hpgl_origin",
235  &m_PlotPanel.hpgl_origin, false ) );
236 
237  m_params.emplace_back( new PARAM<int>( "simulator.window.pos_x",
238  &m_Simulator.window.pos_x, 0 ) );
239 
240  m_params.emplace_back( new PARAM<int>( "simulator.window.pos_y",
241  &m_Simulator.window.pos_y, 0 ) );
242 
243  m_params.emplace_back( new PARAM<int>( "simulator.window.size_x",
244  &m_Simulator.window.size_x, 500 ) );
245 
246  m_params.emplace_back( new PARAM<int>( "simulator.window.size_y",
247  &m_Simulator.window.size_y, 400 ) );
248 
249  m_params.emplace_back( new PARAM<bool>( "simulator.window.maximized",
250  &m_Simulator.window.maximized, false ) );
251 
252  m_params.emplace_back( new PARAM<wxString>( "simulator.window.perspective",
253  &m_Simulator.window.perspective, "" ) );
254 
255  m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_width",
257 
258  m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_height",
260 
261  m_params.emplace_back( new PARAM<int>( "simulator.signal_panel_height",
263 
264  m_params.emplace_back( new PARAM<int>( "simulator.cursors_panel_height",
266 
267  m_params.emplace_back( new PARAM<bool>( "simulator.white_background",
268  &m_Simulator.white_background, false ) );
269 
270  m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_h",
271  &m_SymChooserPanel.sash_pos_h, -1 ) );
272 
273  m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_v",
274  &m_SymChooserPanel.sash_pos_v, -1 ) );
275 
276  m_params.emplace_back( new PARAM<int>( "symbol_chooser.width",
277  &m_SymChooserPanel.width, -1 ) );
278 
279  m_params.emplace_back( new PARAM<int>( "symbol_chooser.height",
280  &m_SymChooserPanel.height, -1 ) );
281 
282  m_params.emplace_back( new PARAM<bool>( "symbol_chooser.keep_symbol",
283  &m_SymChooserPanel.keep_symbol, false ) );
284 
285  m_params.emplace_back( new PARAM<bool>( "symbol_chooser.place_all_units",
287 
288  m_params.emplace_back( new PARAM<bool>( "system.never_show_rescue_dialog",
289  &m_RescueNeverShow, false ) );
290 
291  m_params.emplace_back( new PARAM<int>( "lib_view.window.pos_x",
292  &m_LibViewPanel.window.pos_x, 0 ) );
293 
294  m_params.emplace_back( new PARAM<int>( "lib_view.window.pos_y",
295  &m_LibViewPanel.window.pos_y, 0 ) );
296 
297  m_params.emplace_back( new PARAM<int>( "lib_view.window.size_x",
298  &m_LibViewPanel.window.size_x, 500 ) );
299 
300  m_params.emplace_back( new PARAM<int>( "lib_view.window.size_y",
301  &m_LibViewPanel.window.size_y, 400 ) );
302 
303  m_params.emplace_back( new PARAM<bool>( "lib_view.window.maximized",
304  &m_LibViewPanel.window.maximized, false ) );
305 
306  m_params.emplace_back( new PARAM<wxString>( "lib_view.window.perspective",
308 
309  m_params.emplace_back( new PARAM<int>( "lib_view.lib_list_width",
310  &m_LibViewPanel.lib_list_width, 150 ) );
311 
312  m_params.emplace_back( new PARAM<int>( "lib_view.cmp_list_width",
313  &m_LibViewPanel.cmp_list_width, 150 ) );
314 
315  m_params.emplace_back( new PARAM<bool>( "lib_view.show_pin_electrical_type",
317 }
318 
319 
320 bool EESCHEMA_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
321 {
322  bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
323 
324  ret &= fromLegacy<bool>( aCfg, "FootprintPreview", "appearance.footprint_preview" );
325  ret &= fromLegacy<bool>( aCfg, "NavigatorStaysOpen", "appearance.navigator_stays_open" );
326  ret &= fromLegacy<bool>( aCfg, "PrintSheetReferenceAndTitleBlock",
327  "appearance.print_sheet_reference" );
328  ret &= fromLegacy<bool>( aCfg, "ShowHiddenPins", "appearance.show_hidden_pins" );
329  ret &= fromLegacy<bool>( aCfg, "ShowIllegalSymbolLibDialog",
330  "appearance.show_illegal_symbol_lib_dialog" );
331  ret &= fromLegacy<bool>( aCfg, "ShowPageLimits", "appearance.show_page_limits" );
332  ret &= fromLegacy<bool>( aCfg, "ShowSheetFileNameCaseSensitivityDlg",
333  "appearance.show_sheet_filename_case_sensitivity_dialog" );
334 
335  ret &= fromLegacy<bool>( aCfg, "AutoplaceFields", "autoplace_fields.enable" );
336  ret &= fromLegacy<bool>( aCfg, "AutoplaceJustify", "autoplace_fields.allow_rejustify" );
337  ret &= fromLegacy<bool>( aCfg, "AutoplaceAlign", "autoplace_fields.align_to_grid" );
338 
339  ret &= fromLegacy<int>( aCfg, "DefaultBusWidth", "drawing.default_bus_thickness" );
340  ret &= fromLegacy<int>( aCfg, "DefaultJunctionSize", "drawing.default_junction_size" );
341  ret &= fromLegacy<int>( aCfg, "DefaultDrawLineWidth", "drawing.default_line_thickness" );
342  ret &= fromLegacy<int>( aCfg, "RepeatStepX", "drawing.default_repeat_offset_x" );
343  ret &= fromLegacy<int>( aCfg, "RepeatStepY", "drawing.default_repeat_offset_y" );
344  ret &= fromLegacy<int>( aCfg, "DefaultWireWidth", "drawing.default_wire_thickness" );
345  ret &= fromLegacyString( aCfg, "FieldNames", "drawing.field_names" );
346  ret &= fromLegacy<bool>( aCfg, "HorizVertLinesOnly", "drawing.hv_lines_only" );
347  ret &= fromLegacy<int>( aCfg, "RepeatLabelIncrement", "drawing.repeat_label_increment" );
348 
349  ret &= fromLegacy<bool>( aCfg, "DragActionIsMove", "input.drag_is_move" );
350 
351  ret &= fromLegacy<int>( aCfg, "SelectionThickness", "selection.thickness" );
352  ret &= fromLegacy<bool>( aCfg, "SelectionDrawChildItems", "selection.draw_selected_children" );
353  ret &= fromLegacy<bool>( aCfg, "SelectionFillShapes", "selection.fill_shapes" );
354  ret &= fromLegacy<bool>( aCfg, "SelectPinSelectSymbolOpt",
355  "selection.select_pin_selects_symbol" );
356  ret &= fromLegacy<bool>( aCfg, "SelectionTextAsBox", "selection.text_as_box" );
357 
358  ret &= fromLegacy<int>( aCfg, "AnnotateAlgoOption", "annotation.method" );
359  ret &= fromLegacy<int>( aCfg, "AnnotateFilterMsg", "annotation.messages_filter" );
360  ret &= fromLegacy<int>( aCfg, "AnnotateSortOption", "annotation.sort_order" );
361 
362  ret &= fromLegacyString( aCfg, "bom_plugin_selected", "bom.selected_plugin" );
363  ret &= fromLegacyString( aCfg, "bom_plugins", "bom.plugins" );
364 
365  ret &= fromLegacyString( aCfg, "SymbolFieldsShownColumns",
366  "edit_sch_component.visible_columns" );
367 
368  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportRevision", "page_settings.export_revision" );
369  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportDate", "page_settings.export_date" );
370  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportTitle", "page_settings.export_title" );
371  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportCompany", "page_settings.export_company" );
372  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment1", "page_settings.export_comment1" );
373  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment2", "page_settings.export_comment2" );
374  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment3", "page_settings.export_comment3" );
375  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment4", "page_settings.export_comment4" );
376  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment5", "page_settings.export_comment5" );
377  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment6", "page_settings.export_comment6" );
378  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment7", "page_settings.export_comment7" );
379  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment8", "page_settings.export_comment8" );
380  ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment9", "page_settings.export_comment9" );
381 
382  {
383  constexpr int max_custom_commands = 8; // from DIALOG_NETLIST
384  nlohmann::json js_cmd = nlohmann::json::array();
385  nlohmann::json js_title = nlohmann::json::array();
386  wxString cmd_key, title_key, cmd, title;
387 
388  for( int i = 1; i <= max_custom_commands; ++i )
389  {
390  // Only migrate if both title and command are specified
391  cmd_key.Printf( "CustomNetlistCommand%d", i );
392  title_key.Printf( "CustomNetlistTitle%d", i );
393 
394  if( aCfg->Read( cmd_key, &cmd ) && aCfg->Read( title_key, &title )
395  && !cmd.IsEmpty() && !title.IsEmpty() )
396  {
397  js_cmd.push_back( cmd.ToUTF8() );
398  js_title.push_back( title.ToUTF8() );
399  }
400  }
401 
402  ( *this )[PointerFromString( "netlist.custom_command_titles" )] = js_title;
403  ( *this )[PointerFromString( "netlist.custom_command_paths" )] = js_cmd;
404  }
405 
406  {
407  // NOTE(JE) These parameters should move to project-local storage before V6, but we are
408  // migrating them here in order to preserve data. There is a bug here that is preserved:
409  // keys are taken directly from the (translated) UI and stored in the config, so if the user
410  // changes languages the keys will no longer work.
411  aCfg->SetPath( "SymbolFieldEditor/Show/" );
412 
413  nlohmann::json js = nlohmann::json( {} );
414  wxString key;
415  bool value = false;
416  long index = 0;
417 
418  while( aCfg->GetNextEntry( key, index ) )
419  {
420  if( aCfg->Read( key, &value ) )
421  {
422  std::string key_utf( key.ToUTF8() );
423  js[PointerFromString( key_utf )] = value;
424  }
425  }
426 
427  ( *this )[PointerFromString( "field_editor.fields_show" ) ] = js;
428 
429  aCfg->SetPath( "../GroupBy" );
430 
431  while( aCfg->GetNextEntry( key, index ) )
432  {
433  if( aCfg->Read( key, &value ) )
434  {
435  std::string key_utf( key.ToUTF8() );
436  js[PointerFromString( key_utf )] = value;
437  }
438  }
439 
440  ( *this )[PointerFromString( "field_editor.fields_group_by" ) ] = js;
441 
442  aCfg->SetPath( "../.." );
443  }
444 
445  ret &= fromLegacy<bool>( aCfg, "PlotModeColor", "plot.color" );
446  ret &= fromLegacy<int>( aCfg, "PlotFormat", "plot.format" );
447  ret &= fromLegacy<bool>( aCfg, "PlotFrameRef", "plot.frame_reference" );
448  ret &= fromLegacy<bool>( aCfg, "PlotHPGLOrg", "plot.hpgl_origin" );
449  ret &= fromLegacy<int>( aCfg, "PlotHPGLPaperSize", "plot.hpgl_paper_size" );
450  ret &= fromLegacy<double>( aCfg, "PlotHPGLPenSize", "plot.hpgl_pen_size" );
451 
452  ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_x", "simulator.window.pos_x" );
453  ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_y", "simulator.window.pos_y" );
454  ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_x", "simulator.window.size_x" );
455  ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_y", "simulator.window.size_y" );
456  ret &= fromLegacy<bool>( aCfg, "SIM_PLOT_FRAMEMaximized", "simulator.window.maximized" );
457  ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEPerspective", "simulator.window.perspective" );
458  ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEMostRecentlyUsedPath", "simulator.mru_path" );
459  ret &= fromLegacy<int>( aCfg, "SimPlotPanelWidth", "simulator.plot_panel_width" );
460  ret &= fromLegacy<int>( aCfg, "SimPlotPanelHeight", "simulator.plot_panel_height" );
461  ret &= fromLegacy<int>( aCfg, "SimSignalPanelHeight", "simulator.signal_panel_height" );
462  ret &= fromLegacy<int>( aCfg, "SimCursorsPanelHeight", "simulator.cursors_panel_height" );
463  ret &= fromLegacy<bool>( aCfg, "SimPlotWhiteBg", "simulator.white_background" );
464 
465  ret &= fromLegacy<int>( aCfg, "SymbolChooserHSashPosition", "symbol_chooser.sash_pos_h" );
466  ret &= fromLegacy<int>( aCfg, "SymbolChooserVSashPosition", "symbol_chooser.sash_pos_v" );
467  ret &= fromLegacy<int>( aCfg, "SymbolChooserWidth", "symbol_chooser.width" );
468  ret &= fromLegacy<int>( aCfg, "SymbolChooserHeight", "symbol_chooser.height" );
469  ret &= fromLegacy<bool>( aCfg, "SymbolChooserKeepSymbol", "symbol_chooser.keep_symbol" );
470  ret &= fromLegacy<bool>( aCfg, "SymbolChooserUseUnits", "symbol_chooser.place_all_units" );
471 
472  const std::string vlf = "ViewlibFrame";
473  ret &= fromLegacy<bool>( aCfg, vlf + "Maximized", "lib_view.window.maximized" );
474  ret &= fromLegacyString( aCfg, vlf + "MostRecentlyUsedPath", "lib_view.window.mru_path" );
475  ret &= fromLegacy<int>( aCfg, vlf + "Size_x", "lib_view.window.size_x" );
476  ret &= fromLegacy<int>( aCfg, vlf + "Size_y", "lib_view.window.size_y" );
477  ret &= fromLegacyString( aCfg, vlf + "Perspective", "lib_view.window.perspective" );
478  ret &= fromLegacy<int>( aCfg, vlf + "Pos_x", "lib_view.window.pos_x" );
479  ret &= fromLegacy<int>( aCfg, vlf + "Pos_y", "lib_view.window.pos_y" );
480  ret &= fromLegacy<int>( aCfg, "ViewLiblistWidth", "lib_view.lib_list_width" );
481  ret &= fromLegacy<int>( aCfg, "ViewCmplistWidth", "lib_view.cmp_list_width" );
482  ret &= fromLegacy<bool>( aCfg,
483  "ViewCmpShowPinElectricalType", "lib_view.show_pin_electrical_type" );
484  ret &= fromLegacy<bool>( aCfg, vlf + "ShowGrid", "lib_view.grid.show" );
485  ret &= fromLegacy<int>( aCfg, vlf + "_LastGridSize", "lib_view.grid.last_size" );
486 
487  ret &= fromLegacy<bool>( aCfg, "RescueNeverShow", "system.never_show_rescue_dialog" );
488 
489  // Legacy version stored this setting in eeschema, so move it to common if it exists
490  aCfg->Read( "MoveWarpsCursor", &Pgm().GetCommonSettings()->m_Input.warp_mouse_on_move );
491 
492  COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
493 
494  auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) {
495  wxString str;
496 
497  if( aCfg->Read( aKey, &str ) )
498  cs->SetColor( aLayerId, COLOR4D( str ) );
499  };
500 
501  migrateLegacyColor( "Color4DBgCanvasEx", LAYER_SCHEMATIC_BACKGROUND );
502  migrateLegacyColor( "Color4DBodyBgEx", LAYER_DEVICE_BACKGROUND );
503  migrateLegacyColor( "Color4DBodyEx", LAYER_DEVICE );
504  migrateLegacyColor( "Color4DBrightenedEx", LAYER_BRIGHTENED );
505  migrateLegacyColor( "Color4DBusEx", LAYER_BUS );
506  migrateLegacyColor( "Color4DConnEx", LAYER_JUNCTION );
507  migrateLegacyColor( "Color4DCursorEx", LAYER_SCHEMATIC_CURSOR );
508  migrateLegacyColor( "Color4DErcEEx", LAYER_ERC_ERR );
509  migrateLegacyColor( "Color4DErcWEx", LAYER_ERC_WARN );
510  migrateLegacyColor( "Color4DFieldEx", LAYER_FIELDS );
511  migrateLegacyColor( "Color4DGLabelEx", LAYER_GLOBLABEL );
512  migrateLegacyColor( "Color4DGridEx", LAYER_SCHEMATIC_GRID );
513  migrateLegacyColor( "Color4DHLabelEx", LAYER_HIERLABEL );
514  migrateLegacyColor( "Color4DHiddenEx", LAYER_HIDDEN );
515  migrateLegacyColor( "Color4DLLabelEx", LAYER_LOCLABEL );
516  migrateLegacyColor( "Color4DNetNameEx", LAYER_NETNAM );
517  migrateLegacyColor( "Color4DNoConnectEx", LAYER_NOCONNECT );
518  migrateLegacyColor( "Color4DNoteEx", LAYER_NOTES );
519  migrateLegacyColor( "Color4DPinEx", LAYER_PIN );
520  migrateLegacyColor( "Color4DPinNameEx", LAYER_PINNAM );
521  migrateLegacyColor( "Color4DPinNumEx", LAYER_PINNUM );
522  migrateLegacyColor( "Color4DReferenceEx", LAYER_REFERENCEPART );
523  migrateLegacyColor( "Color4DShadowEx", LAYER_SELECTION_SHADOWS );
524  migrateLegacyColor( "Color4DSheetEx", LAYER_SHEET );
525  migrateLegacyColor( "Color4DSheetFileNameEx", LAYER_SHEETFILENAME );
526  migrateLegacyColor( "Color4DSheetLabelEx", LAYER_SHEETLABEL );
527  migrateLegacyColor( "Color4DSheetNameEx", LAYER_SHEETNAME );
528  migrateLegacyColor( "Color4DValueEx", LAYER_VALUEPART );
529  migrateLegacyColor( "Color4DWireEx", LAYER_WIRE );
530  migrateLegacyColor( "Color4DWorksheetEx", LAYER_SCHEMATIC_WORKSHEET );
531 
532  Pgm().GetSettingsManager().SaveColorSettings( cs, "schematic" );
533 
534  // LibEdit settings were stored with eeschema. If eeschema is the first app to run,
535  // we need to migrate the LibEdit settings here
536 
537  auto libedit = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>( false );
538  libedit->MigrateFromLegacy( aCfg );
539  libedit->Load();
540 
541  return ret;
542 }
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:445
Definition: colors.h:61
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:58
AUTOPLACE_FIELDS m_AutoplaceFields
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:73
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.
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)
Definition: colors.h:49
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.
void SetColor(int aLayer, COLOR4D aColor)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40