KiCad PCB EDA Suite
Loading...
Searching...
No Matches
common_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
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <set>
22#include <fstream>
23#include <sstream>
24
26#include <env_vars.h>
27#include <paths.h>
28#include <richio.h>
29#include <search_stack.h>
35#include <settings/parameters.h>
36#include <systemdirsappend.h>
37#include <trace_helpers.h>
38#include <wx/config.h>
39#include <wx/log.h>
40#include <wx/regex.h>
41#include <wx/tokenzr.h>
42#include <wx/window.h>
43
44
46const wxRegEx versionedEnvVarRegex( wxS( "KICAD[0-9]+_[A-Z0-9_]+(_DIR)?" ) );
47
49const int commonSchemaVersion = 7;
50
52
56 m_Backup(),
57 m_Env(),
58 m_Input(),
60 m_Graphics(),
61 m_Session(),
62 m_System(),
65 m_Api(),
68{
69 /*
70 * Automatic dark mode detection works fine on Mac.
71 */
72#if defined( __WXGTK__ ) || defined( __WXMSW__ )
73 m_params.emplace_back( new PARAM_ENUM<ICON_THEME>( "appearance.icon_theme",
75#else
76 m_Appearance.icon_theme = ICON_THEME::AUTO;
77#endif
78
79#if defined( __WXMSW__ )
80 m_params.emplace_back( new PARAM_ENUM<APP_THEME>( "appearance.app_theme", &m_Appearance.app_theme,
82#else
83 m_Appearance.app_theme = APP_THEME::AUTO;
84#endif
85
86 /*
87 * Automatic canvas scaling works fine on all supported platforms, so it's no longer exposed as
88 * a configuration option.
89 */
90 m_Appearance.canvas_scale = 0.0;
91
92 /*
93 * Menu icons are off by default on OSX and on for all other platforms.
94 */
95#ifdef __WXMAC__
96 m_params.emplace_back( new PARAM<bool>( "appearance.use_icons_in_menus",
97 &m_Appearance.use_icons_in_menus, false ) );
98#else
99 m_params.emplace_back( new PARAM<bool>( "appearance.use_icons_in_menus",
100 &m_Appearance.use_icons_in_menus, true ) );
101#endif
102
103 /*
104 * Font scaling hacks are only needed on GTK under wxWidgets 3.0.
105 */
106 m_Appearance.apply_icon_scale_to_fonts = false;
107
108 m_params.emplace_back( new PARAM<bool>( "appearance.show_scrollbars",
109 &m_Appearance.show_scrollbars, false ) );
110
111 m_params.emplace_back( new PARAM<double>( "appearance.hicontrast_dimming_factor",
112 &m_Appearance.hicontrast_dimming_factor, 0.8f ) );
113
114 m_params.emplace_back( new PARAM<int>( "appearance.text_editor_zoom",
115 &m_Appearance.text_editor_zoom, 0 ) );
116
117 m_params.emplace_back( new PARAM<int>( "appearance.toolbar_icon_size",
118 &m_Appearance.toolbar_icon_size, 24, 16, 64 ) );
119
120 m_params.emplace_back( new PARAM<bool>( "appearance.grid_striping",
121 &m_Appearance.grid_striping, false ) );
122
123 m_params.emplace_back( new PARAM<bool>( "appearance.use_custom_cursors",
124 &m_Appearance.use_custom_cursors, true ) );
125
126 m_Appearance.zoom_correction_factor = 1.0;
127 m_params.emplace_back( new PARAM<double>( "appearance.zoom_correction_factor",
128 &m_Appearance.zoom_correction_factor, 1.0, 0.1, 10.0 ) );
129
130 m_params.emplace_back( new PARAM<bool>( "auto_backup.enabled", &m_Backup.enabled, true ) );
131
132 m_params.emplace_back( new PARAM_ENUM<BACKUP_FORMAT>( "auto_backup.format", &m_Backup.format,
134
135 m_params.emplace_back( new PARAM_ENUM<BACKUP_LOCATION>( "auto_backup.location",
138
139 m_params.emplace_back( new PARAM<unsigned long long>( "auto_backup.limit_total_size",
140 &m_Backup.limit_total_size, 104857600 ) );
141
142 auto envVarsParam = m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "environment.vars",
143 [&]() -> nlohmann::json
144 {
145 nlohmann::json ret = nlohmann::json::object();
146
147 for( const std::pair<wxString, ENV_VAR_ITEM> entry : m_Env.vars )
148 {
149 const ENV_VAR_ITEM& var = entry.second;
150
151 wxASSERT( entry.first == var.GetKey() );
152
153 // Default values are never persisted
154 if( var.IsDefault() )
155 {
156 wxLogTrace( traceEnvVars,
157 wxS( "COMMON_SETTINGS: Env var %s skipping save (default)" ),
158 var.GetKey() );
159 continue;
160 }
161
162 wxString value = var.GetValue();
163
164 value.Trim( true ).Trim( false ); // Trim from both sides
165
166 // Vars that existed in JSON are persisted, but if they were overridden
167 // externally, we persist the old value (i.e. the one that was loaded from JSON)
168 if( var.GetDefinedExternally() )
169 {
170 if( var.GetDefinedInSettings() )
171 {
172 wxLogTrace( traceEnvVars,
173 wxS( "COMMON_SETTINGS: Env var %s was overridden "
174 "externally, saving previously-loaded value %s" ),
175 var.GetKey(), var.GetSettingsValue() );
176 value = var.GetSettingsValue();
177 }
178 else
179 {
180 wxLogTrace( traceEnvVars,
181 wxS( "COMMON_SETTINGS: Env var %s skipping save "
182 "(external)" ),
183 var.GetKey() );
184 continue;
185 }
186 }
187
188 wxLogTrace( traceEnvVars,
189 wxS( "COMMON_SETTINGS: Saving env var %s = %s" ),
190 var.GetKey(), value);
191
192 std::string key( var.GetKey().Trim( true ).Trim( false ).ToUTF8() );
193 ret[ std::move( key ) ] = value;
194 }
195
196 return ret;
197 },
198 [&]( const nlohmann::json& aJson )
199 {
200 if( !aJson.is_object() )
201 return;
202
203 for( const auto& entry : aJson.items() )
204 {
205 wxString key = wxString( entry.key().c_str(), wxConvUTF8 ).Trim( true ).Trim( false );
206 wxString val = entry.value().get<wxString>().Trim( true ).Trim( false );
207
208 if( m_Env.vars.count( key ) )
209 {
210 if( m_Env.vars[key].GetDefinedExternally() )
211 {
212 wxLogTrace( traceEnvVars,
213 wxS( "COMMON_SETTINGS: %s is defined externally" ),
214 key );
215 m_Env.vars[key].SetDefinedInSettings();
216 m_Env.vars[key].SetSettingsValue( val );
217 continue;
218 }
219 else
220 {
221 wxLogTrace( traceEnvVars,
222 wxS( "COMMON_SETTINGS: Updating %s: %s -> %s"),
223 key, m_Env.vars[key].GetValue(), val );
224 m_Env.vars[key].SetValue( val );
225 }
226 }
227 else
228 {
229 wxLogTrace( traceEnvVars,
230 wxS( "COMMON_SETTINGS: Loaded new var: %s = %s" ),
231 key, val );
232 m_Env.vars[key] = ENV_VAR_ITEM( key, val );
233 }
234
235 m_Env.vars[key].SetDefinedInSettings();
236 m_Env.vars[key].SetSettingsValue( val );
237 }
238 },
239 {} ) );
240 envVarsParam->SetClearUnknownKeys();
241
242 m_params.emplace_back( new PARAM<bool>( "input.focus_follow_sch_pcb",
243 &m_Input.focus_follow_sch_pcb, false ) );
244
245 m_params.emplace_back( new PARAM<bool>( "input.auto_pan", &m_Input.auto_pan, false ) );
246
247 m_params.emplace_back( new PARAM<int>( "input.auto_pan_acceleration",
248 &m_Input.auto_pan_acceleration, 5 ) );
249
250 m_params.emplace_back( new PARAM<bool>( "input.center_on_zoom",
251 &m_Input.center_on_zoom, true ) );
252
253 m_params.emplace_back( new PARAM<bool>( "input.immediate_actions",
254 &m_Input.immediate_actions, true ) );
255
256 m_params.emplace_back( new PARAM<bool>( "input.warp_mouse_on_move",
257 &m_Input.warp_mouse_on_move, true ) );
258
259 m_params.emplace_back( new PARAM<bool>( "input.horizontal_pan",
260 &m_Input.horizontal_pan, true ) );
261
262 m_params.emplace_back( new PARAM<bool>( "input.hotkey_feedback",
263 &m_Input.hotkey_feedback, true ) );
264
265 m_params.emplace_back( new PARAM<bool>( "input.zoom_acceleration",
266 &m_Input.zoom_acceleration, false ) );
267
268#ifdef __WXMAC__
269 int default_zoom_speed = 5;
270#else
271 int default_zoom_speed = 1;
272#endif
273
274 m_params.emplace_back( new PARAM<int>( "input.zoom_speed",
275 &m_Input.zoom_speed, default_zoom_speed ) );
276
277 m_params.emplace_back( new PARAM<bool>( "input.zoom_speed_auto",
278 &m_Input.zoom_speed_auto, true ) );
279
280#ifdef __WXMSW__
281 constexpr TOUCHPAD_MODE defaultTouchpadMode = TOUCHPAD_MODE::NATIVE_GESTURES;
282#else
283 constexpr TOUCHPAD_MODE defaultTouchpadMode = TOUCHPAD_MODE::SCROLL_GESTURES;
284#endif
285
286 m_params.emplace_back( new PARAM_ENUM<TOUCHPAD_MODE>( "input.touchpad_mode",
287 &m_Input.touchpad_mode, defaultTouchpadMode, TOUCHPAD_MODE::NATIVE_GESTURES,
289
290 m_params.emplace_back( new PARAM<int>( "input.scroll_modifier_zoom",
291 &m_Input.scroll_modifier_zoom, 0 ) );
292
293 m_params.emplace_back( new PARAM<int>( "input.scroll_modifier_pan_h",
294 &m_Input.scroll_modifier_pan_h, WXK_CONTROL ) );
295
296 m_params.emplace_back( new PARAM<int>( "input.scroll_modifier_pan_v",
297 &m_Input.scroll_modifier_pan_v, WXK_SHIFT ) );
298
299 m_params.emplace_back( new PARAM<int>( "input.motion_pan_modifier",
300 &m_Input.motion_pan_modifier, 0 ) );
301
302 m_params.emplace_back( new PARAM<bool>( "input.reverse_scroll_zoom",
303 &m_Input.reverse_scroll_zoom, false ) );
304
305 m_params.emplace_back( new PARAM<bool>( "input.reverse_scroll_pan_h",
306 &m_Input.reverse_scroll_pan_h, false ) );
307
308 m_params.emplace_back( new PARAM_ENUM<MOUSE_DRAG_ACTION>( "input.mouse_left",
311
312 m_params.emplace_back( new PARAM_ENUM<MOUSE_DRAG_ACTION>( "input.mouse_middle",
315
316 m_params.emplace_back( new PARAM_ENUM<MOUSE_DRAG_ACTION>( "input.mouse_right",
319
320 m_params.emplace_back( new PARAM<int>( "spacemouse.rotate_speed",
321 &m_SpaceMouse.rotate_speed, 5, 1, 10 ) );
322
323 m_params.emplace_back( new PARAM<int>( "spacemouse.pan_speed",
324 &m_SpaceMouse.pan_speed, 5, 1, 10 ) );
325
326 m_params.emplace_back( new PARAM<bool>( "spacemouse.reverse_rotate",
327 &m_SpaceMouse.reverse_rotate, false ) );
328
329 m_params.emplace_back( new PARAM<bool>( "spacemouse.reverse_pan_x",
330 &m_SpaceMouse.reverse_pan_x, false ) );
331
332 m_params.emplace_back( new PARAM<bool>( "spacemouse.reverse_pan_y",
333 &m_SpaceMouse.reverse_pan_y, false ) );
334
335 m_params.emplace_back( new PARAM<bool>( "spacemouse.reverse_zoom",
336 &m_SpaceMouse.reverse_zoom, false ) );
337
338 m_params.emplace_back( new PARAM<int>( "graphics.canvas_type",
339 &m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) );
340
341 m_params.emplace_back( new PARAM<int>( "graphics.antialiasing_mode",
342 &m_Graphics.aa_mode, 2, 0, 2 ) );
343
344 m_params.emplace_back( new PARAM<int>( "system.local_history_debounce",
345 &m_System.local_history_debounce, 5, 0, 100000 ) );
346
347#ifdef __WXMAC__
348 m_params.emplace_back( new PARAM<wxString>( "system.text_editor",
349 &m_System.text_editor, wxS( "/usr/bin/open -e" ) ) );
350#else
351 m_params.emplace_back( new PARAM<wxString>( "system.text_editor",
352 &m_System.text_editor, wxS( "" ) ) );
353#endif
354
355#if defined( __WINDOWS__ )
356 m_params.emplace_back( new PARAM<wxString>( "system.file_explorer",
357 &m_System.file_explorer, wxS( "explorer.exe /n,/select,%F" ) ) );
358#else
359 m_params.emplace_back( new PARAM<wxString>( "system.file_explorer",
360 &m_System.file_explorer, wxS( "" ) ) );
361#endif
362
363 m_params.emplace_back( new PARAM<int>( "system.file_history_size",
364 &m_System.file_history_size, 9 ) );
365
366 m_params.emplace_back( new PARAM<wxString>( "system.language",
367 &m_System.language, wxS( "Default" ) ) );
368
369 m_params.emplace_back( new PARAM<wxString>( "system.pdf_viewer_name",
370 &m_System.pdf_viewer_name, wxS( "" ) ) );
371
372 m_params.emplace_back( new PARAM<bool>( "system.use_system_pdf_viewer",
373 &m_System.use_system_pdf_viewer, true ) );
374
375 m_params.emplace_back( new PARAM<wxString>( "system.working_dir",
376 &m_System.working_dir, wxS( "" ) ) );
377
378 m_params.emplace_back( new PARAM<int>( "system.clear_3d_cache_interval",
379 &m_System.clear_3d_cache_interval, 30 ) );
380
381 m_params.emplace_back( new PARAM<bool>( "do_not_show_again.zone_fill_warning",
382 &m_DoNotShowAgain.zone_fill_warning, false ) );
383
384 m_params.emplace_back( new PARAM<bool>( "do_not_show_again.env_var_overwrite_warning",
385 &m_DoNotShowAgain.env_var_overwrite_warning, false ) );
386
387 m_params.emplace_back( new PARAM<bool>( "do_not_show_again.scaled_3d_models_warning",
388 &m_DoNotShowAgain.scaled_3d_models_warning, false ) );
389
390 m_params.emplace_back( new PARAM<bool>( "do_not_show_again.data_collection_prompt",
391 &m_DoNotShowAgain.data_collection_prompt, false ) );
392
393 m_params.emplace_back( new PARAM<bool>( "do_not_show_again.update_check_prompt",
394 &m_DoNotShowAgain.update_check_prompt, false ) );
395
396 m_params.emplace_back( new PARAM<bool>( "do_not_show_again.migrate_wrl_prompt",
397 &m_DoNotShowAgain.migrate_wrl_prompt, false ) );
398
399 m_params.emplace_back( new PARAM<bool>( "embed_file_defaults.datasheet", &m_EmbedFileDefaults.datasheet, true ) );
400
401 m_params.emplace_back(
402 new PARAM<bool>( "embed_file_defaults.drawing_sheet", &m_EmbedFileDefaults.drawing_sheet, true ) );
403
404 m_params.emplace_back( new PARAM<bool>( "embed_file_defaults.model_3d", &m_EmbedFileDefaults.model_3d, false ) );
405
406 m_params.emplace_back( new PARAM<bool>( "embed_file_defaults.sim_model", &m_EmbedFileDefaults.sim_model, false ) );
407
408 m_params.emplace_back( new PARAM_LIST<wxString>( "system.extra_3d_search_dirs",
409 &m_Extra3DSearchDirs, {} ) );
410
411 m_params.emplace_back( new PARAM_LIST<wxString>( "system.declined_model_preview_requirements",
412 &m_DeclinedModelPreviewRequirements, {} ) );
413
414 m_params.emplace_back( new PARAM<bool>( "session.remember_open_files",
415 &m_Session.remember_open_files, false ) );
416
417 m_params.emplace_back( new PARAM_LIST<wxString>( "session.pinned_symbol_libs",
418 &m_Session.pinned_symbol_libs, {} ) );
419
420 m_params.emplace_back( new PARAM_LIST<wxString>( "session.pinned_fp_libs",
421 &m_Session.pinned_fp_libs, {} ) );
422
423 m_params.emplace_back( new PARAM_LIST<wxString>( "session.pinned_design_block_libs",
424 &m_Session.pinned_design_block_libs, {} ) );
425
426 m_params.emplace_back( new PARAM_LAMBDA<std::string>( "fields.template_field_names",
427 [&]() -> std::string
428 {
429 if( m_FieldNameTemplates.GetTemplateFieldNames( TEMPLATES::SCOPE::GLOBAL ).empty() )
430 return {};
431
432 STRING_FORMATTER formatter;
433 m_FieldNameTemplates.Format( &formatter, TEMPLATES::SCOPE::GLOBAL );
434 return formatter.GetString();
435 },
436 [&]( const std::string& aSerializedTemplates )
437 {
438 m_FieldNameTemplates.DeleteFieldNameTemplates( TEMPLATES::SCOPE::GLOBAL );
439
440 if( !aSerializedTemplates.empty() )
441 {
442 m_FieldNameTemplates.AddTemplateFieldNames(
443 wxString::FromUTF8( aSerializedTemplates ), TEMPLATES::SCOPE::GLOBAL );
444 }
445 }, {} ) );
446
447 m_params.emplace_back( new PARAM<int>( "package_manager.sash_pos",
448 &m_PackageManager.sash_pos, 380 ) );
449
450 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "git.repositories",
451 [&]() -> nlohmann::json
452 {
453 nlohmann::json ret = nlohmann::json::array();
454
455 for( const GIT_REPOSITORY& repo : m_Git.repositories )
456 {
457 nlohmann::json repoJson = {};
458
459 repoJson["name"] = repo.name;
460 repoJson["path"] = repo.path;
461 repoJson["authType"] = repo.authType;
462 repoJson["username"] = repo.username;
463 repoJson["ssh_path"] = repo.ssh_path;
464 repoJson["active"] = repo.active;
465
466 ret.push_back( repoJson );
467 }
468
469 return ret;
470 },
471 [&]( const nlohmann::json& aJson )
472 {
473 if( !aJson.is_array() )
474 return;
475
476 m_Git.repositories.clear();
477
478 for( const auto& repoJson : aJson )
479 {
480 GIT_REPOSITORY repo;
481
482 repo.name = repoJson["name"].get<wxString>();
483 repo.path = repoJson["path"].get<wxString>();
484 repo.authType = repoJson["authType"].get<wxString>();
485 repo.username = repoJson["username"].get<wxString>();
486 repo.ssh_path = repoJson["ssh_path"].get<wxString>();
487 repo.active = repoJson["active"].get<bool>();
488 repo.checkValid = true;
489
490 m_Git.repositories.push_back( repo );
491 }
492 },
493 {} ) );
494
495 m_params.emplace_back( new PARAM<wxString>( "git.authorName",
496 &m_Git.authorName, wxS( "" ) ) );
497
498 m_params.emplace_back( new PARAM<wxString>( "git.authorEmail",
499 &m_Git.authorEmail, wxS( "" ) ) );
500
501 m_params.emplace_back( new PARAM<bool>( "git.useDefaultAuthor",
502 &m_Git.useDefaultAuthor, true ) );
503
504 m_params.emplace_back( new PARAM<bool>( "git.enableGit",
505 &m_Git.enableGit, true ) );
506
507 m_params.emplace_back( new PARAM<int>( "git.updatInterval",
508 &m_Git.updatInterval, 5 ) );
509
510 m_params.emplace_back( new PARAM<wxString>( "api.interpreter_path",
511 &m_Api.python_interpreter, wxS( "" ) ) );
512
513 m_params.emplace_back( new PARAM<bool>( "api.enable_server",
514 &m_Api.enable_server, false ) );
515
516 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "dialog.controls",
517 [&]() -> nlohmann::json
518 {
519 nlohmann::json ret = nlohmann::json::object();
520
521 for( const auto& dlg : m_csInternals->m_dialogControlValues )
522 ret[ dlg.first ] = dlg.second;
523
524 return ret;
525 },
526 [&]( const nlohmann::json& aVal )
527 {
528 m_csInternals->m_dialogControlValues.clear();
529
530 if( !aVal.is_object() )
531 return;
532
533 for( auto& [dlgKey, dlgVal] : aVal.items() )
534 {
535 if( !dlgVal.is_object() )
536 continue;
537
538 for( auto& [ctrlKey, ctrlVal] : dlgVal.items() )
539 m_csInternals->m_dialogControlValues[ dlgKey ][ ctrlKey ] = ctrlVal;
540 }
541 },
542 nlohmann::json::object() ) );
543
544 // Let the save drop entries for dialogs and controls that no longer exist
545 m_params.back()->SetClearUnknownKeys();
546
547 registerMigration( 0, 1, std::bind( &COMMON_SETTINGS::migrateSchema0to1, this ) );
548 registerMigration( 1, 2, std::bind( &COMMON_SETTINGS::migrateSchema1to2, this ) );
549 registerMigration( 2, 3, std::bind( &COMMON_SETTINGS::migrateSchema2to3, this ) );
550 registerMigration( 3, 4, std::bind( &COMMON_SETTINGS::migrateSchema3to4, this ) );
551 registerMigration( 4, 5, std::bind( &COMMON_SETTINGS::migrateSchema4to5, this ) );
552 registerMigration( 5, 6, std::bind( &COMMON_SETTINGS::migrateSchema5to6, this ) );
553 registerMigration( 6, 7, std::bind( &COMMON_SETTINGS::migrateSchema6to7, this ) );
554}
555
556
558{
564
565 nlohmann::json::json_pointer mwp_pointer( "/input/mousewheel_pan"_json_pointer );
566
567 bool mwp = false;
568
569 try
570 {
571 mwp = m_internals->at( mwp_pointer );
572 m_internals->At( "input" ).erase( "mousewheel_pan" );
573 }
574 catch( ... )
575 {
576 wxLogTrace( traceSettings,
577 wxT( "COMMON_SETTINGS::Migrate 0->1: mousewheel_pan not found" ) );
578 }
579
580 if( mwp )
581 {
582 ( *m_internals )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = true;
583 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] = WXK_SHIFT;
584 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] = 0;
585 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = WXK_CONTROL;
586 }
587 else
588 {
589 ( *m_internals )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = false;
590 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] = WXK_CONTROL;
591 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] = WXK_SHIFT;
592 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = 0;
593 }
594
595 return true;
596}
597
598
600{
601 nlohmann::json::json_pointer v1_pointer( "/input/prefer_select_to_drag"_json_pointer );
602
603 bool prefer_selection = false;
604
605 try
606 {
607 prefer_selection = m_internals->at( v1_pointer );
608 m_internals->at( nlohmann::json::json_pointer( "/input"_json_pointer ) ).erase( "prefer_select_to_drag" );
609 }
610 catch( ... )
611 {
612 wxLogTrace( traceSettings, wxT( "COMMON_SETTINGS::Migrate 1->2: prefer_select_to_drag not found" ) );
613 }
614
615 if( prefer_selection )
616 ( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] = MOUSE_DRAG_ACTION::SELECT;
617 else
618 ( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] = MOUSE_DRAG_ACTION::DRAG_ANY;
619
620 return true;
621}
622
623
625{
626 wxFileName cfgpath;
627 cfgpath.AssignDir( PATHS::GetUserSettingsPath() );
628 cfgpath.AppendDir( wxT( "3d" ) );
629 cfgpath.SetFullName( wxS( "3Dresolver.cfg" ) );
630 cfgpath.MakeAbsolute();
631
632 std::vector<LEGACY_3D_SEARCH_PATH> legacyPaths;
633 readLegacy3DResolverCfg( cfgpath.GetFullPath(), legacyPaths );
634
635 // env variables have a limited allowed character set for names
636 wxRegEx nonValidCharsRegex( wxS( "[^A-Z0-9_]+" ), wxRE_ADVANCED );
637
638 for( const LEGACY_3D_SEARCH_PATH& path : legacyPaths )
639 {
640 wxString key = path.m_Alias;
641 const wxString& val = path.m_Pathvar;
642
643 // The 3d alias config didn't use the same naming restrictions as real env variables
644 // We need to sanitize them
645
646 // upper case only
647 key.MakeUpper();
648
649 // logically swap - with _
650 key.Replace( wxS( "-" ), wxS( "_" ) );
651
652 // remove any other chars
653 nonValidCharsRegex.Replace( &key, wxEmptyString );
654
655 if( !m_Env.vars.count( key ) )
656 {
657 wxLogTrace( traceEnvVars, wxS( "COMMON_SETTINGS: Loaded new var: %s = %s" ), key, val );
658 m_Env.vars[key] = ENV_VAR_ITEM( key, val );
659 }
660 }
661
662 if( cfgpath.FileExists() )
663 {
664 wxRemoveFile( cfgpath.GetFullPath() );
665 }
666
667 return true;
668}
669
670
672{
673 // >= 10 = add 1
674 try
675 {
676 // Update netclass panel shown columns for eeschema
677 const nlohmann::json::json_pointer v3_pointer_eeschema( "/netclass_panel/eeschema_shown_columns"_json_pointer );
678 wxString eeSchemaColumnList_old = m_internals->at( v3_pointer_eeschema );
679
680 wxStringTokenizer eeSchemaShownTokens( eeSchemaColumnList_old, " \t\r\n" );
681 wxString eeSchemaColumnList_new;
682
683 while( eeSchemaShownTokens.HasMoreTokens() )
684 {
685 long colNumber;
686 eeSchemaShownTokens.GetNextToken().ToLong( &colNumber );
687
688 if( colNumber >= 10 )
689 ++colNumber;
690
691 eeSchemaColumnList_new += wxString::Format( wxT( "%ld " ), colNumber );
692 }
693
694 eeSchemaColumnList_new.Trim( true );
695 eeSchemaColumnList_new.Trim( false );
696
697 m_internals->at( v3_pointer_eeschema ) = eeSchemaColumnList_new.ToUTF8();
698
699 // Update netclass panel shown columns for pcbnew
700 const nlohmann::json::json_pointer v3_pointer_pcbnew( "/netclass_panel/pcbnew_shown_columns"_json_pointer );
701 wxString pcbnewColumnList_old = m_internals->at( v3_pointer_pcbnew );
702
703 wxStringTokenizer pcbnewShownTokens( pcbnewColumnList_old, " \t\r\n" );
704 wxString pcbnewColumnList_new;
705
706 while( pcbnewShownTokens.HasMoreTokens() )
707 {
708 long colNumber;
709 pcbnewShownTokens.GetNextToken().ToLong( &colNumber );
710
711 if( colNumber >= 10 )
712 ++colNumber;
713
714 pcbnewColumnList_new += wxString::Format( wxT( "%ld " ), colNumber );
715 }
716
717 pcbnewColumnList_new.Trim( true );
718 pcbnewColumnList_new.Trim( false );
719
720 m_internals->at( v3_pointer_pcbnew ) = pcbnewColumnList_new.ToUTF8();
721 }
722 catch( ... )
723 {
724 wxLogTrace( traceSettings, wxT( "COMMON_SETTINGS::Migrate 3->4: /netclass_panel/shown_columns not found" ) );
725 }
726
727 return true;
728}
729
730
732{
733 try
734 {
735 nlohmann::json& controls = m_internals->At( "dialog" ).at( "controls" );
736
737 for( auto& [dlgKey, dlgVal] : controls.items() )
738 {
739 if( !dlgVal.is_object() )
740 continue;
741
742 auto geoIt = dlgVal.find( "__geometry" );
743
744 if( geoIt == dlgVal.end() || !geoIt->is_object() )
745 continue;
746
747 nlohmann::json& geom = *geoIt;
748
749 // Legacy values were stored in logical pixels. Convert to DIP using the
750 // primary display's scale factor (best approximation without window context).
751 int w = geom.value( "w", 0 );
752 int h = geom.value( "h", 0 );
753
754 wxSize dipSize = wxWindow::ToDIP( wxSize( w, h ), nullptr );
755 geom[ "w" ] = dipSize.x;
756 geom[ "h" ] = dipSize.y;
757
758 geom.erase( "dip" );
759 }
760 }
761 catch( ... )
762 {
763 wxLogTrace( traceSettings, wxT( "COMMON_SETTINGS::Migrate 4->5: dialog.controls not found" ) );
764 }
765
766 return true;
767}
768
769
771{
772 // Schema 6 introduces auto_backup.format and auto_backup.location. Pre-schema-6
773 // installs unconditionally produced timestamped zip archives whenever a save was
774 // eligible for backup, so the new INCREMENTAL default would silently disable archive
775 // creation for users who already had auto_backup.enabled set. Write ZIP into the
776 // upgraded config to preserve their backup behavior; new installs skip the migration
777 // path entirely and keep the new default. The location default (PROJECT_DIR) already
778 // matches the legacy on-disk layout, so we leave it absent.
779 try
780 {
781 if( !Contains( "auto_backup.format" ) )
782 Set<int>( "auto_backup.format", static_cast<int>( BACKUP_FORMAT::ZIP ) );
783 }
784 catch( ... )
785 {
786 wxLogTrace( traceSettings, wxT( "COMMON_SETTINGS::Migrate 5->6: failed to set auto_backup.format" ) );
787 }
788
789 return true;
790}
791
792
794{
795 // Global field name templates used to be stored in eeschema.json. Import them here so
796 // applications which do not load Eeschema can use them immediately after upgrading.
797 if( Contains( "fields.template_field_names" ) )
798 return true;
799
800 wxFileName eeschemaPath( PATHS::GetUserSettingsPath(), wxS( "eeschema.json" ) );
801
802 if( !eeschemaPath.IsFileReadable() )
803 return true;
804
805 try
806 {
807 std::ifstream eeschemaFile( eeschemaPath.GetFullPath().fn_str() );
808 nlohmann::json eeschemaSettings = nlohmann::json::parse( eeschemaFile, nullptr, ALLOW_EXCEPTIONS,
810
811 const nlohmann::json::json_pointer fieldNamesPointer( "/drawing/field_names"_json_pointer );
812
813 if( eeschemaSettings.contains( fieldNamesPointer )
814 && eeschemaSettings.at( fieldNamesPointer ).is_string() )
815 {
816 Set<std::string>( "fields.template_field_names",
817 eeschemaSettings.at( fieldNamesPointer ).get<std::string>() );
818 }
819 }
820 catch( ... )
821 {
822 wxLogTrace( traceSettings, wxT( "COMMON_SETTINGS::Migrate 6->7: failed to import field name templates" ) );
823 }
824
825 return true;
826}
827
828
829bool COMMON_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
830{
831 bool ret = true;
832
833 ret &= fromLegacy<double>( aCfg, "CanvasScale", "appearance.canvas_scale" );
834 ret &= fromLegacy<int>( aCfg, "IconScale", "appearance.icon_scale" );
835 ret &= fromLegacy<bool>( aCfg, "UseIconsInMenus", "appearance.use_icons_in_menus" );
836 ret &= fromLegacy<bool>( aCfg, "ShowEnvVarWarningDialog", "environment.show_warning_dialog" );
837
838 auto load_env_vars =
839 [&]()
840 {
841 wxString key, value;
842 long index = 0;
843 nlohmann::json::json_pointer ptr = m_internals->PointerFromString( "environment.vars" );
844
845 aCfg->SetPath( "EnvironmentVariables" );
846 ( *m_internals )[ptr] = nlohmann::json( {} );
847
848 while( aCfg->GetNextEntry( key, index ) )
849 {
850 if( versionedEnvVarRegex.Matches( key ) )
851 {
852 wxLogTrace( traceSettings,
853 wxT( "Migrate Env: %s is blacklisted; skipping." ), key );
854 continue;
855 }
856
857 value = aCfg->Read( key, wxEmptyString );
858
859 if( !value.IsEmpty() )
860 {
861 ptr.push_back( key.ToStdString() );
862
863 wxLogTrace( traceSettings, wxT( "Migrate Env: %s=%s" ),
864 ptr.to_string(), value );
865 ( *m_internals )[ptr] = value.ToUTF8();
866
867 ptr.pop_back();
868 }
869 }
870
871 aCfg->SetPath( ".." );
872 };
873
874 load_env_vars();
875
876 bool mousewheel_pan = false;
877
878 if( aCfg->Read( "MousewheelPAN", &mousewheel_pan ) && mousewheel_pan )
879 {
880 Set( "input.horizontal_pan", true );
881 Set( "input.scroll_modifier_pan_h", static_cast<int>( WXK_SHIFT ) );
882 Set( "input.scroll_modifier_pan_v", 0 );
883 Set( "input.scroll_modifier_zoom", static_cast<int>( WXK_CONTROL ) );
884 }
885
886 ret &= fromLegacy<bool>( aCfg, "AutoPAN", "input.auto_pan" );
887 ret &= fromLegacy<bool>( aCfg, "ImmediateActions", "input.immediate_actions" );
888 ret &= fromLegacy<bool>( aCfg, "PreferSelectionToDragging", "input.prefer_select_to_drag" );
889 ret &= fromLegacy<bool>( aCfg, "MoveWarpsCursor", "input.warp_mouse_on_move" );
890 ret &= fromLegacy<bool>( aCfg, "ZoomNoCenter", "input.center_on_zoom" );
891
892 // This was stored inverted in legacy config
893 if( std::optional<bool> value = Get<bool>( "input.center_on_zoom" ) )
894 Set( "input.center_on_zoom", !( *value ) );
895
896 ret &= fromLegacy<int>( aCfg, "OpenGLAntialiasingMode", "graphics.antialiasing_mode" );
897
898 // Cairo anti-aliasing modes no longer supported
899 //ret &= fromLegacy<int>( aCfg, "CairoAntialiasingMode", "graphics.cairo_antialiasing_mode" );
900
901 ret &= fromLegacy<int>( aCfg, "AutoSaveInterval", "system.local_history_debounce" );
902 ret &= fromLegacyString( aCfg, "Editor", "system.text_editor" );
903 ret &= fromLegacy<int>( aCfg, "FileHistorySize", "system.file_history_size" );
904 ret &= fromLegacyString( aCfg, "LanguageID", "system.language" );
905 ret &= fromLegacyString( aCfg, "PdfBrowserName", "system.pdf_viewer_name" );
906 ret &= fromLegacy<bool>( aCfg, "UseSystemBrowser", "system.use_system_pdf_viewer" );
907 ret &= fromLegacyString( aCfg, "WorkingDir", "system.working_dir" );
908
909 return ret;
910}
911
912
914{
915 auto addVar =
916 [&]( const wxString& aKey, const wxString& aDefault )
917 {
918 m_Env.vars[aKey] = ENV_VAR_ITEM( aKey, aDefault, aDefault );
919
920 wxString envValue;
921
922 if( wxGetEnv( aKey, &envValue ) == true && !envValue.IsEmpty() )
923 {
924 m_Env.vars[aKey].SetValue( envValue );
925 m_Env.vars[aKey].SetDefinedExternally();
926 wxLogTrace( traceEnvVars, wxS( "InitializeEnvironment: Entry %s defined externally as %s" ),
927 aKey, envValue );
928 }
929 else
930 {
931 wxLogTrace( traceEnvVars, wxS( "InitializeEnvironment: Setting entry %s to default %s" ),
932 aKey, aDefault );
933 }
934 };
935
936 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "FOOTPRINT_DIR" ) ), PATHS::GetStockFootprintsPath() );
937 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "3DMODEL_DIR" ) ), PATHS::GetStock3dmodelsPath() );
938 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "TEMPLATE_DIR" ) ), PATHS::GetStockTemplatesPath() );
939 addVar( wxT( "KICAD_USER_TEMPLATE_DIR" ), PATHS::GetUserTemplatesPath() );
940 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "3RD_PARTY" ) ), PATHS::GetDefault3rdPartyPath() );
941 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "SYMBOL_DIR" ) ), PATHS::GetStockSymbolsPath() );
942 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "DESIGN_BLOCK_DIR" ) ), PATHS::GetStockDesignBlocksPath() );
943}
944
945
947 std::vector<LEGACY_3D_SEARCH_PATH>& aSearchPaths )
948{
949 wxFileName cfgpath( path );
950
951 // This should be the same as wxWidgets 3.0 wxPATH_NORM_ALL which is deprecated in 3.1.
952 // There are known issues with environment variable expansion so maybe we should be using
953 // our own ExpandEnvVarSubstitutions() here instead.
954 cfgpath.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS );
955 wxString cfgname = cfgpath.GetFullPath();
956
957 std::ifstream cfgFile;
958 std::string cfgLine;
959
960 if( !wxFileName::Exists( cfgname ) )
961 {
962 std::ostringstream ostr;
963 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
964 wxString errmsg = "no 3D configuration file";
965 ostr << " * " << errmsg.ToUTF8() << " '";
966 ostr << cfgname.ToUTF8() << "'";
967 wxLogTrace( traceSettings, "%s\n", ostr.str().c_str() );
968 return false;
969 }
970
971 cfgFile.open( cfgname.ToUTF8() );
972
973 if( !cfgFile.is_open() )
974 {
975 std::ostringstream ostr;
976 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
977 wxString errmsg = wxS( "Could not open configuration file" );
978 ostr << " * " << errmsg.ToUTF8() << " '" << cfgname.ToUTF8() << "'";
979 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
980 return false;
981 }
982
983 int lineno = 0;
985 size_t idx;
986 int vnum = 0; // version number
987
988 while( cfgFile.good() )
989 {
990 cfgLine.clear();
991 std::getline( cfgFile, cfgLine );
992 ++lineno;
993
994 if( cfgLine.empty() )
995 {
996 if( cfgFile.eof() )
997 break;
998
999 continue;
1000 }
1001
1002 if( 1 == lineno && cfgLine.compare( 0, 2, "#V" ) == 0 )
1003 {
1004 // extract the version number and parse accordingly
1005 if( cfgLine.size() > 2 )
1006 {
1007 std::istringstream istr;
1008 istr.str( cfgLine.substr( 2 ) );
1009 istr >> vnum;
1010 }
1011
1012 continue;
1013 }
1014
1015 idx = 0;
1016
1017 if( !getLegacy3DHollerith( cfgLine, idx, al.m_Alias ) )
1018 continue;
1019
1020 // Don't add KICADn_3DMODEL_DIR, one of its legacy equivalents, or KIPRJMOD from a
1021 // config file. They're system variables which are defined at runtime.
1022 wxString versionedPath = wxString::Format( wxS( "${%s}" ),
1023 ENV_VAR::GetVersionedEnvVarName( wxS( "3DMODEL_DIR" ) ) );
1024
1025 if( al.m_Alias == versionedPath
1026 || al.m_Alias == wxS( "${KIPRJMOD}" )
1027 || al.m_Alias == wxS( "$(KIPRJMOD)" )
1028 || al.m_Alias == wxS( "${KISYS3DMOD}" )
1029 || al.m_Alias == wxS( "$(KISYS3DMOD)" ) )
1030 {
1031 continue;
1032 }
1033
1034 if( !getLegacy3DHollerith( cfgLine, idx, al.m_Pathvar ) )
1035 continue;
1036
1037 if( !getLegacy3DHollerith( cfgLine, idx, al.m_Description ) )
1038 continue;
1039
1040 aSearchPaths.push_back( al );
1041 }
1042
1043 cfgFile.close();
1044
1045 return true;
1046}
1047
1048
1049bool COMMON_SETTINGS::getLegacy3DHollerith( const std::string& aString, size_t& aIndex, wxString& aResult )
1050{
1051 aResult.clear();
1052
1053 if( aIndex >= aString.size() )
1054 {
1055 std::ostringstream ostr;
1056 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1057 wxString errmsg = wxS( "bad Hollerith string on line" );
1058 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1059 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1060
1061 return false;
1062 }
1063
1064 size_t i2 = aString.find( '"', aIndex );
1065
1066 if( std::string::npos == i2 )
1067 {
1068 std::ostringstream ostr;
1069 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1070 wxString errmsg = wxS( "missing opening quote mark in config file" );
1071 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1072 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1073
1074 return false;
1075 }
1076
1077 ++i2;
1078
1079 if( i2 >= aString.size() )
1080 {
1081 std::ostringstream ostr;
1082 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1083 wxString errmsg = wxS( "invalid entry (unexpected end of line)" );
1084 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1085 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1086
1087 return false;
1088 }
1089
1090 std::string tnum;
1091
1092 while( aString[i2] >= '0' && aString[i2] <= '9' )
1093 tnum.append( 1, aString[i2++] );
1094
1095 if( tnum.empty() || aString[i2++] != ':' )
1096 {
1097 std::ostringstream ostr;
1098 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1099 wxString errmsg = wxS( "bad Hollerith string on line" );
1100 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1101 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1102
1103 return false;
1104 }
1105
1106 std::istringstream istr;
1107 istr.str( tnum );
1108 size_t nchars;
1109 istr >> nchars;
1110
1111 if( ( i2 + nchars ) >= aString.size() )
1112 {
1113 std::ostringstream ostr;
1114 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1115 wxString errmsg = wxS( "invalid entry (unexpected end of line)" );
1116 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1117 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1118
1119 return false;
1120 }
1121
1122 if( nchars > 0 )
1123 {
1124 aResult = wxString::FromUTF8( aString.substr( i2, nchars ).c_str() );
1125 i2 += nchars;
1126 }
1127
1128 if( i2 >= aString.size() || aString[i2] != '"' )
1129 {
1130 std::ostringstream ostr;
1131 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1132 wxString errmsg = wxS( "missing closing quote mark in config file" );
1133 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1134 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1135
1136 return false;
1137 }
1138
1139 aIndex = i2 + 1;
1140 return true;
1141}
int index
SPACEMOUSE m_SpaceMouse
std::unique_ptr< COMMON_SETTINGS_INTERNALS > m_csInternals
APPEARANCE m_Appearance
virtual ~COMMON_SETTINGS()
static bool getLegacy3DHollerith(const std::string &aString, size_t &aIndex, wxString &aResult)
bool readLegacy3DResolverCfg(const wxString &aPath, std::vector< LEGACY_3D_SEARCH_PATH > &aSearchPaths)
PACKAGE_MANAGER m_PackageManager
void InitializeEnvironment()
Creates the built-in environment variables and sets their default values.
AUTO_BACKUP m_Backup
TEMPLATES m_FieldNameTemplates
Global field name templates shared by all project editors.
DO_NOT_SHOW_AGAIN m_DoNotShowAgain
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
@ GAL_TYPE_OPENGL
OpenGL implementation.
KiCad uses environment variables internally for determining the base paths for libraries,...
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
bool fromLegacy(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig 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...
bool Contains(const std::string &aPath) const
std::optional< ValueType > Get(const std::string &aPath) const
Fetches a value from within the JSON document.
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
JSON_SETTINGS(const wxString &aFilename, SETTINGS_LOC aLocation, int aSchemaVersion)
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals
Stores an enum as an integer.
Definition parameters.h:232
Like a normal param, but with custom getter and setter functions.
Definition parameters.h:299
static wxString GetStockSymbolsPath()
Gets the stock (install) symbols path.
Definition paths.cpp:300
static wxString GetUserTemplatesPath()
Gets the user path for custom templates.
Definition paths.cpp:71
static wxString GetDefault3rdPartyPath()
Gets the default path for PCM packages.
Definition paths.cpp:126
static wxString GetStock3dmodelsPath()
Gets the stock (install) 3dmodels path.
Definition paths.cpp:333
static wxString GetStockTemplatesPath()
Gets the stock (install) templates path.
Definition paths.cpp:355
static wxString GetUserSettingsPath()
Return the user configuration path used to store KiCad's configuration files.
Definition paths.cpp:624
static wxString GetStockDesignBlocksPath()
Gets the stock (install) footprints path.
Definition paths.cpp:322
static wxString GetStockFootprintsPath()
Gets the stock (install) footprints path.
Definition paths.cpp:311
Implement an OUTPUTFORMATTER to a memory buffer.
Definition richio.h:430
const std::string & GetString()
Definition richio.h:453
const int commonSchemaVersion
! Update the schema version whenever a migration is required
const wxRegEx versionedEnvVarRegex(wxS("KICAD[0-9]+_[A-Z0-9_]+(_DIR)?"))
! The following environment variables will never be migrated from a previous version
@ ZIP
Zip archive snapshots; autosave uses recovery files.
@ INCREMENTAL
Git-based local history (default)
TOUCHPAD_MODE
@ USER_DIR
Under the KiCad user data directory.
@ PROJECT_DIR
Inside the project directory (default)
Functions related to environment variables, including help functions.
const wxChar *const traceEnvVars
Flag to enable debug output of environment variable operations.
#define ALLOW_EXCEPTIONS
#define IGNORE_COMMENTS
template KICOMMON_API void JSON_SETTINGS::Set< std::string >(const std::string &aPath, std::string aValue)
SETTINGS_LOC
@ USER
The main config directory (e.g. ~/.config/kicad/)
#define traceSettings
KICOMMON_API wxString GetVersionedEnvVarName(const wxString &aBaseName)
Construct a versioned environment variable based on this KiCad major version.
Definition env_vars.cpp:78
STL namespace.
System directories search utilities.
std::string path
wxLogTrace helper definitions.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition wx_filename.h:35