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:
36 m_LastCustomWidth = 17000;
37 m_LastCustomHeight = 11000;
38 m_LastWasPortrait = false;
39 m_BlackBackground = false;
40
41 // Build settings:
42 m_params.emplace_back(
43 new PARAM<int>( "properties_frame_width", &m_PropertiesFrameWidth, 150 ) );
44
45 m_params.emplace_back(
46 new PARAM<float>( "properties_splitter", &m_PropertiesSplitter, 0.5f ) );
47
48 m_params.emplace_back( new PARAM<int>( "corner_origin", &m_CornerOrigin, 0 ) );
49
50 m_params.emplace_back( new PARAM<bool>( "black_background", &m_BlackBackground, false ) );
51
52 m_params.emplace_back( new PARAM<wxString>( "last_paper_size", &m_LastPaperSize, "A3" ) );
53
54 m_params.emplace_back( new PARAM<int>( "last_custom_width", &m_LastCustomWidth, 17000 ) );
55
56 m_params.emplace_back( new PARAM<int>( "last_custom_height", &m_LastCustomHeight, 11000 ) );
57
58 m_params.emplace_back( new PARAM<bool>( "last_was_portrait", &m_LastWasPortrait, false ) );
59}
60
61
62bool PL_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
63{
64 bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
65
66 ret &= fromLegacy<int>( aCfg, "PropertiesFrameWidth", "properties_frame_width" );
67 ret &= fromLegacy<int>( aCfg, "CornerOriginChoice", "corner_origin" );
68 ret &= fromLegacy<bool>( aCfg, "BlackBgColor", "black_background" );
69 ret &= fromLegacy<int>( aCfg, "LastUsedPaperSize", "last_paper_size" );
70 ret &= fromLegacy<int>( aCfg, "LastUsedCustomWidth", "last_custom_width" );
71 ret &= fromLegacy<int>( aCfg, "LastUsedCustomHeight", "last_custom_height" );
72 ret &= fromLegacy<bool>( aCfg, "LastUsedWasPortrait", "last_was_portrait" );
73
74 return ret;
75}
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