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 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#include <zoom_defines.h>
33
34
35APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaVersion ) :
36 JSON_SETTINGS( aFilename, SETTINGS_LOC::USER, aSchemaVersion ),
37 m_CrossProbing(),
38 m_FindReplace(),
39 m_Graphics(),
40 m_ColorPicker(),
41 m_LibTree(),
42 m_Printing(),
43 m_SearchPane(),
44 m_System(),
45 m_Plugins(),
46 m_Window(),
47 m_CustomToolbars( false ),
48 m_appSettingsSchemaVersion( aSchemaVersion )
49{
50 // Build parameters list:
51 m_params.emplace_back(
52 new PARAM<int>( "find_replace.match_mode", &m_FindReplace.match_mode, 0 ) );
53
54 m_params.emplace_back(
55 new PARAM<bool>( "find_replace.match_case", &m_FindReplace.match_case, false ) );
56
57 m_params.emplace_back( new PARAM<bool>( "find_replace.search_and_replace",
59
60 m_params.emplace_back( new PARAM<wxString>( "find_replace.find_string",
61 &m_FindReplace.find_string, wxS( "" ) ) );
62
63 m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.find_history",
65
66 m_params.emplace_back( new PARAM<wxString>( "find_replace.replace_string",
68
69 m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.replace_history",
71
72 m_params.emplace_back( new PARAM<int>( "design_block_chooser.sash_pos_h",
74
75 m_params.emplace_back( new PARAM<int>( "design_block_chooser.sash_pos_v",
77
78 m_params.emplace_back( new PARAM<int>( "design_block_chooser.width",
80
81 m_params.emplace_back( new PARAM<int>( "design_block_chooser.height",
83
84 m_params.emplace_back( new PARAM<int>( "design_block_chooser.sort_mode",
86
87 m_params.emplace_back( new PARAM<bool>( "design_block_chooser.repeated_placement",
89
90 m_params.emplace_back( new PARAM<bool>( "design_block_chooser.place_as_sheet",
92
93 m_params.emplace_back( new PARAM<bool>( "design_block_chooser.keep_annotations",
95
96 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>(
97 "design_block_chooser.lib_tree.column_widths",
98 [&]() -> nlohmann::json
99 {
100 nlohmann::json ret = {};
101
102 for( const auto& [name, width] : m_DesignBlockChooserPanel.tree.column_widths )
103 ret[std::string( name.ToUTF8() )] = width;
104
105 return ret;
106 },
107 [&]( const nlohmann::json& aJson )
108 {
109 if( !aJson.is_object() )
110 return;
111
113
114 for( const auto& entry : aJson.items() )
115 {
116 if( !entry.value().is_number_integer() )
117 continue;
118
119 m_DesignBlockChooserPanel.tree.column_widths[entry.key()] = entry.value().get<int>();
120 }
121 },
122 {} ) );
123
124 m_params.emplace_back( new PARAM<float>( "graphics.highlight_factor",
125 &m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) );
126
127 m_params.emplace_back( new PARAM<float>( "graphics.select_factor",
128 &m_Graphics.select_factor, 0.75f, 0.0, 1.0f ) );
129
130 m_params.emplace_back( new PARAM<int>( "color_picker.default_tab",
132
133 m_params.emplace_back( new PARAM_LIST<wxString>( "lib_tree.columns", &m_LibTree.columns, {} ) );
134
135 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "lib_tree.column_widths",
136 [&]() -> nlohmann::json
137 {
138 nlohmann::json ret = {};
139
140 for( const std::pair<const wxString, int>& pair : m_LibTree.column_widths )
141 ret[std::string( pair.first.ToUTF8() )] = pair.second;
142
143 return ret;
144 },
145 [&]( const nlohmann::json& aJson )
146 {
147 if( !aJson.is_object() )
148 return;
149
150 m_LibTree.column_widths.clear();
151
152 for( const auto& entry : aJson.items() )
153 {
154 if( !entry.value().is_number_integer() )
155 continue;
156
157 m_LibTree.column_widths[ entry.key() ] = entry.value().get<int>();
158 }
159 },
160 {} ) );
161
162 m_params.emplace_back(
163 new PARAM_LIST<wxString>( "lib_tree.open_libs", &m_LibTree.open_libs, {} ) );
164
165 m_params.emplace_back( new PARAM<bool>( "printing.background",
166 &m_Printing.background, false ) );
167
168 m_params.emplace_back( new PARAM<bool>( "printing.monochrome",
169 &m_Printing.monochrome, true ) );
170
171 m_params.emplace_back( new PARAM<double>( "printing.scale",
172 &m_Printing.scale, 1.0 ) );
173
174 m_params.emplace_back( new PARAM<bool>( "printing.use_theme",
175 &m_Printing.use_theme, false ) );
176
177 m_params.emplace_back( new PARAM<wxString>( "printing.color_theme",
178 &m_Printing.color_theme, wxS( "" ) ) );
179
180 m_params.emplace_back( new PARAM<bool>( "printing.title_block",
181 &m_Printing.title_block, false ) );
182
183 m_params.emplace_back( new PARAM_LIST<int>( "printing.layers",
184 &m_Printing.layers, {} ) );
185
186 m_params.emplace_back( new PARAM<int>( "search_pane.selection_zoom",
187 reinterpret_cast<int*>( &m_SearchPane.selection_zoom ),
188 static_cast<int>( SEARCH_PANE::SELECTION_ZOOM::PAN ) ) );
189
190 m_params.emplace_back( new PARAM<bool>( "search_pane.search_hidden_fields",
191 &m_SearchPane.search_hidden_fields, true ) );
192
193 m_params.emplace_back( new PARAM<bool>( "search_pane.search_metadata",
194 &m_SearchPane.search_metadata, false ) );
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, "P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth",
293 "lib_tree.column_width" );
294
295 ret &= fromLegacy<bool>( aCfg, "PrintMonochrome", "printing.monochrome" );
296 ret &= fromLegacy<double>( aCfg, "PrintScale", "printing.scale" );
297 ret &= fromLegacy<bool>( aCfg, "PrintPageFrame", "printing.title_block" );
298
299 {
300 nlohmann::json js = nlohmann::json::array();
301 wxString key;
302 bool val = false;
303
304 for( unsigned i = 0; i < PCB_LAYER_ID_COUNT; ++i )
305 {
306 key.Printf( wxT( "PlotLayer_%d" ), i );
307
308 if( aCfg->Read( key, &val ) && val )
309 js.push_back( i );
310 }
311
312 Set( "printing.layers", js );
313 }
314
315 ret &= fromLegacy<bool>( aCfg, f + "FirstRunShown", "system.first_run_shown" );
316 ret &= fromLegacy<int>( aCfg, f + "DevelMaxUndoItems", "system.max_undo_items" );
317 ret &= fromLegacy<int>( aCfg, f + "Units", "system.units" );
318
319 {
320 int max_history_size = Pgm().GetCommonSettings()->m_System.file_history_size;
321 wxString file, key;
322 nlohmann::json js = nlohmann::json::array();
323
324 for( int i = 1; i <= max_history_size; i++ )
325 {
326 key.Printf( "file%d", i );
327 file = aCfg->Read( key, wxEmptyString );
328
329 if( !file.IsEmpty() )
330 js.push_back( file.ToStdString() );
331 }
332
333 Set( "system.file_history", js );
334 }
335
336 ret &= migrateWindowConfig( aCfg, f, "window" );
337
338 return ret;
339}
340
341
343{
344 const int find_replace_history_size = 10;
345 nlohmann::json find_history = nlohmann::json::array();
346 nlohmann::json replace_history = nlohmann::json::array();
347 wxString tmp, find_key, replace_key;
348
349 for( int i = 0; i < find_replace_history_size; ++i )
350 {
351 find_key.Printf( "FindStringHistoryList%d", i );
352 replace_key.Printf( "ReplaceStringHistoryList%d", i );
353
354 if( aCfg->Read( find_key, &tmp ) )
355 find_history.push_back( tmp.ToStdString() );
356
357 if( aCfg->Read( replace_key, &tmp ) )
358 replace_history.push_back( tmp.ToStdString() );
359 }
360
361 Set( "find_replace.find_history", find_history );
362 Set( "find_replace.replace_history", replace_history );
363}
364
365
366bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::string& aFrame,
367 const std::string& aJsonPath )
368{
369 bool ret = true;
370
371 const std::string frameGDO = aFrame + "GalDisplayOptions";
372 const std::string cursorPath = aJsonPath + ".cursor";
373 const std::string gridPath = aJsonPath + ".grid";
374
375 ret &= fromLegacy<bool>( aCfg, aFrame + "Maximized", aJsonPath + ".maximized" );
376 ret &= fromLegacyString( aCfg, aFrame + "MostRecentlyUsedPath", aJsonPath + ".mru_path" );
377 ret &= fromLegacy<int>( aCfg, aFrame + "Size_x", aJsonPath + ".size_x" );
378 ret &= fromLegacy<int>( aCfg, aFrame + "Size_y", aJsonPath + ".size_y" );
379 ret &= fromLegacyString( aCfg, aFrame + "Perspective", aJsonPath + ".perspective" );
380 ret &= fromLegacy<int>( aCfg, aFrame + "Pos_x", aJsonPath + ".pos_x" );
381 ret &= fromLegacy<int>( aCfg, aFrame + "Pos_y", aJsonPath + ".pos_y" );
382
383 ret &= fromLegacy<bool>( aCfg, frameGDO + "ForceDisplayCursor",
384 cursorPath + ".always_show_cursor" );
385 ret &= fromLegacy<bool>( aCfg, frameGDO + "CursorFullscreen",
386 cursorPath + ".fullscreen_cursor" );
387
388 ret &= fromLegacy<int>( aCfg, aFrame + "_LastGridSize", gridPath + ".last_size" );
389
390 ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid1", gridPath + ".fast_grid_1" );
391 ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid2", gridPath + ".fast_grid_2" );
392
393 ret &= fromLegacy<bool>( aCfg, frameGDO + "GridAxesEnabled", gridPath + ".axes_enabled" );
394 ret &= fromLegacy<double>( aCfg, frameGDO + "GridLineWidth", gridPath + ".line_width" );
395 ret &= fromLegacy<double>( aCfg, frameGDO + "GridMaxDensity", gridPath + ".min_spacing" );
396 ret &= fromLegacy<bool>( aCfg, frameGDO + "ShowGrid", gridPath + ".show" );
397 ret &= fromLegacy<int>( aCfg, frameGDO + "GridStyle", gridPath + ".style" );
398 ret &= fromLegacyColor( aCfg, frameGDO + "GridColor", gridPath + ".color" );
399
400 return ret;
401}
402
403
404void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std::string& aJsonPath,
405 int aDefaultWidth, int aDefaultHeight )
406{
407 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".maximized",
408 &aWindow->state.maximized, false ) );
409
410 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".mru_path",
411 &aWindow->mru_path, wxS( "" ) ) );
412
413 m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_x", &aWindow->state.size_x, aDefaultWidth ) );
414
415 m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_y", &aWindow->state.size_y, aDefaultHeight ) );
416
417 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".perspective",
418 &aWindow->perspective, wxS( "" ) ) );
419
420 m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_x", &aWindow->state.pos_x, 0 ) );
421
422 m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_y", &aWindow->state.pos_y, 0 ) );
423
424 m_params.emplace_back( new PARAM<unsigned int>( aJsonPath + ".display",
425 &aWindow->state.display, 0 ) );
426
427 m_params.emplace_back( new PARAM_LIST<double>( aJsonPath + ".zoom_factors",
428 &aWindow->zoom_factors, DefaultZoomList(), true /* resetIfEmpty */ ) );
429
430 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.axes_enabled",
431 &aWindow->grid.axes_enabled, false ) );
432
433 int defaultGridIdx;
434
435 if( ( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) ) )
436 {
437 defaultGridIdx = 1;
438 }
439 else if( m_filename == wxS( "pl_editor" ) )
440 {
441 defaultGridIdx = 4;
442 }
443 else
444 {
445 defaultGridIdx = 15;
446 }
447
448 m_params.emplace_back( new PARAM_LIST<GRID>( aJsonPath + ".grid.sizes", &aWindow->grid.grids,
449 DefaultGridSizeList(), true /* resetIfEmpty */ ) );
450
451 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.last_size",
452 &aWindow->grid.last_size_idx, defaultGridIdx ) );
453
454 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_1",
455 &aWindow->grid.fast_grid_1, defaultGridIdx ) );
456
457 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_2",
458 &aWindow->grid.fast_grid_2, defaultGridIdx + 1 ) );
459
460 // legacy values, leave blank by default so we don't convert them
461 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_x",
462 &aWindow->grid.user_grid_x, wxEmptyString ) );
463 m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_y",
464 &aWindow->grid.user_grid_y, wxEmptyString ) );
465
466 // for grid overrides, give just the schematic and symbol editors sane values
467 if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
468 {
469 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.overrides_enabled",
470 &aWindow->grid.overrides_enabled, true ) );
471 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_connected",
472 &aWindow->grid.override_connected, true ) );
473 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_wires",
474 &aWindow->grid.override_wires, true ) );
475 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_vias",
476 &aWindow->grid.override_vias, false ) );
477 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_text",
478 &aWindow->grid.override_text, true ) );
479 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_graphics",
480 &aWindow->grid.override_graphics, false ) );
481
482 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_connected_idx",
483 &aWindow->grid.override_connected_idx, 1 ) );
484 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_wires_idx",
485 &aWindow->grid.override_wires_idx, 1 ) );
486 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_vias_idx",
487 &aWindow->grid.override_vias_idx, 0 ) );
488 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_text_idx",
489 &aWindow->grid.override_text_idx, 3 ) );
490 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_graphics_idx",
491 &aWindow->grid.override_graphics_idx, 2 ) );
492 }
493 else
494 {
495 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.overrides_enabled",
496 &aWindow->grid.overrides_enabled, true ) );
497 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_connected",
498 &aWindow->grid.override_connected, false ) );
499 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_wires",
500 &aWindow->grid.override_wires, false ) );
501 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_vias",
502 &aWindow->grid.override_vias, false ) );
503 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_text",
504 &aWindow->grid.override_text, false ) );
505 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.override_graphics",
506 &aWindow->grid.override_graphics, false ) );
507
508 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_connected_idx",
509 &aWindow->grid.override_connected_idx, 16 ) );
510 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_text_idx",
511 &aWindow->grid.override_text_idx, 18 ) );
512 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_wires_idx",
513 &aWindow->grid.override_wires_idx, 19 ) );
514 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_vias_idx",
515 &aWindow->grid.override_vias_idx, 18 ) );
516 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.override_graphics_idx",
517 &aWindow->grid.override_graphics_idx, 15 ) );
518 }
519
520 m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.line_width",
521 &aWindow->grid.line_width, 1.0 ) );
522
523 m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.min_spacing",
524 &aWindow->grid.min_spacing, 10 ) );
525
526 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.show",
527 &aWindow->grid.show, true ) );
528
529 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style",
530 &aWindow->grid.style, 0 ) );
531
532 m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.snap",
533 &aWindow->grid.snap, 0 ) );
534
535 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.always_show_cursor",
536 &aWindow->cursor.always_show_cursor, true ) );
537
538 m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.fullscreen_cursor",
539 &aWindow->cursor.fullscreen_cursor, false ) );
540}
541
542
543const std::vector<double> APP_SETTINGS_BASE::DefaultZoomList() const
544{
545 if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
546 {
547 return { ZOOM_LIST_EESCHEMA };
548 }
549 else if( m_filename == wxS( "pl_editor" ) )
550 {
551 return { ZOOM_LIST_PL_EDITOR };
552 }
553 else if( m_filename == wxS( "gerbview" ) )
554 {
555 return { ZOOM_LIST_GERBVIEW };
556 }
557 else
558 {
559 if( ADVANCED_CFG::GetCfg().m_HyperZoom )
560 return { ZOOM_LIST_PCBNEW_HYPER };
561 else
562 return { ZOOM_LIST_PCBNEW };
563 }
564}
565
566
567const std::vector<GRID> APP_SETTINGS_BASE::DefaultGridSizeList() const
568{
569 if( m_filename == wxS( "eeschema" ) || m_filename == wxS( "symbol_editor" ) )
570 {
571 return { GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
572 GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
573 GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
574 GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) } };
575 }
576 else if( m_filename == wxS( "pl_editor" ) )
577 {
578 return { GRID{ wxEmptyString, wxS( "5.00 mm" ), wxS( "5.00 mm" ) },
579 GRID{ wxEmptyString, wxS( "2.50 mm" ), wxS( "2.50 mm" ) },
580 GRID{ wxEmptyString, wxS( "2.00 mm" ), wxS( "2.00 mm" ) },
581 GRID{ wxEmptyString, wxS( "1.00 mm" ), wxS( "1.00 mm" ) },
582 GRID{ wxEmptyString, wxS( "0.50 mm" ), wxS( "0.50 mm" ) },
583 GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) },
584 GRID{ wxEmptyString, wxS( "0.20 mm" ), wxS( "0.20 mm" ) },
585 GRID{ wxEmptyString, wxS( "0.10 mm" ), wxS( "0.10 mm" ) } };
586 }
587 else if( m_filename == wxS( "gerbview" ) )
588 {
589 return { GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
590 GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
591 GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
592 GRID{ wxEmptyString, wxS( "20 mil" ), wxS( "20 mil" ) },
593 GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) },
594 GRID{ wxEmptyString, wxS( "5 mil" ), wxS( "5 mil" ) },
595 GRID{ wxEmptyString, wxS( "2.5 mil" ), wxS( "2.5 mil" ) },
596 GRID{ wxEmptyString, wxS( "2 mil" ), wxS( "2 mil" ) },
597 GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) },
598 GRID{ wxEmptyString, wxS( "0.5 mil" ), wxS( "0.5 mil" ) },
599 GRID{ wxEmptyString, wxS( "0.2 mil" ), wxS( "0.2 mil" ) },
600 GRID{ wxEmptyString, wxS( "0.1 mil" ), wxS( "0.1 mil" ) },
601 GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) },
602 GRID{ wxEmptyString, wxS( "1.5 mm" ), wxS( "2.5 mm" ) },
603 GRID{ wxEmptyString, wxS( "1.0 mm" ), wxS( "1.0 mm" ) },
604 GRID{ wxEmptyString, wxS( "0.5 mm" ), wxS( "0.5 mm" ) },
605 GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) },
606 GRID{ wxEmptyString, wxS( "0.2 mm" ), wxS( "0.2 mm" ) },
607 GRID{ wxEmptyString, wxS( "0.1 mm" ), wxS( "0.1 mm" ) },
608 GRID{ wxEmptyString, wxS( "0.05 mm" ), wxS( "0.0 mm" ) },
609 GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.0 mm" ) },
610 GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.0 mm" ) } };
611 }
612 else
613 {
614 return { GRID{ wxEmptyString, wxS( "1000 mil" ), wxS( "1000 mil" ) },
615 GRID{ wxEmptyString, wxS( "500 mil" ), wxS( "500 mil" ) },
616 GRID{ wxEmptyString, wxS( "250 mil" ), wxS( "250 mil" ) },
617 GRID{ wxEmptyString, wxS( "200 mil" ), wxS( "200 mil" ) },
618 GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
619 GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
620 GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
621 GRID{ wxEmptyString, wxS( "20 mil" ), wxS( "20 mil" ) },
622 GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) },
623 GRID{ wxEmptyString, wxS( "5 mil" ), wxS( "5 mil" ) },
624 GRID{ wxEmptyString, wxS( "2 mil" ), wxS( "2 mil" ) },
625 GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) },
626 GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) },
627 GRID{ wxEmptyString, wxS( "2.5 mm" ), wxS( "2.5 mm" ) },
628 GRID{ wxEmptyString, wxS( "1.0 mm" ), wxS( "1.0 mm" ) },
629 GRID{ wxEmptyString, wxS( "0.5 mm" ), wxS( "0.5 mm" ) },
630 GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) },
631 GRID{ wxEmptyString, wxS( "0.2 mm" ), wxS( "0.2 mm" ) },
632 GRID{ wxEmptyString, wxS( "0.1 mm" ), wxS( "0.1 mm" ) },
633 GRID{ wxEmptyString, wxS( "0.05 mm" ), wxS( "0.05 mm" ) },
634 GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.025 mm" ) },
635 GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.01 mm" ) } };
636 }
637}
638
639
641{
642 // We used to store only the width of the first column, because there were only
643 // two possible columns.
644 if( std::optional<int> optWidth = Get<int>( "lib_tree.column_width" ) )
645 {
646 Set<nlohmann::json>( "lib_tree.column_widths", { { "Item", *optWidth } } );
647 At( "lib_tree" ).erase( "column_width" );
648 }
649
650 return true;
651}
const char * name
Definition: DXF_plotter.cpp:62
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
APP_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
FIND_REPLACE m_FindReplace
Definition: app_settings.h:215
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:217
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath, int aDefaultWidth=0, int aDefaultHeight=0)
Add parameters for the given window object.
const std::vector< double > DefaultZoomList() const
COLOR_PICKER m_ColorPicker
Definition: app_settings.h:221
virtual std::string getLegacyFrameName() const
Definition: app_settings.h:247
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
bool migrateLibTreeWidth()
Migrate the library tree width setting from a single column (Item) to multi-column.
static const wxString COLOR_BUILTIN_DEFAULT
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
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:565
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:902
see class PGM_BASE
std::vector< wxString > replace_history
Definition: app_settings.h:115
std::vector< wxString > find_history
Definition: app_settings.h:113
float highlight_factor
How much to brighten highlighted objects by.
Definition: app_settings.h:139
float select_factor
How much to brighten selected objects by.
Definition: app_settings.h:140
std::vector< wxString > columns
Ordered list of visible columns in the tree.
Definition: app_settings.h:150
std::map< wxString, int > column_widths
Column widths, keyed by header name.
Definition: app_settings.h:151
std::vector< wxString > open_libs
list of libraries the user has open in the tree.
Definition: app_settings.h:152
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:90
CURSOR_SETTINGS cursor
Definition: app_settings.h:96
WINDOW_STATE state
Definition: app_settings.h:91
GRID_SETTINGS grid
Definition: app_settings.h:97
wxString mru_path
Definition: app_settings.h:92
std::vector< double > zoom_factors
Definition: app_settings.h:94
wxString perspective
Definition: app_settings.h:93
unsigned int display
Definition: app_settings.h:83
#define ZOOM_LIST_PL_EDITOR
Definition: zoom_defines.h:38
#define ZOOM_LIST_PCBNEW
Definition: zoom_defines.h:32
#define ZOOM_LIST_PCBNEW_HYPER
Definition: zoom_defines.h:35
#define ZOOM_LIST_EESCHEMA
Definition: zoom_defines.h:41
#define ZOOM_LIST_GERBVIEW
Definition: zoom_defines.h:29