KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <[email protected]>
5 * Copyright (C) 2020-2023 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_appSettingsSchemaVersion( aSchemaVersion )
47{
48 // Make Coverity happy:
50
51 // Build parameters list:
52 m_params.emplace_back(
53 new PARAM<int>( "find_replace.match_mode", &m_FindReplace.match_mode, 0 ) );
54
55 m_params.emplace_back(
56 new PARAM<bool>( "find_replace.match_case", &m_FindReplace.match_case, false ) );
57
58 m_params.emplace_back( new PARAM<bool>( "find_replace.search_and_replace",
60
61 m_params.emplace_back( new PARAM<wxString>( "find_replace.find_string",
62 &m_FindReplace.find_string, wxS( "" ) ) );
63
64 m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.find_history",
66
67 m_params.emplace_back( new PARAM<wxString>( "find_replace.replace_string",
69
70 m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.replace_history",
72
73 m_params.emplace_back( new PARAM<int>( "graphics.canvas_type",
75
76 m_params.emplace_back( new PARAM<float>( "graphics.highlight_factor",
77 &m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) );
78
79 m_params.emplace_back( new PARAM<float>( "graphics.select_factor",
80 &m_Graphics.select_factor, 0.75f, 0.0, 1.0f ) );
81
82 m_params.emplace_back( new PARAM<int>( "color_picker.default_tab",
84
85 m_params.emplace_back( new PARAM_LIST<wxString>( "lib_tree.columns", &m_LibTree.columns, {} ) );
86
87 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "lib_tree.column_widths",
88 [&]() -> nlohmann::json
89 {
90 nlohmann::json ret = {};
91
92 for( const std::pair<const wxString, int>& pair : m_LibTree.column_widths )
93 ret[std::string( pair.first.ToUTF8() )] = pair.second;
94
95 return ret;
96 },
97 [&]( const nlohmann::json& aJson )
98 {
99 if( !aJson.is_object() )
100 return;
101
102 m_LibTree.column_widths.clear();
103
104 for( const auto& entry : aJson.items() )
105 {
106 if( !entry.value().is_number_integer() )
107 continue;
108
109 m_LibTree.column_widths[ entry.key() ] = entry.value().get<int>();
110 }
111 },
112 {} ) );
113
114 m_params.emplace_back(
115 new PARAM_LIST<wxString>( "lib_tree.open_libs", &m_LibTree.open_libs, {} ) );
116
117 m_params.emplace_back( new PARAM<bool>( "printing.background",
118 &m_Printing.background, false ) );
119
120 m_params.emplace_back( new PARAM<bool>( "printing.monochrome",
121 &m_Printing.monochrome, true ) );
122
123 m_params.emplace_back( new PARAM<double>( "printing.scale",
124 &m_Printing.scale, 1.0 ) );
125
126 m_params.emplace_back( new PARAM<bool>( "printing.use_theme",
127 &m_Printing.use_theme, false ) );
128
129 m_params.emplace_back( new PARAM<wxString>( "printing.color_theme",
130 &m_Printing.color_theme, wxS( "" ) ) );
131
132 m_params.emplace_back( new PARAM<bool>( "printing.title_block",
133 &m_Printing.title_block, false ) );
134
135 m_params.emplace_back( new PARAM_LIST<int>( "printing.layers",
136 &m_Printing.layers, {} ) );
137
138 m_params.emplace_back( new PARAM<int>( "search_pane.selection_zoom",
139 reinterpret_cast<int*>( &m_SearchPane.selection_zoom ),
140 static_cast<int>( SEARCH_PANE::SELECTION_ZOOM::PAN ) ) );
141
142 m_params.emplace_back( new PARAM<bool>( "system.first_run_shown",
143 &m_System.first_run_shown, false ) ); //@todo RFB remove? - not used
144
145 m_params.emplace_back( new PARAM<int>( "system.max_undo_items",
146 &m_System.max_undo_items, 0 ) );
147
148 m_params.emplace_back( new PARAM_LIST<wxString>( "system.file_history",
149 &m_System.file_history, {} ) );
150
151 if( m_filename == wxS( "pl_editor" )
152 || ( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) ) )
153 {
154 m_params.emplace_back( new PARAM<int>( "system.units",
155 &m_System.units, static_cast<int>( EDA_UNITS::MILS ) ) );
156 }
157 else
158 {
159 m_params.emplace_back( new PARAM<int>( "system.units",
160 &m_System.units, static_cast<int>( EDA_UNITS::MILLIMETRES ) ) );
161 }
162
163 m_params.emplace_back( new PARAM<int>( "system.last_metric_units",
164 &m_System.last_metric_units, static_cast<int>( EDA_UNITS::MILLIMETRES ) ) );
165
166 m_params.emplace_back( new PARAM<int>( "system.last_imperial_units",
167 &m_System.last_imperial_units, static_cast<int>( EDA_UNITS::MILS ) ) );
168
169 m_params.emplace_back( new PARAM<bool>( "system.show_import_issues",
170 &m_System.show_import_issues, true ) );
171
172 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "plugins.actions",
173 [&]() -> nlohmann::json
174 {
175 nlohmann::json js = nlohmann::json::array();
176
177 for( const auto& [identifier, visible] : m_Plugins.actions )
178 js.push_back( nlohmann::json( { { identifier.ToUTF8(), visible } } ) );
179
180 return js;
181 },
182 [&]( const nlohmann::json& aObj )
183 {
184 m_Plugins.actions.clear();
185
186 if( !aObj.is_array() )
187 {
188 return;
189 }
190
191 for( const auto& entry : aObj )
192 {
193 if( entry.empty() || !entry.is_object() )
194 continue;
195
196 for( const auto& pair : entry.items() )
197 {
198 m_Plugins.actions.emplace_back( std::make_pair(
199 wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) );
200 }
201 }
202 },
203 nlohmann::json::array() ) );
204
205 m_params.emplace_back( new PARAM<wxString>( "appearance.color_theme",
207
208 addParamsForWindow( &m_Window, "window" );
209
210 m_params.emplace_back( new PARAM<bool>( "cross_probing.on_selection",
211 &m_CrossProbing.on_selection, true ) );
212
213 m_params.emplace_back( new PARAM<bool>( "cross_probing.center_on_items",
215
216 m_params.emplace_back( new PARAM<bool>( "cross_probing.zoom_to_fit",
217 &m_CrossProbing.zoom_to_fit, true ) );
218
219 m_params.emplace_back( new PARAM<bool>( "cross_probing.auto_highlight",
221}
222
223
224bool APP_SETTINGS_BASE::MigrateFromLegacy( wxConfigBase* aCfg )
225{
226 bool ret = true;
227
228 const std::string f = getLegacyFrameName();
229
230 ret &= fromLegacyString( aCfg, "LastFindString", "find_replace.find_string" );
231 ret &= fromLegacyString( aCfg, "LastReplaceString", "find_replace.replace_string" );
232
233 migrateFindReplace( aCfg );
234
235 ret &= fromLegacy<int>( aCfg, "canvas_type", "graphics.canvas_type" );
236
237 ret &= fromLegacy<int>( aCfg, "P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth",
238 "lib_tree.column_width" );
239
240 ret &= fromLegacy<bool>( aCfg, "PrintMonochrome", "printing.monochrome" );
241 ret &= fromLegacy<double>( aCfg, "PrintScale", "printing.scale" );
242 ret &= fromLegacy<bool>( aCfg, "PrintPageFrame", "printing.title_block" );
243
244 {
245 nlohmann::json js = nlohmann::json::array();
246 wxString key;
247 bool val = false;
248
249 for( unsigned i = 0; i < PCB_LAYER_ID_COUNT; ++i )
250 {
251 key.Printf( wxT( "PlotLayer_%d" ), i );
252
253 if( aCfg->Read( key, &val ) && val )
254 js.push_back( i );
255 }
256
257 Set( "printing.layers", js );
258 }
259
260 ret &= fromLegacy<bool>( aCfg, f + "FirstRunShown", "system.first_run_shown" );
261 ret &= fromLegacy<int>( aCfg, f + "DevelMaxUndoItems", "system.max_undo_items" );
262 ret &= fromLegacy<int>( aCfg, f + "Units", "system.units" );
263
264 {
265 int max_history_size = Pgm().GetCommonSettings()->m_System.file_history_size;
266 wxString file, key;
267 nlohmann::json js = nlohmann::json::array();
268
269 for( int i = 1; i <= max_history_size; i++ )
270 {
271 key.Printf( "file%d", i );
272 file = aCfg->Read( key, wxEmptyString );
273
274 if( !file.IsEmpty() )
275 js.push_back( file.ToStdString() );
276 }
277
278 Set( "system.file_history", js );
279 }
280
281 ret &= migrateWindowConfig( aCfg, f, "window" );
282
283 return ret;
284}
285
286
288{
289 const int find_replace_history_size = 10;
290 nlohmann::json find_history = nlohmann::json::array();
291 nlohmann::json replace_history = nlohmann::json::array();
292 wxString tmp, find_key, replace_key;
293
294 for( int i = 0; i < find_replace_history_size; ++i )
295 {
296 find_key.Printf( "FindStringHistoryList%d", i );
297 replace_key.Printf( "ReplaceStringHistoryList%d", i );
298
299 if( aCfg->Read( find_key, &tmp ) )
300 find_history.push_back( tmp.ToStdString() );
301
302 if( aCfg->Read( replace_key, &tmp ) )
303 replace_history.push_back( tmp.ToStdString() );
304 }
305
306 Set( "find_replace.find_history", find_history );
307 Set( "find_replace.replace_history", replace_history );
308}
309
310
311bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::string& aFrame,
312 const std::string& aJsonPath )
313{
314 bool ret = true;
315
316 const std::string frameGDO = aFrame + "GalDisplayOptions";
317 const std::string cursorPath = aJsonPath + ".cursor";
318 const std::string gridPath = aJsonPath + ".grid";
319
320 ret &= fromLegacy<bool>( aCfg, aFrame + "Maximized", aJsonPath + ".maximized" );
321 ret &= fromLegacyString( aCfg, aFrame + "MostRecentlyUsedPath", aJsonPath + ".mru_path" );
322 ret &= fromLegacy<int>( aCfg, aFrame + "Size_x", aJsonPath + ".size_x" );
323 ret &= fromLegacy<int>( aCfg, aFrame + "Size_y", aJsonPath + ".size_y" );
324 ret &= fromLegacyString( aCfg, aFrame + "Perspective", aJsonPath + ".perspective" );
325 ret &= fromLegacy<int>( aCfg, aFrame + "Pos_x", aJsonPath + ".pos_x" );
326 ret &= fromLegacy<int>( aCfg, aFrame + "Pos_y", aJsonPath + ".pos_y" );
327
328 ret &= fromLegacy<bool>( aCfg, frameGDO + "ForceDisplayCursor", cursorPath + ".always_show_cursor" );
329 ret &= fromLegacy<bool>( aCfg, frameGDO + "CursorFullscreen", cursorPath + ".fullscreen_cursor" );
330
331 ret &= fromLegacy<int>( aCfg, aFrame + "_LastGridSize", gridPath + ".last_size" );
332
333 ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid1", gridPath + ".fast_grid_1" );
334 ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid2", gridPath + ".fast_grid_2" );
335
336 ret &= fromLegacy<bool>( aCfg, frameGDO + "GridAxesEnabled", gridPath + ".axes_enabled" );
337 ret &= fromLegacy<double>( aCfg, frameGDO + "GridLineWidth", gridPath + ".line_width" );
338 ret &= fromLegacy<double>( aCfg, frameGDO + "GridMaxDensity", gridPath + ".min_spacing" );
339 ret &= fromLegacy<bool>( aCfg, frameGDO + "ShowGrid", gridPath + ".show" );
340 ret &= fromLegacy<int>( aCfg, frameGDO + "GridStyle", gridPath + ".style" );
341 ret &= fromLegacyColor( aCfg, frameGDO + "GridColor", gridPath + ".color" );
342
343 return ret;
344}
345
346
347void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std::string& aJsonPath )
348{
349 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".maximized",
350 &aWindow->state.maximized, false ) );
351
352 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".mru_path",
353 &aWindow->mru_path, wxS( "" ) ) );
354
355 m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_x", &aWindow->state.size_x, 0 ) );
356
357 m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_y", &aWindow->state.size_y, 0 ) );
358
359 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".perspective",
360 &aWindow->perspective, wxS( "" ) ) );
361
362 m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_x", &aWindow->state.pos_x, 0 ) );
363
364 m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_y", &aWindow->state.pos_y, 0 ) );
365
366 m_params.emplace_back( new PARAM<unsigned int>( aJsonPath + ".display",
367 &aWindow->state.display, 0 ) );
368
369 m_params.emplace_back( new PARAM_LIST<double>( aJsonPath + ".zoom_factors",
370 &aWindow->zoom_factors, {} ) );
371
372 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.axes_enabled",
373 &aWindow->grid.axes_enabled, false ) );
374
375 int defaultGridIdx;
376
377 if( ( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) ) )
378 {
379 defaultGridIdx = 1;
380 }
381 else if( m_filename == wxS( "pl_editor" ) )
382 {
383 defaultGridIdx = 4;
384 }
385 else
386 {
387 defaultGridIdx = 15;
388 }
389
390 m_params.emplace_back( new PARAM_LIST<GRID>( aJsonPath + ".grid.sizes", &aWindow->grid.grids,
392
393 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.last_size",
394 &aWindow->grid.last_size_idx, defaultGridIdx ) );
395
396 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_1",
397 &aWindow->grid.fast_grid_1, defaultGridIdx ) );
398
399 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_2",
400 &aWindow->grid.fast_grid_2, defaultGridIdx + 1 ) );
401
402 // legacy values, leave blank by default so we don't convert them
403 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_x",
404 &aWindow->grid.user_grid_x, wxEmptyString ) );
405 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_y",
406 &aWindow->grid.user_grid_y, wxEmptyString ) );
407
408 // for grid overrides, give just the schematic and symbol editors sane values
409 if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
410 {
411 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.overrides_enabled",
412 &aWindow->grid.overrides_enabled, true ) );
413 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_connected",
414 &aWindow->grid.override_connected, true ) );
415 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_wires",
416 &aWindow->grid.override_wires, true ) );
417 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_vias",
418 &aWindow->grid.override_vias, false ) );
419 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_text",
420 &aWindow->grid.override_text, true ) );
421 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_graphics",
422 &aWindow->grid.override_graphics, false ) );
423
424 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_connected_idx",
425 &aWindow->grid.override_connected_idx, 1 ) );
426 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_wires_idx",
427 &aWindow->grid.override_wires_idx, 1 ) );
428 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_vias_idx",
429 &aWindow->grid.override_vias_idx, 0 ) );
430 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_text_idx",
431 &aWindow->grid.override_text_idx, 3 ) );
432 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_graphics_idx",
433 &aWindow->grid.override_graphics_idx, 2 ) );
434 }
435 else
436 {
437 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.overrides_enabled",
438 &aWindow->grid.overrides_enabled, true ) );
439 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_connected",
440 &aWindow->grid.override_connected, false ) );
441 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_wires",
442 &aWindow->grid.override_wires, false ) );
443 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_vias",
444 &aWindow->grid.override_vias, false ) );
445 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_text",
446 &aWindow->grid.override_text, false ) );
447 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_graphics",
448 &aWindow->grid.override_graphics, false ) );
449
450 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_connected_idx",
451 &aWindow->grid.override_connected_idx, 16 ) );
452 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_text_idx",
453 &aWindow->grid.override_text_idx, 18 ) );
454 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_wires_idx",
455 &aWindow->grid.override_wires_idx, 19 ) );
456 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_vias_idx",
457 &aWindow->grid.override_vias_idx, 18 ) );
458 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_graphics_idx",
459 &aWindow->grid.override_graphics_idx, 15 ) );
460 }
461
462 m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.line_width",
463 &aWindow->grid.line_width, 1.0 ) );
464
465 m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.min_spacing",
466 &aWindow->grid.min_spacing, 10 ) );
467
468 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.show",
469 &aWindow->grid.show, true ) );
470
471 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style",
472 &aWindow->grid.style, 0 ) );
473
474 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.snap",
475 &aWindow->grid.snap, 0 ) );
476
477 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.always_show_cursor",
478 &aWindow->cursor.always_show_cursor, true ) );
479
480 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.fullscreen_cursor",
481 &aWindow->cursor.fullscreen_cursor, false ) );
482}
483
484
485const std::vector<GRID> APP_SETTINGS_BASE::DefaultGridSizeList() const
486{
487 if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
488 {
489 return { GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
490 GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
491 GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
492 GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) } };
493 }
494 else
495 {
496 return { GRID{ wxEmptyString, wxS( "1000 mil" ), wxS( "1000 mil" ) },
497 GRID{ wxEmptyString, wxS( "500 mil" ), wxS( "500 mil" ) },
498 GRID{ wxEmptyString, wxS( "250 mil" ), wxS( "250 mil" ) },
499 GRID{ wxEmptyString, wxS( "200 mil" ), wxS( "200 mil" ) },
500 GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
501 GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
502 GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
503 GRID{ wxEmptyString, wxS( "20 mil" ), wxS( "20 mil" ) },
504 GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) },
505 GRID{ wxEmptyString, wxS( "5 mil" ), wxS( "5 mil" ) },
506 GRID{ wxEmptyString, wxS( "2 mil" ), wxS( "2 mil" ) },
507 GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) },
508 GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) },
509 GRID{ wxEmptyString, wxS( "2.5 mm" ), wxS( "2.5 mm" ) },
510 GRID{ wxEmptyString, wxS( "1.0 mm" ), wxS( "1.0 mm" ) },
511 GRID{ wxEmptyString, wxS( "0.5 mm" ), wxS( "0.5 mm" ) },
512 GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) },
513 GRID{ wxEmptyString, wxS( "0.2 mm" ), wxS( "0.2 mm" ) },
514 GRID{ wxEmptyString, wxS( "0.1 mm" ), wxS( "0.1 mm" ) },
515 GRID{ wxEmptyString, wxS( "0.05 mm" ), wxS( "0.05 mm" ) },
516 GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.025 mm" ) },
517 GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.01 mm" ) } };
518 }
519}
520
521
523{
524 // We used to store only the width of the first column, because there were only
525 // two possible columns.
526 if( std::optional<int> optWidth = Get<int>( "lib_tree.column_width" ) )
527 {
528 Set<nlohmann::json>( "lib_tree.column_widths", { { "Item", *optWidth } } );
529 At( "lib_tree" ).erase( "column_width" );
530 }
531
532 return true;
533}
SEARCH_PANE m_SearchPane
Definition: app_settings.h:188
WINDOW_SETTINGS m_Window
Definition: app_settings.h:194
APP_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
FIND_REPLACE m_FindReplace
Definition: app_settings.h:178
bool migrateWindowConfig(wxConfigBase *aCfg, const std::string &aFrameName, const std::string &aJsonPath)
Migrates legacy window settings into the JSON document.
const std::vector< GRID > DefaultGridSizeList() const
void migrateFindReplace(wxConfigBase *aCfg)
! Migrates the find/replace history string lists
COLOR_PICKER m_ColorPicker
Definition: app_settings.h:182
virtual std::string getLegacyFrameName() const
Definition: app_settings.h:205
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:197
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:176
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath)
Adds parameters for the given window object.
bool migrateLibTreeWidth()
Migrates 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:679
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:135
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
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
std::vector< std::pair< wxString, bool > > actions
Ordered list of plugin actions mapped to whether or not they are shown in the toolbar.
Definition: app_settings.h:164
bool monochrome
Whether or not to print in monochrome.
Definition: app_settings.h:141
bool background
Whether or not to print background color.
Definition: app_settings.h:140
std::vector< int > layers
List of enabled layers for printing.
Definition: app_settings.h:146
wxString color_theme
Color theme to use for printing.
Definition: app_settings.h:144
double scale
Printout scale.
Definition: app_settings.h:142
bool title_block
Whether or not to print title block.
Definition: app_settings.h:145
bool use_theme
If false, display color theme will be used.
Definition: app_settings.h:143
bool show_import_issues
Stored value for "show import issues" when importing non-KiCad designs to this application.
Definition: app_settings.h:158
std::vector< wxString > file_history
Definition: app_settings.h:153
bool on_selection
Synchronize the selection for multiple items too.
Definition: app_settings.h:33
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
Definition: app_settings.h:35
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:34
bool auto_highlight
Automatically turn on highlight mode in the target frame.
Definition: app_settings.h:36
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
Stores 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