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<bool>( "session.remember_open_files",
412 &m_Session.remember_open_files, false ) );
413
414 m_params.emplace_back( new PARAM_LIST<wxString>( "session.pinned_symbol_libs",
415 &m_Session.pinned_symbol_libs, {} ) );
416
417 m_params.emplace_back( new PARAM_LIST<wxString>( "session.pinned_fp_libs",
418 &m_Session.pinned_fp_libs, {} ) );
419
420 m_params.emplace_back( new PARAM_LIST<wxString>( "session.pinned_design_block_libs",
421 &m_Session.pinned_design_block_libs, {} ) );
422
423 m_params.emplace_back( new PARAM_LAMBDA<std::string>( "fields.template_field_names",
424 [&]() -> std::string
425 {
426 if( m_FieldNameTemplates.GetTemplateFieldNames( TEMPLATES::SCOPE::GLOBAL ).empty() )
427 return {};
428
429 STRING_FORMATTER formatter;
430 m_FieldNameTemplates.Format( &formatter, TEMPLATES::SCOPE::GLOBAL );
431 return formatter.GetString();
432 },
433 [&]( const std::string& aSerializedTemplates )
434 {
435 m_FieldNameTemplates.DeleteFieldNameTemplates( TEMPLATES::SCOPE::GLOBAL );
436
437 if( !aSerializedTemplates.empty() )
438 {
439 m_FieldNameTemplates.AddTemplateFieldNames(
440 wxString::FromUTF8( aSerializedTemplates ), TEMPLATES::SCOPE::GLOBAL );
441 }
442 }, {} ) );
443
444 m_params.emplace_back( new PARAM<int>( "package_manager.sash_pos",
445 &m_PackageManager.sash_pos, 380 ) );
446
447 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "git.repositories",
448 [&]() -> nlohmann::json
449 {
450 nlohmann::json ret = nlohmann::json::array();
451
452 for( const GIT_REPOSITORY& repo : m_Git.repositories )
453 {
454 nlohmann::json repoJson = {};
455
456 repoJson["name"] = repo.name;
457 repoJson["path"] = repo.path;
458 repoJson["authType"] = repo.authType;
459 repoJson["username"] = repo.username;
460 repoJson["ssh_path"] = repo.ssh_path;
461 repoJson["active"] = repo.active;
462
463 ret.push_back( repoJson );
464 }
465
466 return ret;
467 },
468 [&]( const nlohmann::json& aJson )
469 {
470 if( !aJson.is_array() )
471 return;
472
473 m_Git.repositories.clear();
474
475 for( const auto& repoJson : aJson )
476 {
477 GIT_REPOSITORY repo;
478
479 repo.name = repoJson["name"].get<wxString>();
480 repo.path = repoJson["path"].get<wxString>();
481 repo.authType = repoJson["authType"].get<wxString>();
482 repo.username = repoJson["username"].get<wxString>();
483 repo.ssh_path = repoJson["ssh_path"].get<wxString>();
484 repo.active = repoJson["active"].get<bool>();
485 repo.checkValid = true;
486
487 m_Git.repositories.push_back( repo );
488 }
489 },
490 {} ) );
491
492 m_params.emplace_back( new PARAM<wxString>( "git.authorName",
493 &m_Git.authorName, wxS( "" ) ) );
494
495 m_params.emplace_back( new PARAM<wxString>( "git.authorEmail",
496 &m_Git.authorEmail, wxS( "" ) ) );
497
498 m_params.emplace_back( new PARAM<bool>( "git.useDefaultAuthor",
499 &m_Git.useDefaultAuthor, true ) );
500
501 m_params.emplace_back( new PARAM<bool>( "git.enableGit",
502 &m_Git.enableGit, true ) );
503
504 m_params.emplace_back( new PARAM<int>( "git.updatInterval",
505 &m_Git.updatInterval, 5 ) );
506
507 m_params.emplace_back( new PARAM<wxString>( "api.interpreter_path",
508 &m_Api.python_interpreter, wxS( "" ) ) );
509
510 m_params.emplace_back( new PARAM<bool>( "api.enable_server",
511 &m_Api.enable_server, false ) );
512
513 m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "dialog.controls",
514 [&]() -> nlohmann::json
515 {
516 nlohmann::json ret = nlohmann::json::object();
517
518 for( const auto& dlg : m_csInternals->m_dialogControlValues )
519 ret[ dlg.first ] = dlg.second;
520
521 return ret;
522 },
523 [&]( const nlohmann::json& aVal )
524 {
525 m_csInternals->m_dialogControlValues.clear();
526
527 if( !aVal.is_object() )
528 return;
529
530 for( auto& [dlgKey, dlgVal] : aVal.items() )
531 {
532 if( !dlgVal.is_object() )
533 continue;
534
535 for( auto& [ctrlKey, ctrlVal] : dlgVal.items() )
536 m_csInternals->m_dialogControlValues[ dlgKey ][ ctrlKey ] = ctrlVal;
537 }
538 },
539 nlohmann::json::object() ) );
540
541 // Let the save drop entries for dialogs and controls that no longer exist
542 m_params.back()->SetClearUnknownKeys();
543
544 registerMigration( 0, 1, std::bind( &COMMON_SETTINGS::migrateSchema0to1, this ) );
545 registerMigration( 1, 2, std::bind( &COMMON_SETTINGS::migrateSchema1to2, this ) );
546 registerMigration( 2, 3, std::bind( &COMMON_SETTINGS::migrateSchema2to3, this ) );
547 registerMigration( 3, 4, std::bind( &COMMON_SETTINGS::migrateSchema3to4, this ) );
548 registerMigration( 4, 5, std::bind( &COMMON_SETTINGS::migrateSchema4to5, this ) );
549 registerMigration( 5, 6, std::bind( &COMMON_SETTINGS::migrateSchema5to6, this ) );
550 registerMigration( 6, 7, std::bind( &COMMON_SETTINGS::migrateSchema6to7, this ) );
551}
552
553
555{
561
562 nlohmann::json::json_pointer mwp_pointer( "/input/mousewheel_pan"_json_pointer );
563
564 bool mwp = false;
565
566 try
567 {
568 mwp = m_internals->at( mwp_pointer );
569 m_internals->At( "input" ).erase( "mousewheel_pan" );
570 }
571 catch( ... )
572 {
573 wxLogTrace( traceSettings,
574 wxT( "COMMON_SETTINGS::Migrate 0->1: mousewheel_pan not found" ) );
575 }
576
577 if( mwp )
578 {
579 ( *m_internals )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = true;
580 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] = WXK_SHIFT;
581 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] = 0;
582 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = WXK_CONTROL;
583 }
584 else
585 {
586 ( *m_internals )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = false;
587 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] = WXK_CONTROL;
588 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] = WXK_SHIFT;
589 ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = 0;
590 }
591
592 return true;
593}
594
595
597{
598 nlohmann::json::json_pointer v1_pointer( "/input/prefer_select_to_drag"_json_pointer );
599
600 bool prefer_selection = false;
601
602 try
603 {
604 prefer_selection = m_internals->at( v1_pointer );
605 m_internals->at( nlohmann::json::json_pointer( "/input"_json_pointer ) )
606 .erase( "prefer_select_to_drag" );
607 }
608 catch( ... )
609 {
610 wxLogTrace( traceSettings,
611 wxT( "COMMON_SETTINGS::Migrate 1->2: prefer_select_to_drag not found" ) );
612 }
613
614 if( prefer_selection )
615 ( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] = MOUSE_DRAG_ACTION::SELECT;
616 else
617 ( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] = MOUSE_DRAG_ACTION::DRAG_ANY;
618
619 return true;
620}
621
622
624{
625 wxFileName cfgpath;
626 cfgpath.AssignDir( PATHS::GetUserSettingsPath() );
627 cfgpath.AppendDir( wxT( "3d" ) );
628 cfgpath.SetFullName( wxS( "3Dresolver.cfg" ) );
629 cfgpath.MakeAbsolute();
630
631 std::vector<LEGACY_3D_SEARCH_PATH> legacyPaths;
632 readLegacy3DResolverCfg( cfgpath.GetFullPath(), legacyPaths );
633
634 // env variables have a limited allowed character set for names
635 wxRegEx nonValidCharsRegex( wxS( "[^A-Z0-9_]+" ), wxRE_ADVANCED );
636
637 for( const LEGACY_3D_SEARCH_PATH& path : legacyPaths )
638 {
639 wxString key = path.m_Alias;
640 const wxString& val = path.m_Pathvar;
641
642 // The 3d alias config didn't use the same naming restrictions as real env variables
643 // We need to sanitize them
644
645 // upper case only
646 key.MakeUpper();
647
648 // logically swap - with _
649 key.Replace( wxS( "-" ), wxS( "_" ) );
650
651 // remove any other chars
652 nonValidCharsRegex.Replace( &key, wxEmptyString );
653
654 if( !m_Env.vars.count( key ) )
655 {
656 wxLogTrace( traceEnvVars, wxS( "COMMON_SETTINGS: Loaded new var: %s = %s" ), key, val );
657 m_Env.vars[key] = ENV_VAR_ITEM( key, val );
658 }
659 }
660
661 if( cfgpath.FileExists() )
662 {
663 wxRemoveFile( cfgpath.GetFullPath() );
664 }
665
666 return true;
667}
668
669
671{
672 // >= 10 = add 1
673 try
674 {
675 // Update netclass panel shown columns for eeschema
676 const nlohmann::json::json_pointer v3_pointer_eeschema( "/netclass_panel/eeschema_shown_columns"_json_pointer );
677 wxString eeSchemaColumnList_old = m_internals->at( v3_pointer_eeschema );
678
679 wxStringTokenizer eeSchemaShownTokens( eeSchemaColumnList_old, " \t\r\n" );
680 wxString eeSchemaColumnList_new;
681
682 while( eeSchemaShownTokens.HasMoreTokens() )
683 {
684 long colNumber;
685 eeSchemaShownTokens.GetNextToken().ToLong( &colNumber );
686
687 if( colNumber >= 10 )
688 ++colNumber;
689
690 eeSchemaColumnList_new += wxString::Format( wxT( "%ld " ), colNumber );
691 }
692
693 eeSchemaColumnList_new.Trim( true );
694 eeSchemaColumnList_new.Trim( false );
695
696 m_internals->at( v3_pointer_eeschema ) = eeSchemaColumnList_new.ToUTF8();
697
698 // Update netclass panel shown columns for pcbnew
699 const nlohmann::json::json_pointer v3_pointer_pcbnew( "/netclass_panel/pcbnew_shown_columns"_json_pointer );
700 wxString pcbnewColumnList_old = m_internals->at( v3_pointer_pcbnew );
701
702 wxStringTokenizer pcbnewShownTokens( pcbnewColumnList_old, " \t\r\n" );
703 wxString pcbnewColumnList_new;
704
705 while( pcbnewShownTokens.HasMoreTokens() )
706 {
707 long colNumber;
708 pcbnewShownTokens.GetNextToken().ToLong( &colNumber );
709
710 if( colNumber >= 10 )
711 ++colNumber;
712
713 pcbnewColumnList_new += wxString::Format( wxT( "%ld " ), colNumber );
714 }
715
716 pcbnewColumnList_new.Trim( true );
717 pcbnewColumnList_new.Trim( false );
718
719 m_internals->at( v3_pointer_pcbnew ) = pcbnewColumnList_new.ToUTF8();
720 }
721 catch( ... )
722 {
723 wxLogTrace( traceSettings, wxT( "COMMON_SETTINGS::Migrate 3->4: /netclass_panel/shown_columns not found" ) );
724 }
725
726 return true;
727}
728
729
731{
732 try
733 {
734 nlohmann::json& controls = m_internals->At( "dialog" ).at( "controls" );
735
736 for( auto& [dlgKey, dlgVal] : controls.items() )
737 {
738 if( !dlgVal.is_object() )
739 continue;
740
741 auto geoIt = dlgVal.find( "__geometry" );
742
743 if( geoIt == dlgVal.end() || !geoIt->is_object() )
744 continue;
745
746 nlohmann::json& geom = *geoIt;
747
748 // Legacy values were stored in logical pixels. Convert to DIP using the
749 // primary display's scale factor (best approximation without window context).
750 int w = geom.value( "w", 0 );
751 int h = geom.value( "h", 0 );
752
753 wxSize dipSize = wxWindow::ToDIP( wxSize( w, h ), nullptr );
754 geom[ "w" ] = dipSize.x;
755 geom[ "h" ] = dipSize.y;
756
757 geom.erase( "dip" );
758 }
759 }
760 catch( ... )
761 {
762 wxLogTrace( traceSettings,
763 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,
787 wxT( "COMMON_SETTINGS::Migrate 5->6: failed to set auto_backup.format" ) );
788 }
789
790 return true;
791}
792
793
795{
796 // Global field name templates used to be stored in eeschema.json. Import them here so
797 // applications which do not load Eeschema can use them immediately after upgrading.
798 if( Contains( "fields.template_field_names" ) )
799 return true;
800
801 wxFileName eeschemaPath( PATHS::GetUserSettingsPath(), wxS( "eeschema.json" ) );
802
803 if( !eeschemaPath.IsFileReadable() )
804 return true;
805
806 try
807 {
808 std::ifstream eeschemaFile( eeschemaPath.GetFullPath().fn_str() );
809 nlohmann::json eeschemaSettings =
810 nlohmann::json::parse( eeschemaFile, nullptr,
811 /* allow_exceptions = */ true,
812 /* ignore_comments = */ true );
813
814 const nlohmann::json::json_pointer fieldNamesPointer(
815 "/drawing/field_names"_json_pointer );
816
817 if( eeschemaSettings.contains( fieldNamesPointer )
818 && eeschemaSettings.at( fieldNamesPointer ).is_string() )
819 {
820 Set<std::string>( "fields.template_field_names",
821 eeschemaSettings.at( fieldNamesPointer ).get<std::string>() );
822 }
823 }
824 catch( ... )
825 {
826 wxLogTrace( traceSettings,
827 wxT( "COMMON_SETTINGS::Migrate 6->7: failed to import field name templates" ) );
828 }
829
830 return true;
831}
832
833
834bool COMMON_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
835{
836 bool ret = true;
837
838 ret &= fromLegacy<double>( aCfg, "CanvasScale", "appearance.canvas_scale" );
839 ret &= fromLegacy<int>( aCfg, "IconScale", "appearance.icon_scale" );
840 ret &= fromLegacy<bool>( aCfg, "UseIconsInMenus", "appearance.use_icons_in_menus" );
841 ret &= fromLegacy<bool>( aCfg, "ShowEnvVarWarningDialog", "environment.show_warning_dialog" );
842
843 auto load_env_vars =
844 [&]()
845 {
846 wxString key, value;
847 long index = 0;
848 nlohmann::json::json_pointer ptr = m_internals->PointerFromString( "environment.vars" );
849
850 aCfg->SetPath( "EnvironmentVariables" );
851 ( *m_internals )[ptr] = nlohmann::json( {} );
852
853 while( aCfg->GetNextEntry( key, index ) )
854 {
855 if( versionedEnvVarRegex.Matches( key ) )
856 {
857 wxLogTrace( traceSettings,
858 wxT( "Migrate Env: %s is blacklisted; skipping." ), key );
859 continue;
860 }
861
862 value = aCfg->Read( key, wxEmptyString );
863
864 if( !value.IsEmpty() )
865 {
866 ptr.push_back( key.ToStdString() );
867
868 wxLogTrace( traceSettings, wxT( "Migrate Env: %s=%s" ),
869 ptr.to_string(), value );
870 ( *m_internals )[ptr] = value.ToUTF8();
871
872 ptr.pop_back();
873 }
874 }
875
876 aCfg->SetPath( ".." );
877 };
878
879 load_env_vars();
880
881 bool mousewheel_pan = false;
882
883 if( aCfg->Read( "MousewheelPAN", &mousewheel_pan ) && mousewheel_pan )
884 {
885 Set( "input.horizontal_pan", true );
886 Set( "input.scroll_modifier_pan_h", static_cast<int>( WXK_SHIFT ) );
887 Set( "input.scroll_modifier_pan_v", 0 );
888 Set( "input.scroll_modifier_zoom", static_cast<int>( WXK_CONTROL ) );
889 }
890
891 ret &= fromLegacy<bool>( aCfg, "AutoPAN", "input.auto_pan" );
892 ret &= fromLegacy<bool>( aCfg, "ImmediateActions", "input.immediate_actions" );
893 ret &= fromLegacy<bool>( aCfg, "PreferSelectionToDragging", "input.prefer_select_to_drag" );
894 ret &= fromLegacy<bool>( aCfg, "MoveWarpsCursor", "input.warp_mouse_on_move" );
895 ret &= fromLegacy<bool>( aCfg, "ZoomNoCenter", "input.center_on_zoom" );
896
897 // This was stored inverted in legacy config
898 if( std::optional<bool> value = Get<bool>( "input.center_on_zoom" ) )
899 Set( "input.center_on_zoom", !( *value ) );
900
901 ret &= fromLegacy<int>( aCfg, "OpenGLAntialiasingMode", "graphics.opengl_antialiasing_mode" );
902 ret &= fromLegacy<int>( aCfg, "CairoAntialiasingMode", "graphics.cairo_antialiasing_mode" );
903
904 ret &= fromLegacy<int>( aCfg, "AutoSaveInterval", "system.local_history_debounce" );
905 ret &= fromLegacyString( aCfg, "Editor", "system.editor_name" );
906 ret &= fromLegacy<int>( aCfg, "FileHistorySize", "system.file_history_size" );
907 ret &= fromLegacyString( aCfg, "LanguageID", "system.language" );
908 ret &= fromLegacyString( aCfg, "PdfBrowserName", "system.pdf_viewer_name" );
909 ret &= fromLegacy<bool>( aCfg, "UseSystemBrowser", "system.use_system_pdf_viewer" );
910 ret &= fromLegacyString( aCfg, "WorkingDir", "system.working_dir" );
911
912 return ret;
913}
914
915
917{
918 auto addVar =
919 [&]( const wxString& aKey, const wxString& aDefault )
920 {
921 m_Env.vars[aKey] = ENV_VAR_ITEM( aKey, aDefault, aDefault );
922
923 wxString envValue;
924
925 if( wxGetEnv( aKey, &envValue ) == true && !envValue.IsEmpty() )
926 {
927 m_Env.vars[aKey].SetValue( envValue );
928 m_Env.vars[aKey].SetDefinedExternally();
929 wxLogTrace( traceEnvVars,
930 wxS( "InitializeEnvironment: Entry %s defined externally as %s" ), aKey,
931 envValue );
932 }
933 else
934 {
935 wxLogTrace( traceEnvVars, wxS( "InitializeEnvironment: Setting entry %s to "
936 "default %s" ),
937 aKey, aDefault );
938 }
939 };
940
941 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "FOOTPRINT_DIR" ) ), PATHS::GetStockFootprintsPath() );
942 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "3DMODEL_DIR" ) ), PATHS::GetStock3dmodelsPath() );
943 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "TEMPLATE_DIR" ) ), PATHS::GetStockTemplatesPath() );
944 addVar( wxT( "KICAD_USER_TEMPLATE_DIR" ), PATHS::GetUserTemplatesPath() );
945 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "3RD_PARTY" ) ), PATHS::GetDefault3rdPartyPath() );
946 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "SYMBOL_DIR" ) ), PATHS::GetStockSymbolsPath() );
947 addVar( ENV_VAR::GetVersionedEnvVarName( wxS( "DESIGN_BLOCK_DIR" ) ), PATHS::GetStockDesignBlocksPath() );
948}
949
950
952 std::vector<LEGACY_3D_SEARCH_PATH>& aSearchPaths )
953{
954 wxFileName cfgpath( path );
955
956 // This should be the same as wxWidgets 3.0 wxPATH_NORM_ALL which is deprecated in 3.1.
957 // There are known issues with environment variable expansion so maybe we should be using
958 // our own ExpandEnvVarSubstitutions() here instead.
959 cfgpath.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS );
960 wxString cfgname = cfgpath.GetFullPath();
961
962 std::ifstream cfgFile;
963 std::string cfgLine;
964
965 if( !wxFileName::Exists( cfgname ) )
966 {
967 std::ostringstream ostr;
968 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
969 wxString errmsg = "no 3D configuration file";
970 ostr << " * " << errmsg.ToUTF8() << " '";
971 ostr << cfgname.ToUTF8() << "'";
972 wxLogTrace( traceSettings, "%s\n", ostr.str().c_str() );
973 return false;
974 }
975
976 cfgFile.open( cfgname.ToUTF8() );
977
978 if( !cfgFile.is_open() )
979 {
980 std::ostringstream ostr;
981 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
982 wxString errmsg = wxS( "Could not open configuration file" );
983 ostr << " * " << errmsg.ToUTF8() << " '" << cfgname.ToUTF8() << "'";
984 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
985 return false;
986 }
987
988 int lineno = 0;
990 size_t idx;
991 int vnum = 0; // version number
992
993 while( cfgFile.good() )
994 {
995 cfgLine.clear();
996 std::getline( cfgFile, cfgLine );
997 ++lineno;
998
999 if( cfgLine.empty() )
1000 {
1001 if( cfgFile.eof() )
1002 break;
1003
1004 continue;
1005 }
1006
1007 if( 1 == lineno && cfgLine.compare( 0, 2, "#V" ) == 0 )
1008 {
1009 // extract the version number and parse accordingly
1010 if( cfgLine.size() > 2 )
1011 {
1012 std::istringstream istr;
1013 istr.str( cfgLine.substr( 2 ) );
1014 istr >> vnum;
1015 }
1016
1017 continue;
1018 }
1019
1020 idx = 0;
1021
1022 if( !getLegacy3DHollerith( cfgLine, idx, al.m_Alias ) )
1023 continue;
1024
1025 // Don't add KICADn_3DMODEL_DIR, one of its legacy equivalents, or KIPRJMOD from a
1026 // config file. They're system variables which are defined at runtime.
1027 wxString versionedPath = wxString::Format( wxS( "${%s}" ),
1028 ENV_VAR::GetVersionedEnvVarName( wxS( "3DMODEL_DIR" ) ) );
1029
1030 if( al.m_Alias == versionedPath || al.m_Alias == wxS( "${KIPRJMOD}" )
1031 || al.m_Alias == wxS( "$(KIPRJMOD)" ) || al.m_Alias == wxS( "${KISYS3DMOD}" )
1032 || al.m_Alias == wxS( "$(KISYS3DMOD)" ) )
1033 {
1034 continue;
1035 }
1036
1037 if( !getLegacy3DHollerith( cfgLine, idx, al.m_Pathvar ) )
1038 continue;
1039
1040 if( !getLegacy3DHollerith( cfgLine, idx, al.m_Description ) )
1041 continue;
1042
1043 aSearchPaths.push_back( al );
1044 }
1045
1046 cfgFile.close();
1047
1048 return true;
1049}
1050
1051
1052bool COMMON_SETTINGS::getLegacy3DHollerith( const std::string& aString, size_t& aIndex,
1053 wxString& aResult )
1054{
1055 aResult.clear();
1056
1057 if( aIndex >= aString.size() )
1058 {
1059 std::ostringstream ostr;
1060 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1061 wxString errmsg = wxS( "bad Hollerith string on line" );
1062 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1063 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1064
1065 return false;
1066 }
1067
1068 size_t i2 = aString.find( '"', aIndex );
1069
1070 if( std::string::npos == i2 )
1071 {
1072 std::ostringstream ostr;
1073 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1074 wxString errmsg = wxS( "missing opening quote mark in config file" );
1075 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1076 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1077
1078 return false;
1079 }
1080
1081 ++i2;
1082
1083 if( i2 >= aString.size() )
1084 {
1085 std::ostringstream ostr;
1086 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1087 wxString errmsg = wxS( "invalid entry (unexpected end of line)" );
1088 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1089 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1090
1091 return false;
1092 }
1093
1094 std::string tnum;
1095
1096 while( aString[i2] >= '0' && aString[i2] <= '9' )
1097 tnum.append( 1, aString[i2++] );
1098
1099 if( tnum.empty() || aString[i2++] != ':' )
1100 {
1101 std::ostringstream ostr;
1102 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1103 wxString errmsg = wxS( "bad Hollerith string on line" );
1104 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1105 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1106
1107 return false;
1108 }
1109
1110 std::istringstream istr;
1111 istr.str( tnum );
1112 size_t nchars;
1113 istr >> nchars;
1114
1115 if( ( i2 + nchars ) >= aString.size() )
1116 {
1117 std::ostringstream ostr;
1118 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1119 wxString errmsg = wxS( "invalid entry (unexpected end of line)" );
1120 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1121 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1122
1123 return false;
1124 }
1125
1126 if( nchars > 0 )
1127 {
1128 aResult = wxString::FromUTF8( aString.substr( i2, nchars ).c_str() );
1129 i2 += nchars;
1130 }
1131
1132 if( i2 >= aString.size() || aString[i2] != '"' )
1133 {
1134 std::ostringstream ostr;
1135 ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1136 wxString errmsg = wxS( "missing closing quote mark in config file" );
1137 ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
1138 wxLogTrace( traceSettings, wxS( "%s\n" ), ostr.str().c_str() );
1139
1140 return false;
1141 }
1142
1143 aIndex = i2 + 1;
1144 return true;
1145}
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.
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