43 m_appSettingsSchemaVersion( aSchemaVersion )
85 [&]() -> nlohmann::json
87 nlohmann::json ret = {};
90 ret[std::string( pair.first.ToUTF8() )] = pair.second;
94 [&](
const nlohmann::json& aJson )
96 if( !aJson.is_object() )
101 for(
const auto& entry : aJson.items() )
103 if( !entry.value().is_number_integer() )
106 m_LibTree.column_widths[ entry.key() ] = entry.value().get<int>();
142 &
m_System.
units,
static_cast<int>( EDA_UNITS::MILLIMETRES ) ) );
175 ret &=
fromLegacyString( aCfg,
"LastFindString",
"find_replace.find_string" );
176 ret &=
fromLegacyString( aCfg,
"LastReplaceString",
"find_replace.replace_string" );
180 ret &= fromLegacy<int>( aCfg,
"canvas_type",
"graphics.canvas_type" );
182 ret &= fromLegacy<int>( aCfg,
"P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth",
183 "lib_tree.column_width" );
185 ret &= fromLegacy<bool>( aCfg,
"PrintMonochrome",
"printing.monochrome" );
186 ret &= fromLegacy<double>( aCfg,
"PrintScale",
"printing.scale" );
187 ret &= fromLegacy<bool>( aCfg,
"PrintPageFrame",
"printing.title_block" );
190 nlohmann::json js = nlohmann::json::array();
196 key.Printf( wxT(
"PlotLayer_%d" ), i );
198 if( aCfg->Read( key, &val ) && val )
202 Set(
"printing.layers", js );
205 ret &= fromLegacy<bool>( aCfg, f +
"FirstRunShown",
"system.first_run_shown" );
206 ret &= fromLegacy<int>( aCfg, f +
"DevelMaxUndoItems",
"system.max_undo_items" );
207 ret &= fromLegacy<int>( aCfg, f +
"Units",
"system.units" );
210 int max_history_size =
Pgm().GetCommonSettings()->m_System.file_history_size;
212 nlohmann::json js = nlohmann::json::array();
214 for(
int i = 1; i <= max_history_size; i++ )
216 key.Printf(
"file%d", i );
217 file = aCfg->Read( key, wxEmptyString );
219 if( !file.IsEmpty() )
220 js.push_back( file.ToStdString() );
223 Set(
"system.file_history", js );
234 const int find_replace_history_size = 10;
235 nlohmann::json find_history = nlohmann::json::array();
236 nlohmann::json replace_history = nlohmann::json::array();
237 wxString tmp, find_key, replace_key;
239 for(
int i = 0; i < find_replace_history_size; ++i )
241 find_key.Printf(
"FindStringHistoryList%d", i );
242 replace_key.Printf(
"ReplaceStringHistoryList%d", i );
244 if( aCfg->Read( find_key, &tmp ) )
245 find_history.push_back( tmp.ToStdString() );
247 if( aCfg->Read( replace_key, &tmp ) )
248 replace_history.push_back( tmp.ToStdString() );
251 Set(
"find_replace.find_history", find_history );
252 Set(
"find_replace.replace_history", replace_history );
257 const std::string& aJsonPath )
261 const std::string frameGDO = aFrame +
"GalDisplayOptions";
262 const std::string cursorPath = aJsonPath +
".cursor";
263 const std::string gridPath = aJsonPath +
".grid";
265 ret &= fromLegacy<bool>( aCfg, aFrame +
"Maximized", aJsonPath +
".maximized" );
266 ret &=
fromLegacyString( aCfg, aFrame +
"MostRecentlyUsedPath", aJsonPath +
".mru_path" );
267 ret &= fromLegacy<int>( aCfg, aFrame +
"Size_x", aJsonPath +
".size_x" );
268 ret &= fromLegacy<int>( aCfg, aFrame +
"Size_y", aJsonPath +
".size_y" );
269 ret &=
fromLegacyString( aCfg, aFrame +
"Perspective", aJsonPath +
".perspective" );
270 ret &= fromLegacy<int>( aCfg, aFrame +
"Pos_x", aJsonPath +
".pos_x" );
271 ret &= fromLegacy<int>( aCfg, aFrame +
"Pos_y", aJsonPath +
".pos_y" );
273 ret &= fromLegacy<bool>( aCfg, frameGDO +
"ForceDisplayCursor", cursorPath +
".always_show_cursor" );
274 ret &= fromLegacy<bool>( aCfg, frameGDO +
"CursorFullscreen", cursorPath +
".fullscreen_cursor" );
276 ret &= fromLegacy<int>( aCfg, aFrame +
"_LastGridSize", gridPath +
".last_size" );
278 ret &= fromLegacy<int>( aCfg, aFrame +
"FastGrid1", gridPath +
".fast_grid_1" );
279 ret &= fromLegacy<int>( aCfg, aFrame +
"FastGrid2", gridPath +
".fast_grid_2" );
281 ret &= fromLegacy<bool>( aCfg, frameGDO +
"GridAxesEnabled", gridPath +
".axes_enabled" );
282 ret &= fromLegacy<double>( aCfg, frameGDO +
"GridLineWidth", gridPath +
".line_width" );
283 ret &= fromLegacy<double>( aCfg, frameGDO +
"GridMaxDensity", gridPath +
".min_spacing" );
284 ret &= fromLegacy<bool>( aCfg, frameGDO +
"ShowGrid", gridPath +
".show" );
285 ret &= fromLegacy<int>( aCfg, frameGDO +
"GridStyle", gridPath +
".style" );
286 ret &=
fromLegacyColor( aCfg, frameGDO +
"GridColor", gridPath +
".color" );
384 return { wxS(
"100 mil" ),
394 return { wxS(
"1000 mil" ),
424 if( std::optional<int> optWidth = Get<int>(
"lib_tree.column_width" ) )
427 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.
void migrateFindReplace(wxConfigBase *aCfg)
! Migrates the find/replace history string lists
const std::vector< wxString > DefaultGridSizeList() const
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.
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...
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...
Like a normal param, but with custom getter and setter functions.
template void JSON_SETTINGS::Set< nlohmann::json >(const std::string &aPath, nlohmann::json aValue)
@ USER
The main config directory (e.g. ~/.config/kicad/)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
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.
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.
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.
std::vector< wxString > sizes
Stores the common settings that are saved and loaded for each window / frame.
std::vector< double > zoom_factors