45 m_appSettingsSchemaVersion( aSchemaVersion )
87 [&]() -> nlohmann::json
89 nlohmann::json ret = {};
92 ret[std::string( pair.first.ToUTF8() )] = pair.second;
96 [&](
const nlohmann::json& aJson )
98 if( !aJson.is_object() )
103 for(
const auto& entry : aJson.items() )
105 if( !entry.value().is_number_integer() )
108 m_LibTree.column_widths[ entry.key() ] = entry.value().get<int>();
159 &
m_System.
units,
static_cast<int>( EDA_UNITS::MILLIMETRES ) ) );
196 ret &=
fromLegacyString( aCfg,
"LastFindString",
"find_replace.find_string" );
197 ret &=
fromLegacyString( aCfg,
"LastReplaceString",
"find_replace.replace_string" );
201 ret &= fromLegacy<int>( aCfg,
"canvas_type",
"graphics.canvas_type" );
203 ret &= fromLegacy<int>( aCfg,
"P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth",
204 "lib_tree.column_width" );
206 ret &= fromLegacy<bool>( aCfg,
"PrintMonochrome",
"printing.monochrome" );
207 ret &= fromLegacy<double>( aCfg,
"PrintScale",
"printing.scale" );
208 ret &= fromLegacy<bool>( aCfg,
"PrintPageFrame",
"printing.title_block" );
211 nlohmann::json js = nlohmann::json::array();
217 key.Printf( wxT(
"PlotLayer_%d" ), i );
219 if( aCfg->Read( key, &val ) && val )
223 Set(
"printing.layers", js );
226 ret &= fromLegacy<bool>( aCfg, f +
"FirstRunShown",
"system.first_run_shown" );
227 ret &= fromLegacy<int>( aCfg, f +
"DevelMaxUndoItems",
"system.max_undo_items" );
228 ret &= fromLegacy<int>( aCfg, f +
"Units",
"system.units" );
233 nlohmann::json js = nlohmann::json::array();
235 for(
int i = 1; i <= max_history_size; i++ )
237 key.Printf(
"file%d", i );
238 file = aCfg->Read( key, wxEmptyString );
240 if( !file.IsEmpty() )
241 js.push_back( file.ToStdString() );
244 Set(
"system.file_history", js );
255 const int find_replace_history_size = 10;
256 nlohmann::json find_history = nlohmann::json::array();
257 nlohmann::json replace_history = nlohmann::json::array();
258 wxString tmp, find_key, replace_key;
260 for(
int i = 0; i < find_replace_history_size; ++i )
262 find_key.Printf(
"FindStringHistoryList%d", i );
263 replace_key.Printf(
"ReplaceStringHistoryList%d", i );
265 if( aCfg->Read( find_key, &tmp ) )
266 find_history.push_back( tmp.ToStdString() );
268 if( aCfg->Read( replace_key, &tmp ) )
269 replace_history.push_back( tmp.ToStdString() );
272 Set(
"find_replace.find_history", find_history );
273 Set(
"find_replace.replace_history", replace_history );
278 const std::string& aJsonPath )
282 const std::string frameGDO = aFrame +
"GalDisplayOptions";
283 const std::string cursorPath = aJsonPath +
".cursor";
284 const std::string gridPath = aJsonPath +
".grid";
286 ret &= fromLegacy<bool>( aCfg, aFrame +
"Maximized", aJsonPath +
".maximized" );
287 ret &=
fromLegacyString( aCfg, aFrame +
"MostRecentlyUsedPath", aJsonPath +
".mru_path" );
288 ret &= fromLegacy<int>( aCfg, aFrame +
"Size_x", aJsonPath +
".size_x" );
289 ret &= fromLegacy<int>( aCfg, aFrame +
"Size_y", aJsonPath +
".size_y" );
290 ret &=
fromLegacyString( aCfg, aFrame +
"Perspective", aJsonPath +
".perspective" );
291 ret &= fromLegacy<int>( aCfg, aFrame +
"Pos_x", aJsonPath +
".pos_x" );
292 ret &= fromLegacy<int>( aCfg, aFrame +
"Pos_y", aJsonPath +
".pos_y" );
294 ret &= fromLegacy<bool>( aCfg, frameGDO +
"ForceDisplayCursor", cursorPath +
".always_show_cursor" );
295 ret &= fromLegacy<bool>( aCfg, frameGDO +
"CursorFullscreen", cursorPath +
".fullscreen_cursor" );
297 ret &= fromLegacy<int>( aCfg, aFrame +
"_LastGridSize", gridPath +
".last_size" );
299 ret &= fromLegacy<int>( aCfg, aFrame +
"FastGrid1", gridPath +
".fast_grid_1" );
300 ret &= fromLegacy<int>( aCfg, aFrame +
"FastGrid2", gridPath +
".fast_grid_2" );
302 ret &= fromLegacy<bool>( aCfg, frameGDO +
"GridAxesEnabled", gridPath +
".axes_enabled" );
303 ret &= fromLegacy<double>( aCfg, frameGDO +
"GridLineWidth", gridPath +
".line_width" );
304 ret &= fromLegacy<double>( aCfg, frameGDO +
"GridMaxDensity", gridPath +
".min_spacing" );
305 ret &= fromLegacy<bool>( aCfg, frameGDO +
"ShowGrid", gridPath +
".show" );
306 ret &= fromLegacy<int>( aCfg, frameGDO +
"GridStyle", gridPath +
".style" );
307 ret &=
fromLegacyColor( aCfg, frameGDO +
"GridColor", gridPath +
".color" );
455 return {
GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
456 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
457 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
458 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) } };
462 return {
GRID{ wxEmptyString, wxS(
"1000 mil" ), wxS(
"1000 mil" ) },
463 GRID{ wxEmptyString, wxS(
"500 mil" ), wxS(
"500 mil" ) },
464 GRID{ wxEmptyString, wxS(
"250 mil" ), wxS(
"250 mil" ) },
465 GRID{ wxEmptyString, wxS(
"200 mil" ), wxS(
"200 mil" ) },
466 GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
467 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
468 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
469 GRID{ wxEmptyString, wxS(
"20 mil" ), wxS(
"20 mil" ) },
470 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) },
471 GRID{ wxEmptyString, wxS(
"5 mil" ), wxS(
"5 mil" ) },
472 GRID{ wxEmptyString, wxS(
"2 mil" ), wxS(
"2 mil" ) },
473 GRID{ wxEmptyString, wxS(
"1 mil" ), wxS(
"1 mil" ) },
474 GRID{ wxEmptyString, wxS(
"5.0 mm" ), wxS(
"5.0 mm" ) },
475 GRID{ wxEmptyString, wxS(
"2.5 mm" ), wxS(
"2.5 mm" ) },
476 GRID{ wxEmptyString, wxS(
"1.0 mm" ), wxS(
"1.0 mm" ) },
477 GRID{ wxEmptyString, wxS(
"0.5 mm" ), wxS(
"0.5 mm" ) },
478 GRID{ wxEmptyString, wxS(
"0.25 mm" ), wxS(
"0.25 mm" ) },
479 GRID{ wxEmptyString, wxS(
"0.2 mm" ), wxS(
"0.2 mm" ) },
480 GRID{ wxEmptyString, wxS(
"0.1 mm" ), wxS(
"0.1 mm" ) },
481 GRID{ wxEmptyString, wxS(
"0.05 mm" ), wxS(
"0.05 mm" ) },
482 GRID{ wxEmptyString, wxS(
"0.025 mm" ), wxS(
"0.025 mm" ) },
483 GRID{ wxEmptyString, wxS(
"0.01 mm" ), wxS(
"0.01 mm" ) } };
492 if( std::optional<int> optWidth = Get<int>(
"lib_tree.column_width" ) )
495 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)
Migrates legacy window settings into the JSON document.
const std::vector< GRID > DefaultGridSizeList() const
void migrateFindReplace(wxConfigBase *aCfg)
! Migrates the find/replace history string lists
COLOR_PICKER m_ColorPicker
virtual std::string getLegacyFrameName() const
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
wxString m_ColorTheme
Active color theme name.
CROSS_PROBING_SETTINGS m_CrossProbing
void addParamsForWindow(WINDOW_SETTINGS *aWindow, const std::string &aJsonPath)
Adds parameters for the given window object.
bool migrateLibTreeWidth()
Migrates 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
bool monochrome
Whether or not to print in monochrome.
bool background
Whether or not to print background color.
std::vector< int > layers
List of enabled layers for printing.
wxString color_theme
Color theme to use for printing.
double scale
Printout scale.
bool title_block
Whether or not to print title block.
bool use_theme
If false, display color theme will be used.
SELECTION_ZOOM selection_zoom
bool show_import_issues
Stored value for "show import issues" when importing non-KiCad designs to this application.
std::vector< wxString > file_history
bool on_selection
Synchronize the selection for multiple items too.
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
bool center_on_items
Automatically pan to cross-probed items.
bool auto_highlight
Automatically turn on highlight mode in the target frame.
int override_connected_idx
std::vector< GRID > grids
int override_graphics_idx
Common grid settings, available to every frame.
Stores the common settings that are saved and loaded for each window / frame.
std::vector< double > zoom_factors