46 m_CustomToolbars( false ),
47 m_appSettingsSchemaVersion( aSchemaVersion )
99 "design_block_chooser.lib_tree.column_widths",
100 [&]() -> nlohmann::json
102 nlohmann::json ret = {};
105 ret[std::string(
name.ToUTF8() )] = width;
109 [&](
const nlohmann::json& aJson )
111 if( !aJson.is_object() )
116 for(
const auto& entry : aJson.items() )
118 if( !entry.value().is_number_integer() )
121 m_DesignBlockChooserPanel.tree.column_widths[entry.key()] = entry.value().get<int>();
142 [&]() -> nlohmann::json
144 nlohmann::json ret = {};
147 ret[std::string( pair.first.ToUTF8() )] = pair.second;
151 [&](
const nlohmann::json& aJson )
153 if( !aJson.is_object() )
158 for(
const auto& entry : aJson.items() )
160 if( !entry.value().is_number_integer() )
171 m_params.emplace_back(
new PARAM<bool>(
"printing.background",
172 &m_Printing.background,
false ) );
174 m_params.emplace_back(
new PARAM<bool>(
"printing.monochrome",
175 &m_Printing.monochrome,
true ) );
178 &m_Printing.scale, 1.0 ) );
180 m_params.emplace_back(
new PARAM<bool>(
"printing.use_theme",
181 &m_Printing.use_theme,
false ) );
184 &m_Printing.color_theme, wxS(
"" ) ) );
186 m_params.emplace_back(
new PARAM<bool>(
"printing.title_block",
187 &m_Printing.title_block,
false ) );
190 &m_Printing.layers, {} ) );
192 m_params.emplace_back(
new PARAM<int>(
"search_pane.selection_zoom",
193 reinterpret_cast<int*
>( &m_SearchPane.selection_zoom ),
194 static_cast<int>( SEARCH_PANE::SELECTION_ZOOM::PAN ) ) );
196 m_params.emplace_back(
new PARAM<bool>(
"system.first_run_shown",
197 &m_System.first_run_shown,
false ) );
199 m_params.emplace_back(
new PARAM<int>(
"system.max_undo_items",
200 &m_System.max_undo_items, 0 ) );
203 &m_System.file_history, {} ) );
205 if( m_filename == wxS(
"pl_editor" )
206 || ( m_filename == wxS(
"eeschema" ) || m_filename == wxS(
"symbol_editor" ) ) )
208 m_params.emplace_back(
new PARAM<int>(
"system.units",
213 m_params.emplace_back(
new PARAM<int>(
"system.units",
217 m_params.emplace_back(
new PARAM<int>(
"system.last_metric_units",
218 &m_System.last_metric_units,
static_cast<int>(
EDA_UNITS::MM ) ) );
220 m_params.emplace_back(
new PARAM<int>(
"system.last_imperial_units",
221 &m_System.last_imperial_units,
static_cast<int>(
EDA_UNITS::MILS ) ) );
223 m_params.emplace_back(
new PARAM<bool>(
"system.show_import_issues",
224 &m_System.show_import_issues,
true ) );
227 [&]() -> nlohmann::json
229 nlohmann::json js = nlohmann::json::array();
231 for(
const auto& [identifier, visible] : m_Plugins.actions )
232 js.push_back( nlohmann::json( { { identifier.ToUTF8(), visible } } ) );
236 [&](
const nlohmann::json& aObj )
238 m_Plugins.actions.clear();
240 if( !aObj.is_array() )
245 for(
const auto& entry : aObj )
247 if( entry.empty() || !entry.is_object() )
250 for(
const auto& pair : entry.items() )
252 m_Plugins.actions.emplace_back( std::make_pair(
253 wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) );
257 nlohmann::json::array() ) );
262 m_params.emplace_back(
new PARAM<bool>(
"appearance.custom_toolbars",
263 &m_CustomToolbars,
false ) );
265 addParamsForWindow( &m_Window,
"window" );
267 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.on_selection",
268 &m_CrossProbing.on_selection,
true ) );
270 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.center_on_items",
271 &m_CrossProbing.center_on_items,
true ) );
273 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.zoom_to_fit",
274 &m_CrossProbing.zoom_to_fit,
true ) );
276 m_params.emplace_back(
new PARAM<bool>(
"cross_probing.auto_highlight",
277 &m_CrossProbing.auto_highlight,
true ) );
287 ret &=
fromLegacyString( aCfg,
"LastFindString",
"find_replace.find_string" );
288 ret &=
fromLegacyString( aCfg,
"LastReplaceString",
"find_replace.replace_string" );
292 ret &= fromLegacy<int>( aCfg,
"canvas_type",
"graphics.canvas_type" );
294 ret &= fromLegacy<int>( aCfg,
"P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth",
295 "lib_tree.column_width" );
297 ret &= fromLegacy<bool>( aCfg,
"PrintMonochrome",
"printing.monochrome" );
298 ret &= fromLegacy<double>( aCfg,
"PrintScale",
"printing.scale" );
299 ret &= fromLegacy<bool>( aCfg,
"PrintPageFrame",
"printing.title_block" );
302 nlohmann::json js = nlohmann::json::array();
308 key.Printf( wxT(
"PlotLayer_%d" ), i );
310 if( aCfg->Read( key, &val ) && val )
314 Set(
"printing.layers", js );
317 ret &= fromLegacy<bool>( aCfg, f +
"FirstRunShown",
"system.first_run_shown" );
318 ret &= fromLegacy<int>( aCfg, f +
"DevelMaxUndoItems",
"system.max_undo_items" );
319 ret &= fromLegacy<int>( aCfg, f +
"Units",
"system.units" );
324 nlohmann::json js = nlohmann::json::array();
326 for(
int i = 1; i <= max_history_size; i++ )
328 key.Printf(
"file%d", i );
329 file = aCfg->Read( key, wxEmptyString );
331 if( !file.IsEmpty() )
332 js.push_back( file.ToStdString() );
335 Set(
"system.file_history", js );
346 const int find_replace_history_size = 10;
347 nlohmann::json find_history = nlohmann::json::array();
348 nlohmann::json replace_history = nlohmann::json::array();
349 wxString tmp, find_key, replace_key;
351 for(
int i = 0; i < find_replace_history_size; ++i )
353 find_key.Printf(
"FindStringHistoryList%d", i );
354 replace_key.Printf(
"ReplaceStringHistoryList%d", i );
356 if( aCfg->Read( find_key, &tmp ) )
357 find_history.push_back( tmp.ToStdString() );
359 if( aCfg->Read( replace_key, &tmp ) )
360 replace_history.push_back( tmp.ToStdString() );
363 Set(
"find_replace.find_history", find_history );
364 Set(
"find_replace.replace_history", replace_history );
369 const std::string& aJsonPath )
373 const std::string frameGDO = aFrame +
"GalDisplayOptions";
374 const std::string cursorPath = aJsonPath +
".cursor";
375 const std::string gridPath = aJsonPath +
".grid";
377 ret &= fromLegacy<bool>( aCfg, aFrame +
"Maximized", aJsonPath +
".maximized" );
378 ret &=
fromLegacyString( aCfg, aFrame +
"MostRecentlyUsedPath", aJsonPath +
".mru_path" );
379 ret &= fromLegacy<int>( aCfg, aFrame +
"Size_x", aJsonPath +
".size_x" );
380 ret &= fromLegacy<int>( aCfg, aFrame +
"Size_y", aJsonPath +
".size_y" );
381 ret &=
fromLegacyString( aCfg, aFrame +
"Perspective", aJsonPath +
".perspective" );
382 ret &= fromLegacy<int>( aCfg, aFrame +
"Pos_x", aJsonPath +
".pos_x" );
383 ret &= fromLegacy<int>( aCfg, aFrame +
"Pos_y", aJsonPath +
".pos_y" );
385 ret &= fromLegacy<bool>( aCfg, frameGDO +
"ForceDisplayCursor",
386 cursorPath +
".always_show_cursor" );
387 ret &= fromLegacy<bool>( aCfg, frameGDO +
"CursorFullscreen",
388 cursorPath +
".fullscreen_cursor" );
390 ret &= fromLegacy<int>( aCfg, aFrame +
"_LastGridSize", gridPath +
".last_size" );
392 ret &= fromLegacy<int>( aCfg, aFrame +
"FastGrid1", gridPath +
".fast_grid_1" );
393 ret &= fromLegacy<int>( aCfg, aFrame +
"FastGrid2", gridPath +
".fast_grid_2" );
395 ret &= fromLegacy<bool>( aCfg, frameGDO +
"GridAxesEnabled", gridPath +
".axes_enabled" );
396 ret &= fromLegacy<double>( aCfg, frameGDO +
"GridLineWidth", gridPath +
".line_width" );
397 ret &= fromLegacy<double>( aCfg, frameGDO +
"GridMaxDensity", gridPath +
".min_spacing" );
398 ret &= fromLegacy<bool>( aCfg, frameGDO +
"ShowGrid", gridPath +
".show" );
399 ret &= fromLegacy<int>( aCfg, frameGDO +
"GridStyle", gridPath +
".style" );
400 ret &=
fromLegacyColor( aCfg, frameGDO +
"GridColor", gridPath +
".color" );
548 return {
GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
549 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
550 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
551 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) } };
555 return {
GRID{ wxEmptyString, wxS(
"1000 mil" ), wxS(
"1000 mil" ) },
556 GRID{ wxEmptyString, wxS(
"500 mil" ), wxS(
"500 mil" ) },
557 GRID{ wxEmptyString, wxS(
"250 mil" ), wxS(
"250 mil" ) },
558 GRID{ wxEmptyString, wxS(
"200 mil" ), wxS(
"200 mil" ) },
559 GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
560 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
561 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
562 GRID{ wxEmptyString, wxS(
"20 mil" ), wxS(
"20 mil" ) },
563 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) },
564 GRID{ wxEmptyString, wxS(
"5 mil" ), wxS(
"5 mil" ) },
565 GRID{ wxEmptyString, wxS(
"2 mil" ), wxS(
"2 mil" ) },
566 GRID{ wxEmptyString, wxS(
"1 mil" ), wxS(
"1 mil" ) },
567 GRID{ wxEmptyString, wxS(
"5.0 mm" ), wxS(
"5.0 mm" ) },
568 GRID{ wxEmptyString, wxS(
"2.5 mm" ), wxS(
"2.5 mm" ) },
569 GRID{ wxEmptyString, wxS(
"1.0 mm" ), wxS(
"1.0 mm" ) },
570 GRID{ wxEmptyString, wxS(
"0.5 mm" ), wxS(
"0.5 mm" ) },
571 GRID{ wxEmptyString, wxS(
"0.25 mm" ), wxS(
"0.25 mm" ) },
572 GRID{ wxEmptyString, wxS(
"0.2 mm" ), wxS(
"0.2 mm" ) },
573 GRID{ wxEmptyString, wxS(
"0.1 mm" ), wxS(
"0.1 mm" ) },
574 GRID{ wxEmptyString, wxS(
"0.05 mm" ), wxS(
"0.05 mm" ) },
575 GRID{ wxEmptyString, wxS(
"0.025 mm" ), wxS(
"0.025 mm" ) },
576 GRID{ wxEmptyString, wxS(
"0.01 mm" ), wxS(
"0.01 mm" ) } };
585 if( std::optional<int> optWidth = Get<int>(
"lib_tree.column_width" ) )
588 At(
"lib_tree" ).erase(
"column_width" );
APP_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
FIND_REPLACE m_FindReplace
bool migrateWindowConfig(wxConfigBase *aCfg, const std::string &aFrameName, const std::string &aJsonPath)
Migrate legacy window settings into the JSON document.
const std::vector< GRID > DefaultGridSizeList() const
void migrateFindReplace(wxConfigBase *aCfg)
! Migrates the find/replace history string list.s
PANEL_DESIGN_BLOCK_CHOOSER m_DesignBlockChooserPanel
COLOR_PICKER m_ColorPicker
virtual std::string getLegacyFrameName() const
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath)
Add parameters for the given window object.
bool migrateLibTreeWidth()
Migrate the library tree width setting from a single column (Item) to multi-column.
static const wxString COLOR_BUILTIN_DEFAULT
@ GAL_TYPE_OPENGL
OpenGL implementation.
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
void Set(const std::string &aPath, ValueType aVal)
Stores a value into the JSON document Will throw an exception if ValueType isn't something that the l...
wxString m_filename
The filename (not including path) of this settings file (inicode)
bool fromLegacyColor(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy COLOR4D stored in a wxConfig string to a given JSON pointer value.
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
nlohmann::json & At(const std::string &aPath)
Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these function...
Like a normal param, but with custom getter and setter functions.
virtual COMMON_SETTINGS * GetCommonSettings() const
template KICOMMON_API void JSON_SETTINGS::Set< nlohmann::json >(const std::string &aPath, nlohmann::json aValue)
@ USER
The main config directory (e.g. ~/.config/kicad/)
PGM_BASE & Pgm()
The global program "get" accessor.
std::vector< wxString > replace_history
std::vector< wxString > find_history
float highlight_factor
How much to brighten highlighted objects by.
float select_factor
How much to brighten selected objects by.
std::vector< wxString > columns
Ordered list of visible columns in the tree.
std::map< wxString, int > column_widths
Column widths, keyed by header name.
std::vector< wxString > open_libs
list of libraries the user has open in the tree.
int override_connected_idx
std::vector< GRID > grids
int override_graphics_idx
Common grid settings, available to every frame.
Store the common settings that are saved and loaded for each window / frame.
std::vector< double > zoom_factors