46 m_appSettingsSchemaVersion( aSchemaVersion )
88 [&]() -> nlohmann::json
90 nlohmann::json ret = {};
93 ret[std::string( pair.first.ToUTF8() )] = pair.second;
97 [&](
const nlohmann::json& aJson )
99 if( !aJson.is_object() )
104 for(
const auto& entry : aJson.items() )
106 if( !entry.value().is_number_integer() )
109 m_LibTree.column_widths[ entry.key() ] = entry.value().get<int>();
160 &
m_System.
units,
static_cast<int>( EDA_UNITS::MILLIMETRES ) ) );
173 [&]() -> nlohmann::json
175 nlohmann::json js = nlohmann::json::array();
178 js.push_back( nlohmann::json( { { identifier.ToUTF8(), visible } } ) );
182 [&](
const nlohmann::json& aObj )
186 if( !aObj.is_array() )
191 for(
const auto& entry : aObj )
193 if( entry.empty() || !entry.is_object() )
196 for(
const auto& pair : entry.items() )
199 wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) );
203 nlohmann::json::array() ) );
230 ret &=
fromLegacyString( aCfg,
"LastFindString",
"find_replace.find_string" );
231 ret &=
fromLegacyString( aCfg,
"LastReplaceString",
"find_replace.replace_string" );
235 ret &= fromLegacy<int>( aCfg,
"canvas_type",
"graphics.canvas_type" );
237 ret &= fromLegacy<int>( aCfg,
"P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth",
238 "lib_tree.column_width" );
240 ret &= fromLegacy<bool>( aCfg,
"PrintMonochrome",
"printing.monochrome" );
241 ret &= fromLegacy<double>( aCfg,
"PrintScale",
"printing.scale" );
242 ret &= fromLegacy<bool>( aCfg,
"PrintPageFrame",
"printing.title_block" );
245 nlohmann::json js = nlohmann::json::array();
251 key.Printf( wxT(
"PlotLayer_%d" ), i );
253 if( aCfg->Read( key, &val ) && val )
257 Set(
"printing.layers", js );
260 ret &= fromLegacy<bool>( aCfg, f +
"FirstRunShown",
"system.first_run_shown" );
261 ret &= fromLegacy<int>( aCfg, f +
"DevelMaxUndoItems",
"system.max_undo_items" );
262 ret &= fromLegacy<int>( aCfg, f +
"Units",
"system.units" );
267 nlohmann::json js = nlohmann::json::array();
269 for(
int i = 1; i <= max_history_size; i++ )
271 key.Printf(
"file%d", i );
272 file = aCfg->Read( key, wxEmptyString );
274 if( !file.IsEmpty() )
275 js.push_back( file.ToStdString() );
278 Set(
"system.file_history", js );
289 const int find_replace_history_size = 10;
290 nlohmann::json find_history = nlohmann::json::array();
291 nlohmann::json replace_history = nlohmann::json::array();
292 wxString tmp, find_key, replace_key;
294 for(
int i = 0; i < find_replace_history_size; ++i )
296 find_key.Printf(
"FindStringHistoryList%d", i );
297 replace_key.Printf(
"ReplaceStringHistoryList%d", i );
299 if( aCfg->Read( find_key, &tmp ) )
300 find_history.push_back( tmp.ToStdString() );
302 if( aCfg->Read( replace_key, &tmp ) )
303 replace_history.push_back( tmp.ToStdString() );
306 Set(
"find_replace.find_history", find_history );
307 Set(
"find_replace.replace_history", replace_history );
312 const std::string& aJsonPath )
316 const std::string frameGDO = aFrame +
"GalDisplayOptions";
317 const std::string cursorPath = aJsonPath +
".cursor";
318 const std::string gridPath = aJsonPath +
".grid";
320 ret &= fromLegacy<bool>( aCfg, aFrame +
"Maximized", aJsonPath +
".maximized" );
321 ret &=
fromLegacyString( aCfg, aFrame +
"MostRecentlyUsedPath", aJsonPath +
".mru_path" );
322 ret &= fromLegacy<int>( aCfg, aFrame +
"Size_x", aJsonPath +
".size_x" );
323 ret &= fromLegacy<int>( aCfg, aFrame +
"Size_y", aJsonPath +
".size_y" );
324 ret &=
fromLegacyString( aCfg, aFrame +
"Perspective", aJsonPath +
".perspective" );
325 ret &= fromLegacy<int>( aCfg, aFrame +
"Pos_x", aJsonPath +
".pos_x" );
326 ret &= fromLegacy<int>( aCfg, aFrame +
"Pos_y", aJsonPath +
".pos_y" );
328 ret &= fromLegacy<bool>( aCfg, frameGDO +
"ForceDisplayCursor", cursorPath +
".always_show_cursor" );
329 ret &= fromLegacy<bool>( aCfg, frameGDO +
"CursorFullscreen", cursorPath +
".fullscreen_cursor" );
331 ret &= fromLegacy<int>( aCfg, aFrame +
"_LastGridSize", gridPath +
".last_size" );
333 ret &= fromLegacy<int>( aCfg, aFrame +
"FastGrid1", gridPath +
".fast_grid_1" );
334 ret &= fromLegacy<int>( aCfg, aFrame +
"FastGrid2", gridPath +
".fast_grid_2" );
336 ret &= fromLegacy<bool>( aCfg, frameGDO +
"GridAxesEnabled", gridPath +
".axes_enabled" );
337 ret &= fromLegacy<double>( aCfg, frameGDO +
"GridLineWidth", gridPath +
".line_width" );
338 ret &= fromLegacy<double>( aCfg, frameGDO +
"GridMaxDensity", gridPath +
".min_spacing" );
339 ret &= fromLegacy<bool>( aCfg, frameGDO +
"ShowGrid", gridPath +
".show" );
340 ret &= fromLegacy<int>( aCfg, frameGDO +
"GridStyle", gridPath +
".style" );
341 ret &=
fromLegacyColor( aCfg, frameGDO +
"GridColor", gridPath +
".color" );
489 return {
GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
490 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
491 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
492 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) } };
496 return {
GRID{ wxEmptyString, wxS(
"1000 mil" ), wxS(
"1000 mil" ) },
497 GRID{ wxEmptyString, wxS(
"500 mil" ), wxS(
"500 mil" ) },
498 GRID{ wxEmptyString, wxS(
"250 mil" ), wxS(
"250 mil" ) },
499 GRID{ wxEmptyString, wxS(
"200 mil" ), wxS(
"200 mil" ) },
500 GRID{ wxEmptyString, wxS(
"100 mil" ), wxS(
"100 mil" ) },
501 GRID{ wxEmptyString, wxS(
"50 mil" ), wxS(
"50 mil" ) },
502 GRID{ wxEmptyString, wxS(
"25 mil" ), wxS(
"25 mil" ) },
503 GRID{ wxEmptyString, wxS(
"20 mil" ), wxS(
"20 mil" ) },
504 GRID{ wxEmptyString, wxS(
"10 mil" ), wxS(
"10 mil" ) },
505 GRID{ wxEmptyString, wxS(
"5 mil" ), wxS(
"5 mil" ) },
506 GRID{ wxEmptyString, wxS(
"2 mil" ), wxS(
"2 mil" ) },
507 GRID{ wxEmptyString, wxS(
"1 mil" ), wxS(
"1 mil" ) },
508 GRID{ wxEmptyString, wxS(
"5.0 mm" ), wxS(
"5.0 mm" ) },
509 GRID{ wxEmptyString, wxS(
"2.5 mm" ), wxS(
"2.5 mm" ) },
510 GRID{ wxEmptyString, wxS(
"1.0 mm" ), wxS(
"1.0 mm" ) },
511 GRID{ wxEmptyString, wxS(
"0.5 mm" ), wxS(
"0.5 mm" ) },
512 GRID{ wxEmptyString, wxS(
"0.25 mm" ), wxS(
"0.25 mm" ) },
513 GRID{ wxEmptyString, wxS(
"0.2 mm" ), wxS(
"0.2 mm" ) },
514 GRID{ wxEmptyString, wxS(
"0.1 mm" ), wxS(
"0.1 mm" ) },
515 GRID{ wxEmptyString, wxS(
"0.05 mm" ), wxS(
"0.05 mm" ) },
516 GRID{ wxEmptyString, wxS(
"0.025 mm" ), wxS(
"0.025 mm" ) },
517 GRID{ wxEmptyString, wxS(
"0.01 mm" ), wxS(
"0.01 mm" ) } };
526 if( std::optional<int> optWidth = Get<int>(
"lib_tree.column_width" ) )
529 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
std::vector< std::pair< wxString, bool > > actions
Ordered list of plugin actions mapped to whether or not they are shown in the toolbar.
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