65#if defined( __WXGTK__ ) || defined( __WXMSW__ )
111 &
m_Appearance.zoom_correction_factor, 1.0, 0.1, 10.0 ) );
116 &
m_Backup.backup_on_autosave,
false ) );
119 &
m_Backup.limit_total_files, 25 ) );
122 &
m_Backup.limit_total_size, 104857600 ) );
131 [&]() -> nlohmann::json
133 nlohmann::json ret = {};
135 for(
const std::pair<wxString, ENV_VAR_ITEM> entry :
m_Env.vars )
137 const ENV_VAR_ITEM& var = entry.second;
139 wxASSERT( entry.first == var.GetKey() );
142 if( var.IsDefault() )
144 wxLogTrace( traceEnvVars,
145 wxS(
"COMMON_SETTINGS: Env var %s skipping save (default)" ),
150 wxString value = var.GetValue();
152 value.Trim(
true ).Trim(
false );
156 if( var.GetDefinedExternally() )
158 if( var.GetDefinedInSettings() )
160 wxLogTrace( traceEnvVars,
161 wxS(
"COMMON_SETTINGS: Env var %s was overridden "
162 "externally, saving previously-loaded value %s" ),
163 var.GetKey(), var.GetSettingsValue() );
164 value = var.GetSettingsValue();
168 wxLogTrace( traceEnvVars,
169 wxS(
"COMMON_SETTINGS: Env var %s skipping save "
177 wxS(
"COMMON_SETTINGS: Saving env var %s = %s" ),
178 var.GetKey(), value);
180 std::string key( var.GetKey().Trim(
true ).Trim(
false ).ToUTF8() );
181 ret[ std::move( key ) ] = value;
186 [&](
const nlohmann::json& aJson )
188 if( !aJson.is_object() )
191 for(
const auto& entry : aJson.items() )
193 wxString key = wxString( entry.key().c_str(), wxConvUTF8 ).Trim(
true ).Trim(
false );
194 wxString val = entry.value().get<wxString>().Trim(
true ).Trim(
false );
196 if( m_Env.vars.count( key ) )
198 if( m_Env.vars[key].GetDefinedExternally() )
201 wxS(
"COMMON_SETTINGS: %s is defined externally" ),
203 m_Env.vars[key].SetDefinedInSettings();
204 m_Env.vars[key].SetSettingsValue( val );
210 wxS(
"COMMON_SETTINGS: Updating %s: %s -> %s"),
211 key, m_Env.vars[key].GetValue(), val );
212 m_Env.vars[key].SetValue( val );
218 wxS(
"COMMON_SETTINGS: Loaded new var: %s = %s" ),
223 m_Env.vars[key].SetDefinedInSettings();
224 m_Env.vars[key].SetSettingsValue( val );
228 envVarsParam->SetClearUnknownKeys();
230 m_params.emplace_back(
new PARAM<bool>(
"input.focus_follow_sch_pcb",
231 &m_Input.focus_follow_sch_pcb,
false ) );
233 m_params.emplace_back(
new PARAM<bool>(
"input.auto_pan", &m_Input.auto_pan,
false ) );
235 m_params.emplace_back(
new PARAM<int>(
"input.auto_pan_acceleration",
236 &m_Input.auto_pan_acceleration, 5 ) );
238 m_params.emplace_back(
new PARAM<bool>(
"input.center_on_zoom",
239 &m_Input.center_on_zoom,
true ) );
241 m_params.emplace_back(
new PARAM<bool>(
"input.immediate_actions",
242 &m_Input.immediate_actions,
true ) );
244 m_params.emplace_back(
new PARAM<bool>(
"input.warp_mouse_on_move",
245 &m_Input.warp_mouse_on_move,
true ) );
247 m_params.emplace_back(
new PARAM<bool>(
"input.horizontal_pan",
248 &m_Input.horizontal_pan,
false ) );
250 m_params.emplace_back(
new PARAM<bool>(
"input.hotkey_feedback",
251 &m_Input.hotkey_feedback,
true ) );
253 m_params.emplace_back(
new PARAM<bool>(
"input.zoom_acceleration",
254 &m_Input.zoom_acceleration,
false ) );
257 int default_zoom_speed = 5;
259 int default_zoom_speed = 1;
262 m_params.emplace_back(
new PARAM<int>(
"input.zoom_speed",
263 &m_Input.zoom_speed, default_zoom_speed ) );
265 m_params.emplace_back(
new PARAM<bool>(
"input.zoom_speed_auto",
266 &m_Input.zoom_speed_auto,
true ) );
268 m_params.emplace_back(
new PARAM<int>(
"input.scroll_modifier_zoom",
269 &m_Input.scroll_modifier_zoom, 0 ) );
271 m_params.emplace_back(
new PARAM<int>(
"input.scroll_modifier_pan_h",
272 &m_Input.scroll_modifier_pan_h, WXK_CONTROL ) );
274 m_params.emplace_back(
new PARAM<int>(
"input.scroll_modifier_pan_v",
275 &m_Input.scroll_modifier_pan_v, WXK_SHIFT ) );
277 m_params.emplace_back(
new PARAM<int>(
"input.motion_pan_modifier",
278 &m_Input.motion_pan_modifier, 0 ) );
280 m_params.emplace_back(
new PARAM<bool>(
"input.reverse_scroll_zoom",
281 &m_Input.reverse_scroll_zoom,
false ) );
283 m_params.emplace_back(
new PARAM<bool>(
"input.reverse_scroll_pan_h",
284 &m_Input.reverse_scroll_pan_h,
false ) );
298 m_params.emplace_back(
new PARAM<int>(
"spacemouse.rotate_speed",
299 &m_SpaceMouse.rotate_speed, 5, 1, 10 ) );
301 m_params.emplace_back(
new PARAM<int>(
"spacemouse.pan_speed",
302 &m_SpaceMouse.pan_speed, 5, 1, 10 ) );
304 m_params.emplace_back(
new PARAM<bool>(
"spacemouse.reverse_rotate",
305 &m_SpaceMouse.reverse_rotate,
false ) );
307 m_params.emplace_back(
new PARAM<bool>(
"spacemouse.reverse_pan_x",
308 &m_SpaceMouse.reverse_pan_x,
false ) );
310 m_params.emplace_back(
new PARAM<bool>(
"spacemouse.reverse_pan_y",
311 &m_SpaceMouse.reverse_pan_y,
false ) );
313 m_params.emplace_back(
new PARAM<bool>(
"spacemouse.reverse_zoom",
314 &m_SpaceMouse.reverse_zoom,
false ) );
316 m_params.emplace_back(
new PARAM<int>(
"graphics.canvas_type",
319 m_params.emplace_back(
new PARAM<int>(
"graphics.antialiasing_mode",
320 &m_Graphics.aa_mode, 2, 0, 2 ) );
322 m_params.emplace_back(
new PARAM<int>(
"system.autosave_interval",
323 &m_System.autosave_interval, 600 ) );
327 &m_System.text_editor, wxS(
"/usr/bin/open -e" ) ) );
330 &m_System.text_editor, wxS(
"" ) ) );
333#if defined( __WINDOWS__ )
335 &m_System.file_explorer, wxS(
"explorer.exe /n,/select,%F" ) ) );
338 &m_System.file_explorer, wxS(
"" ) ) );
341 m_params.emplace_back(
new PARAM<int>(
"system.file_history_size",
342 &m_System.file_history_size, 9 ) );
345 &m_System.language, wxS(
"Default" ) ) );
348 &m_System.pdf_viewer_name, wxS(
"" ) ) );
350 m_params.emplace_back(
new PARAM<bool>(
"system.use_system_pdf_viewer",
351 &m_System.use_system_pdf_viewer,
true ) );
354 &m_System.working_dir, wxS(
"" ) ) );
356 m_params.emplace_back(
new PARAM<int>(
"system.clear_3d_cache_interval",
357 &m_System.clear_3d_cache_interval, 30 ) );
359 m_params.emplace_back(
new PARAM<bool>(
"do_not_show_again.zone_fill_warning",
360 &m_DoNotShowAgain.zone_fill_warning,
false ) );
362 m_params.emplace_back(
new PARAM<bool>(
"do_not_show_again.env_var_overwrite_warning",
363 &m_DoNotShowAgain.env_var_overwrite_warning,
false ) );
365 m_params.emplace_back(
new PARAM<bool>(
"do_not_show_again.scaled_3d_models_warning",
366 &m_DoNotShowAgain.scaled_3d_models_warning,
false ) );
368 m_params.emplace_back(
new PARAM<bool>(
"do_not_show_again.data_collection_prompt",
369 &m_DoNotShowAgain.data_collection_prompt,
false ) );
371 m_params.emplace_back(
new PARAM<bool>(
"do_not_show_again.update_check_prompt",
372 &m_DoNotShowAgain.update_check_prompt,
false ) );
374 m_params.emplace_back(
new PARAM<bool>(
"session.remember_open_files",
375 &m_Session.remember_open_files,
false ) );
378 &m_Session.pinned_symbol_libs, {} ) );
381 &m_Session.pinned_fp_libs, {} ) );
384 &m_Session.pinned_design_block_libs, {} ) );
386 m_params.emplace_back(
new PARAM<int>(
"netclass_panel.sash_pos",
387 &m_NetclassPanel.sash_pos, 160 ) );
389 m_params.emplace_back(
new PARAM<wxString>(
"netclass_panel.eeschema_shown_columns",
390 &m_NetclassPanel.eeschema_visible_columns,
"0 11 12 13 14" ) );
392 m_params.emplace_back(
new PARAM<wxString>(
"netclass_panel.pcbnew_shown_columns",
393 &m_NetclassPanel.pcbnew_visible_columns,
"0 1 2 3 4 5 6 7 8 9 10" ) );
395 m_params.emplace_back(
new PARAM<int>(
"package_manager.sash_pos",
396 &m_PackageManager.sash_pos, 380 ) );
399 [&]() -> nlohmann::json
401 nlohmann::json ret = {};
403 for(
const GIT_REPOSITORY& repo : m_Git.repositories )
405 nlohmann::json repoJson = {};
407 repoJson[
"name"] = repo.name;
408 repoJson[
"path"] = repo.path;
409 repoJson[
"authType"] = repo.authType;
410 repoJson[
"username"] = repo.username;
411 repoJson[
"ssh_path"] = repo.ssh_path;
412 repoJson[
"active"] = repo.active;
414 ret.push_back( repoJson );
419 [&](
const nlohmann::json& aJson )
421 if( !aJson.is_array() )
424 m_Git.repositories.clear();
426 for(
const auto& repoJson : aJson )
430 repo.name = repoJson[
"name"].get<wxString>();
431 repo.path = repoJson[
"path"].get<wxString>();
432 repo.authType = repoJson[
"authType"].get<wxString>();
433 repo.username = repoJson[
"username"].get<wxString>();
434 repo.ssh_path = repoJson[
"ssh_path"].get<wxString>();
435 repo.active = repoJson[
"active"].get<
bool>();
436 repo.checkValid =
true;
438 m_Git.repositories.push_back( repo );
444 &m_Git.authorName, wxS(
"" ) ) );
447 &m_Git.authorEmail, wxS(
"" ) ) );
449 m_params.emplace_back(
new PARAM<bool>(
"git.useDefaultAuthor",
450 &m_Git.useDefaultAuthor,
true ) );
452 m_params.emplace_back(
new PARAM<bool>(
"git.enableGit",
453 &m_Git.enableGit,
true ) );
455 m_params.emplace_back(
new PARAM<int>(
"git.updatInterval",
456 &m_Git.updatInterval, 5 ) );
459 &m_Api.python_interpreter, wxS(
"" ) ) );
461 m_params.emplace_back(
new PARAM<bool>(
"api.enable_server",
462 &m_Api.enable_server,
false ) );
465 [&]() -> nlohmann::json
467 nlohmann::json ret = nlohmann::json::object();
469 for( const auto& dlg : m_dialogControlValues )
470 ret[ dlg.first ] = dlg.second;
474 [&](
const nlohmann::json& aVal )
476 m_dialogControlValues.clear();
478 if( !aVal.is_object() )
481 for( auto& [dlgKey, dlgVal] : aVal.items() )
483 if( !dlgVal.is_object() )
486 for( auto& [ctrlKey, ctrlVal] : dlgVal.items() )
487 m_dialogControlValues[ dlgKey ][ ctrlKey ] = ctrlVal;
490 nlohmann::json::object() ) );
622 const nlohmann::json::json_pointer v3_pointer_eeschema(
"/netclass_panel/eeschema_shown_columns"_json_pointer );
623 wxString eeSchemaColumnList_old =
m_internals->at( v3_pointer_eeschema );
625 wxStringTokenizer eeSchemaShownTokens( eeSchemaColumnList_old,
" \t\r\n" );
626 wxString eeSchemaColumnList_new;
628 while( eeSchemaShownTokens.HasMoreTokens() )
631 eeSchemaShownTokens.GetNextToken().ToLong( &colNumber );
633 if( colNumber >= 10 )
636 eeSchemaColumnList_new += wxString::Format( wxT(
"%ld " ), colNumber );
639 eeSchemaColumnList_new.Trim(
true );
640 eeSchemaColumnList_new.Trim(
false );
642 m_internals->at( v3_pointer_eeschema ) = eeSchemaColumnList_new.ToUTF8();
645 const nlohmann::json::json_pointer v3_pointer_pcbnew(
"/netclass_panel/pcbnew_shown_columns"_json_pointer );
646 wxString pcbnewColumnList_old =
m_internals->at( v3_pointer_pcbnew );
648 wxStringTokenizer pcbnewShownTokens( pcbnewColumnList_old,
" \t\r\n" );
649 wxString pcbnewColumnList_new;
651 while( pcbnewShownTokens.HasMoreTokens() )
654 pcbnewShownTokens.GetNextToken().ToLong( &colNumber );
656 if( colNumber >= 10 )
659 pcbnewColumnList_new += wxString::Format( wxT(
"%ld " ), colNumber );
662 pcbnewColumnList_new.Trim(
true );
663 pcbnewColumnList_new.Trim(
false );
665 m_internals->at( v3_pointer_pcbnew ) = pcbnewColumnList_new.ToUTF8();
669 wxLogTrace(
traceSettings, wxT(
"COMMON_SETTINGS::Migrate 3->4: /netclass_panel/shown_columns not found" ) );