KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pl_editor_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 The 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, see <https://www.gnu.org/licenses/>.
18*/
19
20#include <settings/parameters.h>
21#include <wx/config.h>
22
23#include "pl_editor_settings.h"
24
27
28
31{
32 // Make Coverity happy:
35 m_LastCustomWidth = 17000;
36 m_LastCustomHeight = 11000;
37 m_LastWasPortrait = false;
38 m_BlackBackground = false;
39
40 // Build settings:
41 m_params.emplace_back(
42 new PARAM<int>( "properties_frame_width", &m_PropertiesFrameWidth, 150 ) );
43
44 m_params.emplace_back( new PARAM<int>( "corner_origin", &m_CornerOrigin, 0 ) );
45
46 m_params.emplace_back( new PARAM<bool>( "black_background", &m_BlackBackground, false ) );
47
48 m_params.emplace_back( new PARAM<wxString>( "last_paper_size", &m_LastPaperSize, "A3" ) );
49
50 m_params.emplace_back( new PARAM<int>( "last_custom_width", &m_LastCustomWidth, 17000 ) );
51
52 m_params.emplace_back( new PARAM<int>( "last_custom_height", &m_LastCustomHeight, 11000 ) );
53
54 m_params.emplace_back( new PARAM<bool>( "last_was_portrait", &m_LastWasPortrait, false ) );
55}
56
57
58bool PL_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
59{
60 bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
61
62 ret &= fromLegacy<int>( aCfg, "PropertiesFrameWidth", "properties_frame_width" );
63 ret &= fromLegacy<int>( aCfg, "CornerOriginChoice", "corner_origin" );
64 ret &= fromLegacy<bool>( aCfg, "BlackBgColor", "black_background" );
65 ret &= fromLegacy<int>( aCfg, "LastUsedPaperSize", "last_paper_size" );
66 ret &= fromLegacy<int>( aCfg, "LastUsedCustomWidth", "last_custom_width" );
67 ret &= fromLegacy<int>( aCfg, "LastUsedCustomHeight", "last_custom_height" );
68 ret &= fromLegacy<bool>( aCfg, "LastUsedWasPortrait", "last_was_portrait" );
69
70 return ret;
71}
APP_SETTINGS_BASE(const std::string &aFilename, int aSchemaVersion)
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
bool fromLegacy(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig value to a given JSON pointer value.
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
const int plEditorSchemaVersion
! Update the schema version whenever a migration is required