KiCad PCB EDA Suite
libedit_settings.cpp
Go to the documentation of this file.
1 /*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23 
25 #include <settings/parameters.h>
27 #include "libedit_settings.h"
28 #include <default_values.h>
29 
30 
32 const int libeditSchemaVersion = 0;
33 
34 
36  m_Defaults(), m_Repeat(), m_ShowPinElectricalType( true ), m_LibWidth(),
37  m_EditComponentVisibleColumns()
38 {
39  // Make Coverity happy
41 
42  // Init settings:
43  SetLegacyFilename( "eeschema" );
44 
45  m_params.emplace_back( new PARAM<int>( "defaults.line_width",
47 
48  m_params.emplace_back( new PARAM<int>( "defaults.text_size",
50 
51  m_params.emplace_back( new PARAM<int>( "defaults.pin_length",
53 
54  m_params.emplace_back( new PARAM<int>( "defaults.pin_name_size",
56 
57  m_params.emplace_back( new PARAM<int>( "defaults.pin_num_size",
59 
60  m_params.emplace_back( new PARAM<int>( "repeat.label_delta", &m_Repeat.label_delta, 1 ) );
61 
62  m_params.emplace_back( new PARAM<int>( "repeat.pin_step", &m_Repeat.pin_step, 100 ) );
63 
64  m_params.emplace_back( new PARAM<int>( "repeat.x_step", &m_Repeat.x_step, 0 ) );
65 
66  m_params.emplace_back( new PARAM<int>( "repeat.y_step", &m_Repeat.y_step, 100 ) );
67 
68  m_params.emplace_back( new PARAM<bool>( "show_pin_electrical_type",
69  &m_ShowPinElectricalType, true ) );
70 
71  m_params.emplace_back( new PARAM<int>( "lib_table_width", &m_LibWidth, 250 ) );
72 
73  m_params.emplace_back( new PARAM<wxString>( "edit_component_visible_columns",
74  &m_EditComponentVisibleColumns, "0 1 2 3 4 5 6 7" ) );
75 
76  m_params.emplace_back(
77  new PARAM<bool>( "use_eeschema_color_settings", &m_UseEeschemaColorSettings, true ) );
78 }
79 
80 
81 bool LIBEDIT_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
82 {
83  /*
84  * #define PinTableShownColumnsKey wxT( "PinTableShownColumns" )
85  "0 1 2 3 4 8 9"
86 
87  */
88  bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
89 
90  ret &= fromLegacy<int>( aCfg, "DefaultWireWidth", "defaults.line_width" );
91  ret &= fromLegacy<int>( aCfg, "DefaultPinLength", "defaults.pin_length" );
92  ret &= fromLegacy<int>( aCfg, "LibeditPinNameSize", "defaults.pin_name_size" );
93  ret &= fromLegacy<int>( aCfg, "LibeditPinNumSize", "defaults.pin_num_size" );
94 
95  ret &= fromLegacy<int>( aCfg, "LibeditRepeatLabelInc", "repeat.label_delta" );
96  ret &= fromLegacy<int>( aCfg, "LibeditPinRepeatStep", "repeat.pin_step" );
97  ret &= fromLegacy<int>( aCfg, "LibeditRepeatStepX", "repeat.x_step" );
98  ret &= fromLegacy<int>( aCfg, "LibeditRepeatStepY", "repeat.y_step" );
99 
100  ret &= fromLegacy<int>( aCfg, "LibeditLibWidth", "lib_table_width" );
101  ret &= fromLegacy<bool>( aCfg, "LibeditShowPinElectricalType", "show_pin_electrical_type" );
102 
103  ret &= fromLegacyString( aCfg, "LibEditFieldsShownColumns", "edit_component_visible_columns" );
104 
105  return ret;
106 }
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
const int libeditSchemaVersion
! Update the schema version whenever a migration is required
void SetLegacyFilename(const std::string &aFilename)
Definition: json_settings.h:61
#define DEFAULT_PIN_LENGTH
The default pin number size when creating pins(can be changed in preference menu)
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:73
wxString m_EditComponentVisibleColumns
#define DEFAULT_PINNUM_SIZE
The default pin name size when creating pins(can be changed in preference menu)
#define DEFAULT_PINNAME_SIZE
The default selection highlight thickness (can be changed in preference menu)
#define DEFAULT_LINE_THICKNESS
The default wire width in mils. (can be changed in preference menu)
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
#define DEFAULT_TEXT_SIZE