KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
app_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 Jon Evans <jon@craftyjon.com>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
22#include <common.h>
23#include <eda_units.h>
24#include <layer_ids.h>
25#include <pgm_base.h>
31#include <settings/parameters.h>
32
33
34APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaVersion ) :
35 JSON_SETTINGS( aFilename, SETTINGS_LOC::USER, aSchemaVersion ),
36 m_CrossProbing(),
37 m_FindReplace(),
38 m_Graphics(),
39 m_ColorPicker(),
40 m_LibTree(),
41 m_Printing(),
42 m_SearchPane(),
43 m_System(),
44 m_Plugins(),
45 m_Window(),
46 m_CustomToolbars( false ),
47 m_appSettingsSchemaVersion( aSchemaVersion )
48{
49 // Make Coverity happy:
51
52 // Build parameters list:
53 m_params.emplace_back(
54 new PARAM<int>( "find_replace.match_mode", &m_FindReplace.match_mode, 0 ) );
55
56 m_params.emplace_back(
57 new PARAM<bool>( "find_replace.match_case", &m_FindReplace.match_case, false ) );
58
59 m_params.emplace_back( new PARAM<bool>( "find_replace.search_and_replace",
61
62 m_params.emplace_back( new PARAM<wxString>( "find_replace.find_string",
63 &m_FindReplace.find_string, wxS( "" ) ) );
64
65 m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.find_history",
67
68 m_params.emplace_back( new PARAM<wxString>( "find_replace.replace_string",
70
71 m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.replace_history",
73
74 m_params.emplace_back( new PARAM<int>( "design_block_chooser.sash_pos_h",
76
77 m_params.emplace_back( new PARAM<int>( "design_block_chooser.sash_pos_v",
79
80 m_params.emplace_back( new PARAM<int>( "design_block_chooser.width",
82
83 m_params.emplace_back( new PARAM<int>( "design_block_chooser.height",
85
86 m_params.emplace_back( new PARAM<int>( "design_block_chooser.sort_mode",
88
89 m_params.emplace_back( new PARAM<bool>( "design_block_chooser.repeated_placement",
91
92 m_params.emplace_back( new PARAM<bool>( "design_block_chooser.place_as_sheet",
94
95 m_params.emplace_back( new PARAM<bool>( "design_block_chooser.keep_annotations",
97
98 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>(
99 "design_block_chooser.lib_tree.column_widths",
100 [&]() -> nlohmann::json
101 {
102 nlohmann::json ret = {};
103
104 for( const auto& [name, width] : m_DesignBlockChooserPanel.tree.column_widths )
105 ret[std::string( name.ToUTF8() )] = width;
106
107 return ret;
108 },
109 [&]( const nlohmann::json& aJson )
110 {
111 if( !aJson.is_object() )
112 return;
113
115
116 for( const auto& entry : aJson.items() )
117 {
118 if( !entry.value().is_number_integer() )
119 continue;
120
121 m_DesignBlockChooserPanel.tree.column_widths[entry.key()] = entry.value().get<int>();
122 }
123 },
124 {} ) );
125
126
127 m_params.emplace_back( new PARAM<int>( "graphics.canvas_type",
129
130 m_params.emplace_back( new PARAM<float>( "graphics.highlight_factor",
131 &m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) );
132
133 m_params.emplace_back( new PARAM<float>( "graphics.select_factor",
134 &m_Graphics.select_factor, 0.75f, 0.0, 1.0f ) );
135
136 m_params.emplace_back( new PARAM<int>( "color_picker.default_tab",
138
139 m_params.emplace_back( new PARAM_LIST<wxString>( "lib_tree.columns", &m_LibTree.columns, {} ) );
140
141 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "lib_tree.column_widths",
142 [&]() -> nlohmann::json
143 {
144 nlohmann::json ret = {};
145
146 for( const std::pair<const wxString, int>& pair : m_LibTree.column_widths )
147 ret[std::string( pair.first.ToUTF8() )] = pair.second;
148
149 return ret;
150 },
151 [&]( const nlohmann::json& aJson )
152 {
153 if( !aJson.is_object() )
154 return;
155
156 m_LibTree.column_widths.clear();
157
158 for( const auto& entry : aJson.items() )
159 {
160 if( !entry.value().is_number_integer() )
161 continue;
162
163 m_LibTree.column_widths[ entry.key() ] = entry.value().get<int>();
164 }
165 },
166 {} ) );
167
168 m_params.emplace_back(
169 new PARAM_LIST<wxString>( "lib_tree.open_libs", &m_LibTree.open_libs, {} ) );
170
171 m_params.emplace_back( new PARAM<bool>( "printing.background",
172 &m_Printing.background, false ) );
173
174 m_params.emplace_back( new PARAM<bool>( "printing.monochrome",
175 &m_Printing.monochrome, true ) );
176
177 m_params.emplace_back( new PARAM<double>( "printing.scale",
178 &m_Printing.scale, 1.0 ) );
179
180 m_params.emplace_back( new PARAM<bool>( "printing.use_theme",
181 &m_Printing.use_theme, false ) );
182
183 m_params.emplace_back( new PARAM<wxString>( "printing.color_theme",
184 &m_Printing.color_theme, wxS( "" ) ) );
185
186 m_params.emplace_back( new PARAM<bool>( "printing.title_block",
187 &m_Printing.title_block, false ) );
188
189 m_params.emplace_back( new PARAM_LIST<int>( "printing.layers",
190 &m_Printing.layers, {} ) );
191
192 m_params.emplace_back( new PARAM<int>( "search_pane.selection_zoom",
193 reinterpret_cast<int*>( &m_SearchPane.selection_zoom ),
194 static_cast<int>( SEARCH_PANE::SELECTION_ZOOM::PAN ) ) );
195
196 m_params.emplace_back( new PARAM<bool>( "system.first_run_shown",
197 &m_System.first_run_shown, false ) ); //@todo RFB remove? - not used
198
199 m_params.emplace_back( new PARAM<int>( "system.max_undo_items",
200 &m_System.max_undo_items, 0 ) );
201
202 m_params.emplace_back( new PARAM_LIST<wxString>( "system.file_history",
203 &m_System.file_history, {} ) );
204
205 if( m_filename == wxS( "pl_editor" )
206 || ( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) ) )
207 {
208 m_params.emplace_back( new PARAM<int>( "system.units",
209 &m_System.units, static_cast<int>( EDA_UNITS::MILS ) ) );
210 }
211 else
212 {
213 m_params.emplace_back( new PARAM<int>( "system.units",
214 &m_System.units, static_cast<int>( EDA_UNITS::MM ) ) );
215 }
216
217 m_params.emplace_back( new PARAM<int>( "system.last_metric_units",
218 &m_System.last_metric_units, static_cast<int>( EDA_UNITS::MM ) ) );
219
220 m_params.emplace_back( new PARAM<int>( "system.last_imperial_units",
221 &m_System.last_imperial_units, static_cast<int>( EDA_UNITS::MILS ) ) );
222
223 m_params.emplace_back( new PARAM<bool>( "system.show_import_issues",
224 &m_System.show_import_issues, true ) );
225
226 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "plugins.actions",
227 [&]() -> nlohmann::json
228 {
229 nlohmann::json js = nlohmann::json::array();
230
231 for( const auto& [identifier, visible] : m_Plugins.actions )
232 js.push_back( nlohmann::json( { { identifier.ToUTF8(), visible } } ) );
233
234 return js;
235 },
236 [&]( const nlohmann::json& aObj )
237 {
238 m_Plugins.actions.clear();
239
240 if( !aObj.is_array() )
241 {
242 return;
243 }
244
245 for( const auto& entry : aObj )
246 {
247 if( entry.empty() || !entry.is_object() )
248 continue;
249
250 for( const auto& pair : entry.items() )
251 {
252 m_Plugins.actions.emplace_back( std::make_pair(
253 wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) );
254 }
255 }
256 },
257 nlohmann::json::array() ) );
258
259 m_params.emplace_back( new PARAM<wxString>( "appearance.color_theme",
260 &m_ColorTheme, COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT ) );
261
262 m_params.emplace_back( new PARAM<bool>( "appearance.custom_toolbars",
263 &m_CustomToolbars, false ) );
264
265 addParamsForWindow( &m_Window, "window" );
266
267 m_params.emplace_back( new PARAM<bool>( "cross_probing.on_selection",
268 &m_CrossProbing.on_selection, true ) );
269
270 m_params.emplace_back( new PARAM<bool>( "cross_probing.center_on_items",
271 &m_CrossProbing.center_on_items, true ) );
272
273 m_params.emplace_back( new PARAM<bool>( "cross_probing.zoom_to_fit",
274 &m_CrossProbing.zoom_to_fit, true ) );
275
276 m_params.emplace_back( new PARAM<bool>( "cross_probing.auto_highlight",
277 &m_CrossProbing.auto_highlight, true ) );
278}
279
280
281bool APP_SETTINGS_BASE::MigrateFromLegacy( wxConfigBase* aCfg )
282{
283 bool ret = true;
284
285 const std::string f = getLegacyFrameName();
286
287 ret &= fromLegacyString( aCfg, "LastFindString", "find_replace.find_string" );
288 ret &= fromLegacyString( aCfg, "LastReplaceString", "find_replace.replace_string" );
289
290 migrateFindReplace( aCfg );
291
292 ret &= fromLegacy<int>( aCfg, "canvas_type", "graphics.canvas_type" );
293
294 ret &= fromLegacy<int>( aCfg, "P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth",
295 "lib_tree.column_width" );
296
297 ret &= fromLegacy<bool>( aCfg, "PrintMonochrome", "printing.monochrome" );
298 ret &= fromLegacy<double>( aCfg, "PrintScale", "printing.scale" );
299 ret &= fromLegacy<bool>( aCfg, "PrintPageFrame", "printing.title_block" );
300
301 {
302 nlohmann::json js = nlohmann::json::array();
303 wxString key;
304 bool val = false;
305
306 for( unsigned i = 0; i < PCB_LAYER_ID_COUNT; ++i )
307 {
308 key.Printf( wxT( "PlotLayer_%d" ), i );
309
310 if( aCfg->Read( key, &val ) && val )
311 js.push_back( i );
312 }
313
314 Set( "printing.layers", js );
315 }
316
317 ret &= fromLegacy<bool>( aCfg, f + "FirstRunShown", "system.first_run_shown" );
318 ret &= fromLegacy<int>( aCfg, f + "DevelMaxUndoItems", "system.max_undo_items" );
319 ret &= fromLegacy<int>( aCfg, f + "Units", "system.units" );
320
321 {
322 int max_history_size = Pgm().GetCommonSettings()->m_System.file_history_size;
323 wxString file, key;
324 nlohmann::json js = nlohmann::json::array();
325
326 for( int i = 1; i <= max_history_size; i++ )
327 {
328 key.Printf( "file%d", i );
329 file = aCfg->Read( key, wxEmptyString );
330
331 if( !file.IsEmpty() )
332 js.push_back( file.ToStdString() );
333 }
334
335 Set( "system.file_history", js );
336 }
337
338 ret &= migrateWindowConfig( aCfg, f, "window" );
339
340 return ret;
341}
342
343
345{
346 const int find_replace_history_size = 10;
347 nlohmann::json find_history = nlohmann::json::array();
348 nlohmann::json replace_history = nlohmann::json::array();
349 wxString tmp, find_key, replace_key;
350
351 for( int i = 0; i < find_replace_history_size; ++i )
352 {
353 find_key.Printf( "FindStringHistoryList%d", i );
354 replace_key.Printf( "ReplaceStringHistoryList%d", i );
355
356 if( aCfg->Read( find_key, &tmp ) )
357 find_history.push_back( tmp.ToStdString() );
358
359 if( aCfg->Read( replace_key, &tmp ) )
360 replace_history.push_back( tmp.ToStdString() );
361 }
362
363 Set( "find_replace.find_history", find_history );
364 Set( "find_replace.replace_history", replace_history );
365}
366
367
368bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::string& aFrame,
369 const std::string& aJsonPath )
370{
371 bool ret = true;
372
373 const std::string frameGDO = aFrame + "GalDisplayOptions";
374 const std::string cursorPath = aJsonPath + ".cursor";
375 const std::string gridPath = aJsonPath + ".grid";
376
377 ret &= fromLegacy<bool>( aCfg, aFrame + "Maximized", aJsonPath + ".maximized" );
378 ret &= fromLegacyString( aCfg, aFrame + "MostRecentlyUsedPath", aJsonPath + ".mru_path" );
379 ret &= fromLegacy<int>( aCfg, aFrame + "Size_x", aJsonPath + ".size_x" );
380 ret &= fromLegacy<int>( aCfg, aFrame + "Size_y", aJsonPath + ".size_y" );
381 ret &= fromLegacyString( aCfg, aFrame + "Perspective", aJsonPath + ".perspective" );
382 ret &= fromLegacy<int>( aCfg, aFrame + "Pos_x", aJsonPath + ".pos_x" );
383 ret &= fromLegacy<int>( aCfg, aFrame + "Pos_y", aJsonPath + ".pos_y" );
384
385 ret &= fromLegacy<bool>( aCfg, frameGDO + "ForceDisplayCursor",
386 cursorPath + ".always_show_cursor" );
387 ret &= fromLegacy<bool>( aCfg, frameGDO + "CursorFullscreen",
388 cursorPath + ".fullscreen_cursor" );
389
390 ret &= fromLegacy<int>( aCfg, aFrame + "_LastGridSize", gridPath + ".last_size" );
391
392 ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid1", gridPath + ".fast_grid_1" );
393 ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid2", gridPath + ".fast_grid_2" );
394
395 ret &= fromLegacy<bool>( aCfg, frameGDO + "GridAxesEnabled", gridPath + ".axes_enabled" );
396 ret &= fromLegacy<double>( aCfg, frameGDO + "GridLineWidth", gridPath + ".line_width" );
397 ret &= fromLegacy<double>( aCfg, frameGDO + "GridMaxDensity", gridPath + ".min_spacing" );
398 ret &= fromLegacy<bool>( aCfg, frameGDO + "ShowGrid", gridPath + ".show" );
399 ret &= fromLegacy<int>( aCfg, frameGDO + "GridStyle", gridPath + ".style" );
400 ret &= fromLegacyColor( aCfg, frameGDO + "GridColor", gridPath + ".color" );
401
402 return ret;
403}
404
405
406void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std::string& aJsonPath )
407{
408 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".maximized",
409 &aWindow->state.maximized, false ) );
410
411 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".mru_path",
412 &aWindow->mru_path, wxS( "" ) ) );
413
414 m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_x", &aWindow->state.size_x, 0 ) );
415
416 m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_y", &aWindow->state.size_y, 0 ) );
417
418 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".perspective",
419 &aWindow->perspective, wxS( "" ) ) );
420
421 m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_x", &aWindow->state.pos_x, 0 ) );
422
423 m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_y", &aWindow->state.pos_y, 0 ) );
424
425 m_params.emplace_back( new PARAM<unsigned int>( aJsonPath + ".display",
426 &aWindow->state.display, 0 ) );
427
428 m_params.emplace_back( new PARAM_LIST<double>( aJsonPath + ".zoom_factors",
429 &aWindow->zoom_factors, {} ) );
430
431 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.axes_enabled",
432 &aWindow->grid.axes_enabled, false ) );
433
434 int defaultGridIdx;
435
436 if( ( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) ) )
437 {
438 defaultGridIdx = 1;
439 }
440 else if( m_filename == wxS( "pl_editor" ) )
441 {
442 defaultGridIdx = 4;
443 }
444 else
445 {
446 defaultGridIdx = 15;
447 }
448
449 m_params.emplace_back( new PARAM_LIST<GRID>( aJsonPath + ".grid.sizes", &aWindow->grid.grids,
451
452 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.last_size",
453 &aWindow->grid.last_size_idx, defaultGridIdx ) );
454
455 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_1",
456 &aWindow->grid.fast_grid_1, defaultGridIdx ) );
457
458 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_2",
459 &aWindow->grid.fast_grid_2, defaultGridIdx + 1 ) );
460
461 // legacy values, leave blank by default so we don't convert them
462 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_x",
463 &aWindow->grid.user_grid_x, wxEmptyString ) );
464 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_y",
465 &aWindow->grid.user_grid_y, wxEmptyString ) );
466
467 // for grid overrides, give just the schematic and symbol editors sane values
468 if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
469 {
470 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.overrides_enabled",
471 &aWindow->grid.overrides_enabled, true ) );
472 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_connected",
473 &aWindow->grid.override_connected, true ) );
474 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_wires",
475 &aWindow->grid.override_wires, true ) );
476 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_vias",
477 &aWindow->grid.override_vias, false ) );
478 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_text",
479 &aWindow->grid.override_text, true ) );
480 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_graphics",
481 &aWindow->grid.override_graphics, false ) );
482
483 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_connected_idx",
484 &aWindow->grid.override_connected_idx, 1 ) );
485 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_wires_idx",
486 &aWindow->grid.override_wires_idx, 1 ) );
487 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_vias_idx",
488 &aWindow->grid.override_vias_idx, 0 ) );
489 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_text_idx",
490 &aWindow->grid.override_text_idx, 3 ) );
491 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_graphics_idx",
492 &aWindow->grid.override_graphics_idx, 2 ) );
493 }
494 else
495 {
496 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.overrides_enabled",
497 &aWindow->grid.overrides_enabled, true ) );
498 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_connected",
499 &aWindow->grid.override_connected, false ) );
500 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_wires",
501 &aWindow->grid.override_wires, false ) );
502 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_vias",
503 &aWindow->grid.override_vias, false ) );
504 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_text",
505 &aWindow->grid.override_text, false ) );
506 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_graphics",
507 &aWindow->grid.override_graphics, false ) );
508
509 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_connected_idx",
510 &aWindow->grid.override_connected_idx, 16 ) );
511 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_text_idx",
512 &aWindow->grid.override_text_idx, 18 ) );
513 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_wires_idx",
514 &aWindow->grid.override_wires_idx, 19 ) );
515 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_vias_idx",
516 &aWindow->grid.override_vias_idx, 18 ) );
517 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_graphics_idx",
518 &aWindow->grid.override_graphics_idx, 15 ) );
519 }
520
521 m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.line_width",
522 &aWindow->grid.line_width, 1.0 ) );
523
524 m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.min_spacing",
525 &aWindow->grid.min_spacing, 10 ) );
526
527 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.show",
528 &aWindow->grid.show, true ) );
529
530 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style",
531 &aWindow->grid.style, 0 ) );
532
533 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.snap",
534 &aWindow->grid.snap, 0 ) );
535
536 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.always_show_cursor",
537 &aWindow->cursor.always_show_cursor, true ) );
538
539 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.fullscreen_cursor",
540 &aWindow->cursor.fullscreen_cursor, false ) );
541}
542
543
544const std::vector<GRID> APP_SETTINGS_BASE::DefaultGridSizeList() const
545{
546 if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
547 {
548 return { GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
549 GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
550 GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
551 GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) } };
552 }
553 else
554 {
555 return { GRID{ wxEmptyString, wxS( "1000 mil" ), wxS( "1000 mil" ) },
556 GRID{ wxEmptyString, wxS( "500 mil" ), wxS( "500 mil" ) },
557 GRID{ wxEmptyString, wxS( "250 mil" ), wxS( "250 mil" ) },
558 GRID{ wxEmptyString, wxS( "200 mil" ), wxS( "200 mil" ) },
559 GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
560 GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
561 GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
562 GRID{ wxEmptyString, wxS( "20 mil" ), wxS( "20 mil" ) },
563 GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) },
564 GRID{ wxEmptyString, wxS( "5 mil" ), wxS( "5 mil" ) },
565 GRID{ wxEmptyString, wxS( "2 mil" ), wxS( "2 mil" ) },
566 GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) },
567 GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) },
568 GRID{ wxEmptyString, wxS( "2.5 mm" ), wxS( "2.5 mm" ) },
569 GRID{ wxEmptyString, wxS( "1.0 mm" ), wxS( "1.0 mm" ) },
570 GRID{ wxEmptyString, wxS( "0.5 mm" ), wxS( "0.5 mm" ) },
571 GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) },
572 GRID{ wxEmptyString, wxS( "0.2 mm" ), wxS( "0.2 mm" ) },
573 GRID{ wxEmptyString, wxS( "0.1 mm" ), wxS( "0.1 mm" ) },
574 GRID{ wxEmptyString, wxS( "0.05 mm" ), wxS( "0.05 mm" ) },
575 GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.025 mm" ) },
576 GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.01 mm" ) } };
577 }
578}
579
580
582{
583 // We used to store only the width of the first column, because there were only
584 // two possible columns.
585 if( std::optional<int> optWidth = Get<int>( "lib_tree.column_width" ) )
586 {
587 Set<nlohmann::json>( "lib_tree.column_widths", { { "Item", *optWidth } } );
588 At( "lib_tree" ).erase( "column_width" );
589 }
590
591 return true;
592}
const char * name
Definition: DXF_plotter.cpp:59
APP_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
FIND_REPLACE m_FindReplace
Definition: app_settings.h:195
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
Definition: app_settings.h:197
COLOR_PICKER m_ColorPicker
Definition: app_settings.h:201
virtual std::string getLegacyFrameName() const
Definition: app_settings.h:227
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath)
Add parameters for the given window object.
bool migrateLibTreeWidth()
Migrate the library tree width setting from a single column (Item) to multi-column.
static const wxString COLOR_BUILTIN_DEFAULT
@ GAL_TYPE_OPENGL
OpenGL implementation.
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.
Definition: parameters.h:295
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:687
The common library.
template KICOMMON_API void JSON_SETTINGS::Set< nlohmann::json >(const std::string &aPath, nlohmann::json aValue)
SETTINGS_LOC
Definition: json_settings.h:54
@ USER
The main config directory (e.g. ~/.config/kicad/)
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:171
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1071
see class PGM_BASE
std::vector< wxString > replace_history
Definition: app_settings.h:99
std::vector< wxString > find_history
Definition: app_settings.h:97
float highlight_factor
How much to brighten highlighted objects by.
Definition: app_settings.h:122
float select_factor
How much to brighten selected objects by.
Definition: app_settings.h:123
std::vector< wxString > columns
Ordered list of visible columns in the tree.
Definition: app_settings.h:133
std::map< wxString, int > column_widths
Column widths, keyed by header name.
Definition: app_settings.h:134
std::vector< wxString > open_libs
list of libraries the user has open in the tree.
Definition: app_settings.h:135
bool always_show_cursor
Definition: app_settings.h:44
bool fullscreen_cursor
Definition: app_settings.h:45
wxString user_grid_x
Definition: grid_settings.h:67
int override_connected_idx
Definition: grid_settings.h:80
double line_width
Definition: grid_settings.h:72
bool overrides_enabled
Definition: grid_settings.h:78
bool override_graphics
Definition: grid_settings.h:87
bool override_connected
Definition: grid_settings.h:79
std::vector< GRID > grids
Definition: grid_settings.h:66
int override_graphics_idx
Definition: grid_settings.h:88
int override_wires_idx
Definition: grid_settings.h:82
wxString user_grid_y
Definition: grid_settings.h:68
double min_spacing
Definition: grid_settings.h:73
Common grid settings, available to every frame.
Definition: grid_settings.h:34
Store the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:74
CURSOR_SETTINGS cursor
Definition: app_settings.h:80
WINDOW_STATE state
Definition: app_settings.h:75
GRID_SETTINGS grid
Definition: app_settings.h:81
wxString mru_path
Definition: app_settings.h:76
std::vector< double > zoom_factors
Definition: app_settings.h:78
wxString perspective
Definition: app_settings.h:77
unsigned int display
Definition: app_settings.h:67