Browse Source
Implement a new settings framework across all of KiCad
Implement a new settings framework across all of KiCad
CHANGED: Settings are now stored in versioned sub-directories ADDED: First-run dialog for migrating settings from a previous version CHANGED: Settings are now stored as JSON files instead of wxConfig-style INI files CHANGED: Color settings are now all stored in a separate settings file CHANGED: The symbol editor and footprint editor now have their own settings files CHANGED: Color settings are no longer exposed through BOARD object CHANGED: Page layout editor now uses Eeschema's color scheme Settings are now managed through a central SETTINGS_MANAGER held by PGM_BASE. Existing settings will be migrated from the wxConfig format on first run of each application. Per-application settings are now stored in one class for each application.pull/16/head
334 changed files with 10686 additions and 4179 deletions
-
33d-viewer/3d_cache/3d_cache.cpp
-
13d-viewer/3d_cache/3d_plugin_manager.cpp
-
223d-viewer/3d_cache/dialogs/panel_prev_model.cpp
-
93d-viewer/3d_canvas/cinfo3d_visu.cpp
-
73d-viewer/3d_canvas/cinfo3d_visu.h
-
63d-viewer/3d_canvas/eda_3d_canvas.cpp
-
1573d-viewer/3d_viewer/3d_viewer_settings.cpp
-
1223d-viewer/3d_viewer/3d_viewer_settings.h
-
3623d-viewer/3d_viewer/eda_3d_viewer.cpp
-
43d-viewer/3d_viewer/eda_3d_viewer.h
-
53d-viewer/CMakeLists.txt
-
1bitmap2component/CMakeLists.txt
-
105bitmap2component/bitmap2cmp_gui.cpp
-
7bitmap2component/bitmap2cmp_gui.h
-
6bitmap2component/bitmap2cmp_main.cpp
-
68bitmap2component/bitmap2cmp_settings.cpp
-
58bitmap2component/bitmap2cmp_settings.h
-
24common/CMakeLists.txt
-
3common/advanced_config.cpp
-
32common/bin_mod.cpp
-
7common/bitmap.cpp
-
24common/board_printout.cpp
-
55common/common.cpp
-
150common/dialogs/dialog_migrate_settings.cpp
-
62common/dialogs/dialog_migrate_settings.h
-
102common/dialogs/dialog_migrate_settings_base.cpp
-
568common/dialogs/dialog_migrate_settings_base.fbp
-
66common/dialogs/dialog_migrate_settings_base.h
-
76common/dialogs/dialog_page_settings.cpp
-
3common/dialogs/dialog_print_generic.h
-
86common/dialogs/panel_common_settings.cpp
-
11common/dpi_scaling.cpp
-
3common/draw_panel_gal.cpp
-
177common/eda_base_frame.cpp
-
17common/eda_doc.cpp
-
212common/eda_draw_frame.cpp
-
40common/filehistory.cpp
-
4common/fp_lib_table.cpp
-
13common/gal/color4d.cpp
-
82common/gal/gal_display_options.cpp
-
7common/hotkeys_basic.cpp
-
1common/kiface_i.cpp
-
7common/lib_table_base.cpp
-
15common/lib_tree_model_adapter.cpp
-
3common/lib_tree_model_adapter.h
-
13common/page_layout/ws_painter.cpp
-
5common/page_layout/ws_proxy_view_item.cpp
-
199common/pgm_base.cpp
-
21common/printout.cpp
-
254common/settings/app_settings.cpp
-
345common/settings/color_settings.cpp
-
169common/settings/common_settings.cpp
-
412common/settings/json_settings.cpp
-
78common/settings/nested_settings.cpp
-
545common/settings/settings_manager.cpp
-
15common/single_top.cpp
-
6common/swig/kicad.i
-
39common/tool/tool_base.cpp
-
19common/view/wx_view_controls.cpp
-
1cvpcb/CMakeLists.txt
-
5cvpcb/cvpcb.cpp
-
18cvpcb/cvpcb_mainframe.cpp
-
4cvpcb/cvpcb_mainframe.h
-
68cvpcb/cvpcb_settings.cpp
-
51cvpcb/cvpcb_settings.h
-
1cvpcb/dialogs/dialog_config_equfiles.cpp
-
1cvpcb/dialogs/dialog_config_equfiles.h
-
40cvpcb/display_footprints_frame.cpp
-
6cvpcb/display_footprints_frame.h
-
2eeschema/CMakeLists.txt
-
7eeschema/autoplace_fields.cpp
-
2eeschema/connection_graph.cpp
-
27eeschema/dialogs/dialog_annotate.cpp
-
41eeschema/dialogs/dialog_bom.cpp
-
62eeschema/dialogs/dialog_choose_component.cpp
-
2eeschema/dialogs/dialog_choose_component.h
-
39eeschema/dialogs/dialog_edit_component_in_lib.cpp
-
2eeschema/dialogs/dialog_edit_component_in_lib.h
-
12eeschema/dialogs/dialog_edit_component_in_schematic.cpp
-
2eeschema/dialogs/dialog_edit_component_in_schematic.h
-
63eeschema/dialogs/dialog_fields_editor_global.cpp
-
1eeschema/dialogs/dialog_fields_editor_global.h
-
16eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp
-
26eeschema/dialogs/dialog_lib_edit_pin_table.cpp
-
1eeschema/dialogs/dialog_lib_edit_pin_table.h
-
91eeschema/dialogs/dialog_netlist.cpp
-
55eeschema/dialogs/dialog_plot_schematic.cpp
-
1eeschema/dialogs/dialog_plot_schematic.h
-
2eeschema/dialogs/dialog_print_using_printer.cpp
-
23eeschema/dialogs/dialog_rescue_each.cpp
-
87eeschema/eeschema.cpp
-
306eeschema/eeschema_config.cpp
-
500eeschema/eeschema_settings.cpp
-
203eeschema/eeschema_settings.h
-
7eeschema/files-io.cpp
-
7eeschema/general.h
-
53eeschema/lib_view_frame.cpp
-
7eeschema/lib_view_frame.h
-
120eeschema/libedit/lib_edit_frame.cpp
-
11eeschema/libedit/lib_edit_frame.h
@ -0,0 +1,157 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify it |
|||
* under the terms of the GNU General Public License as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <3d_enums.h>
|
|||
#include <settings/common_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
#include <settings/settings_manager.h>
|
|||
#include <wx/config.h>
|
|||
|
|||
#include "3d_viewer_settings.h"
|
|||
|
|||
///! Update the schema version whenever a migration is required
|
|||
const int viewer3dSchemaVersion = 0; |
|||
|
|||
|
|||
EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() : |
|||
APP_SETTINGS_BASE( "3d_viewer", viewer3dSchemaVersion ), m_Render() |
|||
{ |
|||
m_params.emplace_back( new PARAM<int>( "render.engine", &m_Render.engine, |
|||
static_cast<int>( RENDER_ENGINE::OPENGL_LEGACY ), |
|||
static_cast<int>( RENDER_ENGINE::OPENGL_LEGACY ), |
|||
static_cast<int>( RENDER_ENGINE::RAYTRACING ) ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "render.grid_type", &m_Render.grid_type, |
|||
static_cast<int>( GRID3D_TYPE::NONE ), |
|||
static_cast<int>( GRID3D_TYPE::NONE ), |
|||
static_cast<int>( GRID3D_TYPE::GRID_10MM ) ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "render.material_mode", &m_Render.material_mode, |
|||
static_cast<int>( MATERIAL_MODE::NORMAL ), |
|||
static_cast<int>( MATERIAL_MODE::NORMAL ), |
|||
static_cast<int>( MATERIAL_MODE::CAD_MODE ) ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( |
|||
"render.opengl_copper_thickness", &m_Render.opengl_copper_thickness, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( |
|||
"render.opengl_show_model_bbox", &m_Render.opengl_show_model_bbox, false ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.raytrace_anti_aliasing", |
|||
&m_Render.raytrace_anti_aliasing, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.raytrace_backfloor", |
|||
&m_Render.raytrace_backfloor, false ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.raytrace_post_processing", |
|||
&m_Render.raytrace_post_processing, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.raytrace_procedural_textures", |
|||
&m_Render.raytrace_procedural_textures, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.raytrace_reflections", |
|||
&m_Render.raytrace_reflections, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.raytrace_refractions", |
|||
&m_Render.raytrace_refractions, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.raytrace_shadows", |
|||
&m_Render.raytrace_shadows, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.realistic", &m_Render.realistic, true ) ); |
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "render.show_adhesive", &m_Render.show_adhesive, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.show_axis", &m_Render.show_axis, true ) ); |
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "render.show_board_body", &m_Render.show_board_body, true ) ); |
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "render.show_comments", &m_Render.show_comments, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.show_eco", &m_Render.show_eco, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.show_footprints_insert", |
|||
&m_Render.show_footprints_insert, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.show_footprints_normal", |
|||
&m_Render.show_footprints_normal, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.show_footprints_virtual", |
|||
&m_Render.show_footprints_virtual, true ) ); |
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "render.show_silkscreen", &m_Render.show_silkscreen, true ) ); |
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "render.show_soldermask", &m_Render.show_soldermask, true ) ); |
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "render.show_solderpaste", &m_Render.show_solderpaste, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.show_zones", &m_Render.show_zones, true ) ); |
|||
m_params.emplace_back( new PARAM<bool>( "render.subtract_mask_from_silk", |
|||
&m_Render.subtract_mask_from_silk, false ) ); |
|||
} |
|||
|
|||
|
|||
bool EDA_3D_VIEWER_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) |
|||
{ |
|||
bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg ); |
|||
|
|||
ret &= fromLegacy<int>( aCfg, "RenderEngine", "render.engine" ); |
|||
ret &= fromLegacy<int>( aCfg, "ShowGrid3D", "render.grid_type" ); |
|||
ret &= fromLegacy<int>( aCfg, "Render_Material", "render.material_mode" ); |
|||
ret &= fromLegacy<bool>( |
|||
aCfg, "Render_OGL_ShowCopperThickness", "render.opengl_copper_thickness" ); |
|||
ret &= fromLegacy<bool>( |
|||
aCfg, "Render_OGL_ShowModelBoudingBoxes", "render.opengl_show_model_bbox" ); |
|||
ret &= fromLegacy<bool>( aCfg, "Render_RAY_AntiAliasing", "render.raytrace_anti_aliasing" ); |
|||
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Backfloor", "render.raytrace_backfloor" ); |
|||
ret &= fromLegacy<bool>( aCfg, "Render_RAY_PostProcess", "render.raytrace_post_processing" ); |
|||
ret &= fromLegacy<bool>( |
|||
aCfg, "Render_RAY_ProceduralTextures", "render.raytrace_procedural_textures" ); |
|||
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Reflections", "render.raytrace_reflections" ); |
|||
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Refractions", "render.raytrace_refractions" ); |
|||
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Shadows", "render.raytrace_shadows" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowRealisticMode", "render.realistic" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowAdhesiveLayers", "render.show_adhesive" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowAxis", "render.show_axis" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowBoardBody", "render.show_board_body" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowCommentsLayers", "render.show_comments" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowEcoLayers", "render.show_eco" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowFootprints_Insert", "render.show_footprints_insert" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowFootprints_Normal", "render.show_footprints_normal" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowFootprints_Virtual", "render.show_footprints_virtual" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowSilkScreenLayers", "render.show_silkscreen" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowSolderMasLayers", "render.show_soldermask" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowSolderPasteLayers", "render.show_solderpaste" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowZones", "render.show_zones" ); |
|||
ret &= fromLegacy<bool>( aCfg, "SubtractMaskFromSilk", "render.subtract_mask_from_silk" ); |
|||
|
|||
auto migrate_color = |
|||
[&] ( const std::string& k_r, const std::string& k_g, |
|||
const std::string &k_b, std::string dest ) |
|||
{ |
|||
COLOR4D color( 1, 1, 1, 1 ); |
|||
|
|||
if( aCfg->Read( k_r, &color.r ) && |
|||
aCfg->Read( k_g, &color.g ) && aCfg->Read( k_b, &color.b ) ) |
|||
{ |
|||
( *this )[PointerFromString( dest )] = color; |
|||
} |
|||
}; |
|||
|
|||
migrate_color( "BgColor_Red", "BgColor_Green", "BgColor_Blue", "colors.background_bottom" ); |
|||
migrate_color( |
|||
"BgColor_Red_Top", "BgColor_Green_Top", "BgColor_Blue_Top", "colors.background_top" ); |
|||
migrate_color( |
|||
"BoardBodyColor_Red", "BoardBodyColor_Green", "BoardBodyColor_Blue", "colors.board" ); |
|||
migrate_color( "CopperColor_Red", "CopperColor_Green", "CopperColor_Blue", "colors.copper" ); |
|||
migrate_color( |
|||
"SilkColor_Red", "SilkColor_Green", "SilkColor_Blue", "colors.silkscreen_bottom" ); |
|||
migrate_color( "SilkColor_Red", "SilkColor_Green", "SilkColor_Blue", "colors.silkscreen_top" ); |
|||
migrate_color( "SMaskColor_Red", "SMaskColor_Green", "SMaskColor_Blue", "colors.soldermask" ); |
|||
migrate_color( |
|||
"SPasteColor_Red", "SPasteColor_Green", "SPasteColor_Blue", "colors.solderpaste" ); |
|||
|
|||
return ret; |
|||
} |
|||
@ -0,0 +1,122 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify it |
|||
* under the terms of the GNU General Public License as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef EDA_3D_VIEWER_SETTINGS_H_ |
|||
#define EDA_3D_VIEWER_SETTINGS_H_ |
|||
|
|||
#include <settings/app_settings.h> |
|||
#include <settings/parameters.h> |
|||
|
|||
|
|||
class EDA_3D_VIEWER_SETTINGS : public APP_SETTINGS_BASE |
|||
{ |
|||
public: |
|||
struct RENDER_SETTINGS |
|||
{ |
|||
int engine; |
|||
int grid_type; |
|||
int material_mode; |
|||
bool opengl_copper_thickness; |
|||
bool opengl_show_model_bbox; |
|||
bool raytrace_anti_aliasing; |
|||
bool raytrace_backfloor; |
|||
bool raytrace_post_processing; |
|||
bool raytrace_procedural_textures; |
|||
bool raytrace_reflections; |
|||
bool raytrace_refractions; |
|||
bool raytrace_shadows; |
|||
bool realistic; |
|||
bool show_adhesive; |
|||
bool show_axis; |
|||
bool show_board_body; |
|||
bool show_comments; |
|||
bool show_eco; |
|||
bool show_footprints_insert; |
|||
bool show_footprints_normal; |
|||
bool show_footprints_virtual; |
|||
bool show_silkscreen; |
|||
bool show_soldermask; |
|||
bool show_solderpaste; |
|||
bool show_zones; |
|||
bool subtract_mask_from_silk; |
|||
}; |
|||
|
|||
EDA_3D_VIEWER_SETTINGS(); |
|||
|
|||
virtual ~EDA_3D_VIEWER_SETTINGS() {} |
|||
|
|||
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override; |
|||
|
|||
RENDER_SETTINGS m_Render; |
|||
|
|||
protected: |
|||
|
|||
virtual std::string getLegacyFrameName() const override { return "Viewer3DFrameName"; } |
|||
}; |
|||
|
|||
|
|||
// Individual color param: not necessary once 3D viewer is migrated to color theme system |
|||
// TODO(JE) remove once irrelevant |
|||
class PARAM_COLOR : public PARAM_BASE |
|||
{ |
|||
public: |
|||
PARAM_COLOR( const std::string& aJsonPath, COLOR4D* aPtr, COLOR4D aDefault, |
|||
bool aReadOnly = false ) : |
|||
PARAM_BASE( aJsonPath, aReadOnly ), m_ptr( aPtr ), m_default( aDefault ) |
|||
{} |
|||
|
|||
void Load( JSON_SETTINGS* aSettings ) const override |
|||
{ |
|||
if( m_readOnly ) |
|||
return; |
|||
|
|||
COLOR4D val = m_default; |
|||
|
|||
try |
|||
{ |
|||
val = aSettings->Get<COLOR4D>( m_path ); |
|||
} |
|||
catch( ... ) |
|||
{} |
|||
|
|||
*m_ptr = val; |
|||
} |
|||
|
|||
void Store( JSON_SETTINGS* aSettings) const override |
|||
{ |
|||
aSettings->Set<COLOR4D>( m_path, *m_ptr ); |
|||
} |
|||
|
|||
COLOR4D GetDefault() const |
|||
{ |
|||
return m_default; |
|||
} |
|||
|
|||
virtual void SetDefault() override |
|||
{ |
|||
*m_ptr = m_default; |
|||
} |
|||
|
|||
private: |
|||
COLOR4D* m_ptr; |
|||
COLOR4D m_default; |
|||
}; |
|||
|
|||
#endif |
|||
@ -0,0 +1,68 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#include <bitmap2cmp_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
#include <wx/config.h>
|
|||
|
|||
|
|||
///! Update the schema version whenever a migration is required
|
|||
const int bitmap2cmpSchemaVersion = 0; |
|||
|
|||
|
|||
BITMAP2CMP_SETTINGS::BITMAP2CMP_SETTINGS() : |
|||
APP_SETTINGS_BASE( "bitmap2component", bitmap2cmpSchemaVersion ), |
|||
m_BitmapFileName(), m_ConvertedFileName(), m_Units(), m_Threshold(), m_Negative(), |
|||
m_LastFormat(), m_LastModLayer() |
|||
{ |
|||
m_params.emplace_back( new PARAM<wxString>( "bitmap_file_name", &m_BitmapFileName, "" ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<wxString>( "converted_file_name", &m_ConvertedFileName, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "units", &m_Units, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "threshold", &m_Threshold, 50 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "negative", &m_Negative, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "last_format", &m_LastFormat, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "last_mod_layer", &m_LastModLayer, 0 ) ); |
|||
} |
|||
|
|||
|
|||
bool BITMAP2CMP_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) |
|||
{ |
|||
bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg ); |
|||
|
|||
ret &= fromLegacyString( aCfg, "Last_input", "bitmap_file_name" ); |
|||
ret &= fromLegacyString( aCfg, "Last_output", "converted_file_name" ); |
|||
ret &= fromLegacy<int>( aCfg, "Last_format", "last_format" ); |
|||
ret &= fromLegacy<int>( aCfg, "Last_modlayer", "last_mod_layer" ); |
|||
ret &= fromLegacy<int>( aCfg, "Threshold", "threshold" ); |
|||
ret &= fromLegacy<bool>( aCfg, "Negative_choice", "negative" ); |
|||
ret &= fromLegacy<int>( aCfg, "Unit_selection", "units" ); |
|||
|
|||
return ret; |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#ifndef _BITMAP2CMP_SETTINGS_H |
|||
#define _BITMAP2CMP_SETTINGS_H |
|||
|
|||
#include <settings/app_settings.h> |
|||
|
|||
class BITMAP2CMP_SETTINGS : public APP_SETTINGS_BASE |
|||
{ |
|||
public: |
|||
BITMAP2CMP_SETTINGS(); |
|||
|
|||
virtual ~BITMAP2CMP_SETTINGS() {} |
|||
|
|||
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override; |
|||
|
|||
wxString m_BitmapFileName; |
|||
|
|||
wxString m_ConvertedFileName; |
|||
|
|||
int m_Units; |
|||
|
|||
int m_Threshold; |
|||
|
|||
bool m_Negative; |
|||
|
|||
int m_LastFormat; |
|||
|
|||
int m_LastModLayer; |
|||
|
|||
protected: |
|||
|
|||
virtual std::string getLegacyFrameName() const override { return "Bmconverter_"; } |
|||
}; |
|||
|
|||
|
|||
#endif |
|||
@ -0,0 +1,150 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify it |
|||
* under the terms of the GNU General Public License as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <bitmaps.h>
|
|||
#include <dialogs/dialog_migrate_settings.h>
|
|||
#include <settings/settings_manager.h>
|
|||
|
|||
|
|||
DIALOG_MIGRATE_SETTINGS::DIALOG_MIGRATE_SETTINGS( SETTINGS_MANAGER* aManager ) : |
|||
DIALOG_MIGRATE_SETTINGS_BASE( nullptr ), m_manager( aManager ) |
|||
{ |
|||
m_standardButtonsCancel->SetLabel( _( "Quit KiCad" ) ); |
|||
|
|||
m_btnCustomPath->SetBitmap( KiBitmap( folder_xpm ) ); |
|||
|
|||
GetSizer()->SetSizeHints( this ); |
|||
Centre(); |
|||
} |
|||
|
|||
|
|||
DIALOG_MIGRATE_SETTINGS::~DIALOG_MIGRATE_SETTINGS() |
|||
{ |
|||
} |
|||
|
|||
|
|||
bool DIALOG_MIGRATE_SETTINGS::TransferDataToWindow() |
|||
{ |
|||
if( !wxDialog::TransferDataToWindow() ) |
|||
return false; |
|||
|
|||
wxString str; |
|||
str.Printf( _( "Welcome to KiCad %s!" ), SETTINGS_MANAGER::GetSettingsVersion() ); |
|||
m_lblWelcome->SetLabelText( str ); |
|||
|
|||
std::vector<wxString> paths; |
|||
|
|||
if( !m_manager->GetPreviousVersionPaths( &paths ) ) |
|||
{ |
|||
m_btnPrevVer->SetLabelText( _( "Import settings from a previous version (none found)" ) ); |
|||
m_btnUseDefaults->SetValue( true ); |
|||
} |
|||
else |
|||
{ |
|||
m_cbPath->Clear(); |
|||
|
|||
for( const auto& path : paths ) |
|||
m_cbPath->Append( path ); |
|||
|
|||
m_cbPath->SetSelection( 0 ); |
|||
m_btnPrevVer->SetValue( true ); |
|||
} |
|||
|
|||
Fit(); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
bool DIALOG_MIGRATE_SETTINGS::TransferDataFromWindow() |
|||
{ |
|||
if( !wxDialog::TransferDataFromWindow() ) |
|||
return false; |
|||
|
|||
if( m_btnPrevVer->GetValue() ) |
|||
m_manager->SetMigrationSource( m_cbPath->GetValue() ); |
|||
else |
|||
m_manager->SetMigrationSource( wxEmptyString ); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
void DIALOG_MIGRATE_SETTINGS::OnPrevVerSelected( wxCommandEvent& event ) |
|||
{ |
|||
m_standardButtons->GetAffirmativeButton()->Enable(); |
|||
m_cbPath->Enable(); |
|||
m_btnCustomPath->Enable(); |
|||
validatePath(); |
|||
} |
|||
|
|||
|
|||
void DIALOG_MIGRATE_SETTINGS::OnPathChanged( wxCommandEvent& event ) |
|||
{ |
|||
validatePath(); |
|||
} |
|||
|
|||
|
|||
void DIALOG_MIGRATE_SETTINGS::OnPathDefocused( wxFocusEvent& event ) |
|||
{ |
|||
validatePath(); |
|||
} |
|||
|
|||
|
|||
void DIALOG_MIGRATE_SETTINGS::OnChoosePath( wxCommandEvent& event ) |
|||
{ |
|||
wxDirDialog dlg( nullptr, _( "Select Settings Path" ), m_cbPath->GetValue(), |
|||
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); |
|||
|
|||
if( dlg.ShowModal() == wxID_OK ) |
|||
{ |
|||
m_cbPath->SetValue( dlg.GetPath() ); |
|||
validatePath(); |
|||
} |
|||
} |
|||
|
|||
|
|||
void DIALOG_MIGRATE_SETTINGS::OnDefaultSelected( wxCommandEvent& event ) |
|||
{ |
|||
m_standardButtons->GetAffirmativeButton()->Enable(); |
|||
m_cbPath->Disable(); |
|||
m_btnCustomPath->Disable(); |
|||
showPathError( false ); |
|||
} |
|||
|
|||
|
|||
bool DIALOG_MIGRATE_SETTINGS::validatePath() |
|||
{ |
|||
wxString path = m_cbPath->GetValue(); |
|||
bool valid = m_manager->IsSettingsPathValid( path ); |
|||
|
|||
showPathError( !valid ); |
|||
m_standardButtons->GetAffirmativeButton()->Enable( valid && !path.IsEmpty() ); |
|||
|
|||
return valid; |
|||
} |
|||
|
|||
|
|||
void DIALOG_MIGRATE_SETTINGS::showPathError( bool aShow ) |
|||
{ |
|||
m_lblPathError->Show( aShow ); |
|||
Layout(); |
|||
Fit(); |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify it |
|||
* under the terms of the GNU General Public License as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef _DIALOG_MIGRATE_SETTINGS_H |
|||
#define _DIALOG_MIGRATE_SETTINGS_H |
|||
|
|||
#include "dialog_migrate_settings_base.h" |
|||
|
|||
|
|||
class SETTINGS_MANAGER; |
|||
|
|||
|
|||
class DIALOG_MIGRATE_SETTINGS : public DIALOG_MIGRATE_SETTINGS_BASE |
|||
{ |
|||
public: |
|||
DIALOG_MIGRATE_SETTINGS( SETTINGS_MANAGER* aManager ); |
|||
|
|||
~DIALOG_MIGRATE_SETTINGS() override; |
|||
|
|||
bool TransferDataToWindow() override; |
|||
|
|||
bool TransferDataFromWindow() override; |
|||
|
|||
protected: |
|||
|
|||
void OnPrevVerSelected( wxCommandEvent& event ) override; |
|||
|
|||
void OnPathChanged( wxCommandEvent& event ) override; |
|||
|
|||
void OnPathDefocused( wxFocusEvent& event ) override; |
|||
|
|||
void OnChoosePath( wxCommandEvent& event ) override; |
|||
|
|||
void OnDefaultSelected( wxCommandEvent& event ) override; |
|||
|
|||
private: |
|||
|
|||
bool validatePath(); |
|||
|
|||
void showPathError( bool aShow = true ); |
|||
|
|||
SETTINGS_MANAGER* m_manager; |
|||
}; |
|||
|
|||
#endif |
|||
@ -0,0 +1,102 @@ |
|||
///////////////////////////////////////////////////////////////////////////
|
|||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
|||
// http://www.wxformbuilder.org/
|
|||
//
|
|||
// PLEASE DO *NOT* EDIT THIS FILE!
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
#include "dialog_migrate_settings_base.h"
|
|||
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
DIALOG_MIGRATE_SETTINGS_BASE::DIALOG_MIGRATE_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) |
|||
{ |
|||
this->SetSizeHints( wxDefaultSize, wxDefaultSize ); |
|||
|
|||
m_sizer = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
wxBoxSizer* bSizer6; |
|||
bSizer6 = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
m_lblWelcome = new wxStaticText( this, wxID_ANY, wxT("Welcome to KiCad %s!"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
m_lblWelcome->Wrap( -1 ); |
|||
m_lblWelcome->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); |
|||
|
|||
bSizer6->Add( m_lblWelcome, 0, wxALL, 5 ); |
|||
|
|||
m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("How would you like to configure KiCad?"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
m_staticText2->Wrap( -1 ); |
|||
bSizer6->Add( m_staticText2, 0, wxALL, 5 ); |
|||
|
|||
m_btnPrevVer = new wxRadioButton( this, wxID_ANY, wxT("Import settings from a previous version at:"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
bSizer6->Add( m_btnPrevVer, 0, wxALL, 5 ); |
|||
|
|||
wxBoxSizer* bSizer5; |
|||
bSizer5 = new wxBoxSizer( wxHORIZONTAL ); |
|||
|
|||
m_cbPath = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); |
|||
m_cbPath->SetMinSize( wxSize( 480,-1 ) ); |
|||
|
|||
bSizer5->Add( m_cbPath, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); |
|||
|
|||
m_btnCustomPath = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); |
|||
m_btnCustomPath->SetToolTip( wxT("Choose a different path") ); |
|||
|
|||
bSizer5->Add( m_btnCustomPath, 0, wxALL, 5 ); |
|||
|
|||
|
|||
bSizer6->Add( bSizer5, 1, wxEXPAND, 5 ); |
|||
|
|||
m_lblPathError = new wxStaticText( this, wxID_ANY, wxT("The selected path does not contain valid KiCad settings!"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
m_lblPathError->Wrap( -1 ); |
|||
m_lblPathError->SetForegroundColour( wxColour( 255, 43, 0 ) ); |
|||
m_lblPathError->Hide(); |
|||
|
|||
bSizer6->Add( m_lblPathError, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); |
|||
|
|||
m_btnUseDefaults = new wxRadioButton( this, wxID_ANY, wxT("Start with default settings"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
bSizer6->Add( m_btnUseDefaults, 0, wxALL, 5 ); |
|||
|
|||
|
|||
m_sizer->Add( bSizer6, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); |
|||
|
|||
|
|||
m_sizer->Add( 0, 0, 1, wxEXPAND, 5 ); |
|||
|
|||
m_standardButtons = new wxStdDialogButtonSizer(); |
|||
m_standardButtonsOK = new wxButton( this, wxID_OK ); |
|||
m_standardButtons->AddButton( m_standardButtonsOK ); |
|||
m_standardButtonsCancel = new wxButton( this, wxID_CANCEL ); |
|||
m_standardButtons->AddButton( m_standardButtonsCancel ); |
|||
m_standardButtons->Realize(); |
|||
m_standardButtons->SetMinSize( wxSize( -1,50 ) ); |
|||
|
|||
m_sizer->Add( m_standardButtons, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 10 ); |
|||
|
|||
|
|||
this->SetSizer( m_sizer ); |
|||
this->Layout(); |
|||
m_sizer->Fit( this ); |
|||
|
|||
this->Centre( wxBOTH ); |
|||
|
|||
// Connect Events
|
|||
m_btnPrevVer->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPrevVerSelected ), NULL, this ); |
|||
m_cbPath->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathChanged ), NULL, this ); |
|||
m_cbPath->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathDefocused ), NULL, this ); |
|||
m_cbPath->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathChanged ), NULL, this ); |
|||
m_btnCustomPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnChoosePath ), NULL, this ); |
|||
m_btnUseDefaults->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnDefaultSelected ), NULL, this ); |
|||
} |
|||
|
|||
DIALOG_MIGRATE_SETTINGS_BASE::~DIALOG_MIGRATE_SETTINGS_BASE() |
|||
{ |
|||
// Disconnect Events
|
|||
m_btnPrevVer->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPrevVerSelected ), NULL, this ); |
|||
m_cbPath->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathChanged ), NULL, this ); |
|||
m_cbPath->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathDefocused ), NULL, this ); |
|||
m_cbPath->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathChanged ), NULL, this ); |
|||
m_btnCustomPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnChoosePath ), NULL, this ); |
|||
m_btnUseDefaults->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnDefaultSelected ), NULL, this ); |
|||
|
|||
} |
|||
@ -0,0 +1,568 @@ |
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> |
|||
<wxFormBuilder_Project> |
|||
<FileVersion major="1" minor="15" /> |
|||
<object class="Project" expanded="1"> |
|||
<property name="class_decoration">; </property> |
|||
<property name="code_generation">C++</property> |
|||
<property name="disconnect_events">1</property> |
|||
<property name="disconnect_mode">source_name</property> |
|||
<property name="disconnect_php_events">0</property> |
|||
<property name="disconnect_python_events">0</property> |
|||
<property name="embedded_files_path">res</property> |
|||
<property name="encoding">UTF-8</property> |
|||
<property name="event_generation">connect</property> |
|||
<property name="file">dialog_migrate_settings_base</property> |
|||
<property name="first_id">1000</property> |
|||
<property name="help_provider">none</property> |
|||
<property name="indent_with_spaces"></property> |
|||
<property name="internationalize">0</property> |
|||
<property name="name">DIALOG_MIGRATE_SETTINGS</property> |
|||
<property name="namespace"></property> |
|||
<property name="path">.</property> |
|||
<property name="precompiled_header"></property> |
|||
<property name="relative_path">1</property> |
|||
<property name="skip_lua_events">1</property> |
|||
<property name="skip_php_events">1</property> |
|||
<property name="skip_python_events">1</property> |
|||
<property name="ui_table">UI</property> |
|||
<property name="use_enum">0</property> |
|||
<property name="use_microsoft_bom">0</property> |
|||
<object class="Dialog" expanded="1"> |
|||
<property name="aui_managed">0</property> |
|||
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property> |
|||
<property name="bg"></property> |
|||
<property name="center">wxBOTH</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="enabled">1</property> |
|||
<property name="event_handler">impl_virtual</property> |
|||
<property name="extra_style"></property> |
|||
<property name="fg"></property> |
|||
<property name="font"></property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="minimum_size"></property> |
|||
<property name="name">DIALOG_MIGRATE_SETTINGS_BASE</property> |
|||
<property name="pos"></property> |
|||
<property name="size"></property> |
|||
<property name="style">wxCAPTION</property> |
|||
<property name="subclass">DIALOG_SHIM; dialog_shim.h; forward_declare</property> |
|||
<property name="title">Configure KiCad Settings Path</property> |
|||
<property name="tooltip"></property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<object class="wxBoxSizer" expanded="1"> |
|||
<property name="minimum_size">-1,-1</property> |
|||
<property name="name">m_sizer</property> |
|||
<property name="orient">wxVERTICAL</property> |
|||
<property name="permission">protected</property> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxBoxSizer" expanded="1"> |
|||
<property name="minimum_size"></property> |
|||
<property name="name">bSizer6</property> |
|||
<property name="orient">wxVERTICAL</property> |
|||
<property name="permission">none</property> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxALL</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxStaticText" expanded="1"> |
|||
<property name="BottomDockable">1</property> |
|||
<property name="LeftDockable">1</property> |
|||
<property name="RightDockable">1</property> |
|||
<property name="TopDockable">1</property> |
|||
<property name="aui_layer"></property> |
|||
<property name="aui_name"></property> |
|||
<property name="aui_position"></property> |
|||
<property name="aui_row"></property> |
|||
<property name="best_size"></property> |
|||
<property name="bg"></property> |
|||
<property name="caption"></property> |
|||
<property name="caption_visible">1</property> |
|||
<property name="center_pane">0</property> |
|||
<property name="close_button">1</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="default_pane">0</property> |
|||
<property name="dock">Dock</property> |
|||
<property name="dock_fixed">0</property> |
|||
<property name="docking">Left</property> |
|||
<property name="enabled">1</property> |
|||
<property name="fg"></property> |
|||
<property name="floatable">1</property> |
|||
<property name="font">,90,92,-1,70,0</property> |
|||
<property name="gripper">0</property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="label">Welcome to KiCad %s!</property> |
|||
<property name="markup">0</property> |
|||
<property name="max_size"></property> |
|||
<property name="maximize_button">0</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="min_size"></property> |
|||
<property name="minimize_button">0</property> |
|||
<property name="minimum_size">-1,-1</property> |
|||
<property name="moveable">1</property> |
|||
<property name="name">m_lblWelcome</property> |
|||
<property name="pane_border">1</property> |
|||
<property name="pane_position"></property> |
|||
<property name="pane_size"></property> |
|||
<property name="permission">protected</property> |
|||
<property name="pin_button">1</property> |
|||
<property name="pos"></property> |
|||
<property name="resize">Resizable</property> |
|||
<property name="show">1</property> |
|||
<property name="size"></property> |
|||
<property name="style"></property> |
|||
<property name="subclass">; ; forward_declare</property> |
|||
<property name="toolbar_pane">0</property> |
|||
<property name="tooltip"></property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<property name="wrap">-1</property> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxALL</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxStaticText" expanded="1"> |
|||
<property name="BottomDockable">1</property> |
|||
<property name="LeftDockable">1</property> |
|||
<property name="RightDockable">1</property> |
|||
<property name="TopDockable">1</property> |
|||
<property name="aui_layer"></property> |
|||
<property name="aui_name"></property> |
|||
<property name="aui_position"></property> |
|||
<property name="aui_row"></property> |
|||
<property name="best_size"></property> |
|||
<property name="bg"></property> |
|||
<property name="caption"></property> |
|||
<property name="caption_visible">1</property> |
|||
<property name="center_pane">0</property> |
|||
<property name="close_button">1</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="default_pane">0</property> |
|||
<property name="dock">Dock</property> |
|||
<property name="dock_fixed">0</property> |
|||
<property name="docking">Left</property> |
|||
<property name="enabled">1</property> |
|||
<property name="fg"></property> |
|||
<property name="floatable">1</property> |
|||
<property name="font"></property> |
|||
<property name="gripper">0</property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="label">How would you like to configure KiCad?</property> |
|||
<property name="markup">0</property> |
|||
<property name="max_size"></property> |
|||
<property name="maximize_button">0</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="min_size"></property> |
|||
<property name="minimize_button">0</property> |
|||
<property name="minimum_size"></property> |
|||
<property name="moveable">1</property> |
|||
<property name="name">m_staticText2</property> |
|||
<property name="pane_border">1</property> |
|||
<property name="pane_position"></property> |
|||
<property name="pane_size"></property> |
|||
<property name="permission">protected</property> |
|||
<property name="pin_button">1</property> |
|||
<property name="pos"></property> |
|||
<property name="resize">Resizable</property> |
|||
<property name="show">1</property> |
|||
<property name="size"></property> |
|||
<property name="style"></property> |
|||
<property name="subclass">; ; forward_declare</property> |
|||
<property name="toolbar_pane">0</property> |
|||
<property name="tooltip"></property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<property name="wrap">-1</property> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxALL</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxRadioButton" expanded="1"> |
|||
<property name="BottomDockable">1</property> |
|||
<property name="LeftDockable">1</property> |
|||
<property name="RightDockable">1</property> |
|||
<property name="TopDockable">1</property> |
|||
<property name="aui_layer"></property> |
|||
<property name="aui_name"></property> |
|||
<property name="aui_position"></property> |
|||
<property name="aui_row"></property> |
|||
<property name="best_size"></property> |
|||
<property name="bg"></property> |
|||
<property name="caption"></property> |
|||
<property name="caption_visible">1</property> |
|||
<property name="center_pane">0</property> |
|||
<property name="close_button">1</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="default_pane">0</property> |
|||
<property name="dock">Dock</property> |
|||
<property name="dock_fixed">0</property> |
|||
<property name="docking">Left</property> |
|||
<property name="enabled">1</property> |
|||
<property name="fg"></property> |
|||
<property name="floatable">1</property> |
|||
<property name="font"></property> |
|||
<property name="gripper">0</property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="label">Import settings from a previous version at:</property> |
|||
<property name="max_size"></property> |
|||
<property name="maximize_button">0</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="min_size"></property> |
|||
<property name="minimize_button">0</property> |
|||
<property name="minimum_size"></property> |
|||
<property name="moveable">1</property> |
|||
<property name="name">m_btnPrevVer</property> |
|||
<property name="pane_border">1</property> |
|||
<property name="pane_position"></property> |
|||
<property name="pane_size"></property> |
|||
<property name="permission">protected</property> |
|||
<property name="pin_button">1</property> |
|||
<property name="pos"></property> |
|||
<property name="resize">Resizable</property> |
|||
<property name="show">1</property> |
|||
<property name="size"></property> |
|||
<property name="style"></property> |
|||
<property name="subclass">; ; forward_declare</property> |
|||
<property name="toolbar_pane">0</property> |
|||
<property name="tooltip"></property> |
|||
<property name="validator_data_type"></property> |
|||
<property name="validator_style">wxFILTER_NONE</property> |
|||
<property name="validator_type">wxDefaultValidator</property> |
|||
<property name="validator_variable"></property> |
|||
<property name="value">0</property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<event name="OnRadioButton">OnPrevVerSelected</event> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxEXPAND</property> |
|||
<property name="proportion">1</property> |
|||
<object class="wxBoxSizer" expanded="1"> |
|||
<property name="minimum_size"></property> |
|||
<property name="name">bSizer5</property> |
|||
<property name="orient">wxHORIZONTAL</property> |
|||
<property name="permission">none</property> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxComboBox" expanded="1"> |
|||
<property name="BottomDockable">1</property> |
|||
<property name="LeftDockable">1</property> |
|||
<property name="RightDockable">1</property> |
|||
<property name="TopDockable">1</property> |
|||
<property name="aui_layer"></property> |
|||
<property name="aui_name"></property> |
|||
<property name="aui_position"></property> |
|||
<property name="aui_row"></property> |
|||
<property name="best_size"></property> |
|||
<property name="bg"></property> |
|||
<property name="caption"></property> |
|||
<property name="caption_visible">1</property> |
|||
<property name="center_pane">0</property> |
|||
<property name="choices"></property> |
|||
<property name="close_button">1</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="default_pane">0</property> |
|||
<property name="dock">Dock</property> |
|||
<property name="dock_fixed">0</property> |
|||
<property name="docking">Left</property> |
|||
<property name="enabled">1</property> |
|||
<property name="fg"></property> |
|||
<property name="floatable">1</property> |
|||
<property name="font"></property> |
|||
<property name="gripper">0</property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="max_size"></property> |
|||
<property name="maximize_button">0</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="min_size"></property> |
|||
<property name="minimize_button">0</property> |
|||
<property name="minimum_size">480,-1</property> |
|||
<property name="moveable">1</property> |
|||
<property name="name">m_cbPath</property> |
|||
<property name="pane_border">1</property> |
|||
<property name="pane_position"></property> |
|||
<property name="pane_size"></property> |
|||
<property name="permission">protected</property> |
|||
<property name="pin_button">1</property> |
|||
<property name="pos"></property> |
|||
<property name="resize">Resizable</property> |
|||
<property name="selection">-1</property> |
|||
<property name="show">1</property> |
|||
<property name="size"></property> |
|||
<property name="style"></property> |
|||
<property name="subclass">; ; forward_declare</property> |
|||
<property name="toolbar_pane">0</property> |
|||
<property name="tooltip"></property> |
|||
<property name="validator_data_type"></property> |
|||
<property name="validator_style">wxFILTER_NONE</property> |
|||
<property name="validator_type">wxDefaultValidator</property> |
|||
<property name="validator_variable"></property> |
|||
<property name="value"></property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<event name="OnCombobox">OnPathChanged</event> |
|||
<event name="OnKillFocus">OnPathDefocused</event> |
|||
<event name="OnTextEnter">OnPathChanged</event> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxALL</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxBitmapButton" expanded="1"> |
|||
<property name="BottomDockable">1</property> |
|||
<property name="LeftDockable">1</property> |
|||
<property name="RightDockable">1</property> |
|||
<property name="TopDockable">1</property> |
|||
<property name="aui_layer"></property> |
|||
<property name="aui_name"></property> |
|||
<property name="aui_position"></property> |
|||
<property name="aui_row"></property> |
|||
<property name="best_size"></property> |
|||
<property name="bg"></property> |
|||
<property name="bitmap"></property> |
|||
<property name="caption"></property> |
|||
<property name="caption_visible">1</property> |
|||
<property name="center_pane">0</property> |
|||
<property name="close_button">1</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="current"></property> |
|||
<property name="default">0</property> |
|||
<property name="default_pane">0</property> |
|||
<property name="disabled"></property> |
|||
<property name="dock">Dock</property> |
|||
<property name="dock_fixed">0</property> |
|||
<property name="docking">Left</property> |
|||
<property name="enabled">1</property> |
|||
<property name="fg"></property> |
|||
<property name="floatable">1</property> |
|||
<property name="focus"></property> |
|||
<property name="font"></property> |
|||
<property name="gripper">0</property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="label">Choose Path</property> |
|||
<property name="margins"></property> |
|||
<property name="markup">0</property> |
|||
<property name="max_size"></property> |
|||
<property name="maximize_button">0</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="min_size"></property> |
|||
<property name="minimize_button">0</property> |
|||
<property name="minimum_size"></property> |
|||
<property name="moveable">1</property> |
|||
<property name="name">m_btnCustomPath</property> |
|||
<property name="pane_border">1</property> |
|||
<property name="pane_position"></property> |
|||
<property name="pane_size"></property> |
|||
<property name="permission">protected</property> |
|||
<property name="pin_button">1</property> |
|||
<property name="pos"></property> |
|||
<property name="position"></property> |
|||
<property name="pressed"></property> |
|||
<property name="resize">Resizable</property> |
|||
<property name="show">1</property> |
|||
<property name="size"></property> |
|||
<property name="style"></property> |
|||
<property name="subclass">; ; forward_declare</property> |
|||
<property name="toolbar_pane">0</property> |
|||
<property name="tooltip">Choose a different path</property> |
|||
<property name="validator_data_type"></property> |
|||
<property name="validator_style">wxFILTER_NONE</property> |
|||
<property name="validator_type">wxDefaultValidator</property> |
|||
<property name="validator_variable"></property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<event name="OnButtonClick">OnChoosePath</event> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxALL</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxStaticText" expanded="1"> |
|||
<property name="BottomDockable">1</property> |
|||
<property name="LeftDockable">1</property> |
|||
<property name="RightDockable">1</property> |
|||
<property name="TopDockable">1</property> |
|||
<property name="aui_layer"></property> |
|||
<property name="aui_name"></property> |
|||
<property name="aui_position"></property> |
|||
<property name="aui_row"></property> |
|||
<property name="best_size"></property> |
|||
<property name="bg"></property> |
|||
<property name="caption"></property> |
|||
<property name="caption_visible">1</property> |
|||
<property name="center_pane">0</property> |
|||
<property name="close_button">1</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="default_pane">0</property> |
|||
<property name="dock">Dock</property> |
|||
<property name="dock_fixed">0</property> |
|||
<property name="docking">Left</property> |
|||
<property name="enabled">1</property> |
|||
<property name="fg">255,43,0</property> |
|||
<property name="floatable">1</property> |
|||
<property name="font"></property> |
|||
<property name="gripper">0</property> |
|||
<property name="hidden">1</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="label">The selected path does not contain valid KiCad settings!</property> |
|||
<property name="markup">0</property> |
|||
<property name="max_size"></property> |
|||
<property name="maximize_button">0</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="min_size"></property> |
|||
<property name="minimize_button">0</property> |
|||
<property name="minimum_size"></property> |
|||
<property name="moveable">1</property> |
|||
<property name="name">m_lblPathError</property> |
|||
<property name="pane_border">1</property> |
|||
<property name="pane_position"></property> |
|||
<property name="pane_size"></property> |
|||
<property name="permission">protected</property> |
|||
<property name="pin_button">1</property> |
|||
<property name="pos"></property> |
|||
<property name="resize">Resizable</property> |
|||
<property name="show">1</property> |
|||
<property name="size"></property> |
|||
<property name="style"></property> |
|||
<property name="subclass">; ; forward_declare</property> |
|||
<property name="toolbar_pane">0</property> |
|||
<property name="tooltip"></property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<property name="wrap">-1</property> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxALL</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxRadioButton" expanded="1"> |
|||
<property name="BottomDockable">1</property> |
|||
<property name="LeftDockable">1</property> |
|||
<property name="RightDockable">1</property> |
|||
<property name="TopDockable">1</property> |
|||
<property name="aui_layer"></property> |
|||
<property name="aui_name"></property> |
|||
<property name="aui_position"></property> |
|||
<property name="aui_row"></property> |
|||
<property name="best_size"></property> |
|||
<property name="bg"></property> |
|||
<property name="caption"></property> |
|||
<property name="caption_visible">1</property> |
|||
<property name="center_pane">0</property> |
|||
<property name="close_button">1</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="default_pane">0</property> |
|||
<property name="dock">Dock</property> |
|||
<property name="dock_fixed">0</property> |
|||
<property name="docking">Left</property> |
|||
<property name="enabled">1</property> |
|||
<property name="fg"></property> |
|||
<property name="floatable">1</property> |
|||
<property name="font"></property> |
|||
<property name="gripper">0</property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="label">Start with default settings</property> |
|||
<property name="max_size"></property> |
|||
<property name="maximize_button">0</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="min_size"></property> |
|||
<property name="minimize_button">0</property> |
|||
<property name="minimum_size"></property> |
|||
<property name="moveable">1</property> |
|||
<property name="name">m_btnUseDefaults</property> |
|||
<property name="pane_border">1</property> |
|||
<property name="pane_position"></property> |
|||
<property name="pane_size"></property> |
|||
<property name="permission">protected</property> |
|||
<property name="pin_button">1</property> |
|||
<property name="pos"></property> |
|||
<property name="resize">Resizable</property> |
|||
<property name="show">1</property> |
|||
<property name="size"></property> |
|||
<property name="style"></property> |
|||
<property name="subclass">; ; forward_declare</property> |
|||
<property name="toolbar_pane">0</property> |
|||
<property name="tooltip"></property> |
|||
<property name="validator_data_type"></property> |
|||
<property name="validator_style">wxFILTER_NONE</property> |
|||
<property name="validator_type">wxDefaultValidator</property> |
|||
<property name="validator_variable"></property> |
|||
<property name="value">0</property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<event name="OnRadioButton">OnDefaultSelected</event> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxEXPAND</property> |
|||
<property name="proportion">1</property> |
|||
<object class="spacer" expanded="1"> |
|||
<property name="height">0</property> |
|||
<property name="permission">protected</property> |
|||
<property name="width">0</property> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">10</property> |
|||
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxStdDialogButtonSizer" expanded="1"> |
|||
<property name="Apply">0</property> |
|||
<property name="Cancel">1</property> |
|||
<property name="ContextHelp">0</property> |
|||
<property name="Help">0</property> |
|||
<property name="No">0</property> |
|||
<property name="OK">1</property> |
|||
<property name="Save">0</property> |
|||
<property name="Yes">0</property> |
|||
<property name="minimum_size">-1,50</property> |
|||
<property name="name">m_standardButtons</property> |
|||
<property name="permission">protected</property> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</wxFormBuilder_Project> |
|||
@ -0,0 +1,66 @@ |
|||
/////////////////////////////////////////////////////////////////////////// |
|||
// C++ code generated with wxFormBuilder (version Oct 26 2018) |
|||
// http://www.wxformbuilder.org/ |
|||
// |
|||
// PLEASE DO *NOT* EDIT THIS FILE! |
|||
/////////////////////////////////////////////////////////////////////////// |
|||
|
|||
#pragma once |
|||
|
|||
#include <wx/artprov.h> |
|||
#include <wx/xrc/xmlres.h> |
|||
#include "dialog_shim.h" |
|||
#include <wx/string.h> |
|||
#include <wx/stattext.h> |
|||
#include <wx/gdicmn.h> |
|||
#include <wx/font.h> |
|||
#include <wx/colour.h> |
|||
#include <wx/settings.h> |
|||
#include <wx/radiobut.h> |
|||
#include <wx/combobox.h> |
|||
#include <wx/bmpbuttn.h> |
|||
#include <wx/bitmap.h> |
|||
#include <wx/image.h> |
|||
#include <wx/icon.h> |
|||
#include <wx/button.h> |
|||
#include <wx/sizer.h> |
|||
#include <wx/dialog.h> |
|||
|
|||
/////////////////////////////////////////////////////////////////////////// |
|||
|
|||
|
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
/// Class DIALOG_MIGRATE_SETTINGS_BASE |
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
class DIALOG_MIGRATE_SETTINGS_BASE : public DIALOG_SHIM |
|||
{ |
|||
private: |
|||
|
|||
protected: |
|||
wxBoxSizer* m_sizer; |
|||
wxStaticText* m_lblWelcome; |
|||
wxStaticText* m_staticText2; |
|||
wxRadioButton* m_btnPrevVer; |
|||
wxComboBox* m_cbPath; |
|||
wxBitmapButton* m_btnCustomPath; |
|||
wxStaticText* m_lblPathError; |
|||
wxRadioButton* m_btnUseDefaults; |
|||
wxStdDialogButtonSizer* m_standardButtons; |
|||
wxButton* m_standardButtonsOK; |
|||
wxButton* m_standardButtonsCancel; |
|||
|
|||
// Virtual event handlers, overide them in your derived class |
|||
virtual void OnPrevVerSelected( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnPathChanged( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnPathDefocused( wxFocusEvent& event ) { event.Skip(); } |
|||
virtual void OnChoosePath( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnDefaultSelected( wxCommandEvent& event ) { event.Skip(); } |
|||
|
|||
|
|||
public: |
|||
|
|||
DIALOG_MIGRATE_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Configure KiCad Settings Path"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION ); |
|||
~DIALOG_MIGRATE_SETTINGS_BASE(); |
|||
|
|||
}; |
|||
|
|||
@ -0,0 +1,254 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify it |
|||
* under the terms of the GNU General Public License as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <class_draw_panel_gal.h>
|
|||
#include <common.h>
|
|||
#include <layers_id_colors_and_visibility.h>
|
|||
#include <pgm_base.h>
|
|||
#include <settings/app_settings.h>
|
|||
#include <settings/common_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
|
|||
|
|||
///! Update the schema version whenever a migration is required
|
|||
const int appSettingsSchemaVersion = 0; |
|||
|
|||
|
|||
APP_SETTINGS_BASE::APP_SETTINGS_BASE( std::string aFilename, int aSchemaVersion ) : |
|||
JSON_SETTINGS( std::move( aFilename ), SETTINGS_LOC::USER, appSettingsSchemaVersion ), |
|||
m_Printing(), m_System(), m_Window(), m_appSettingsSchemaVersion( aSchemaVersion ) |
|||
{ |
|||
m_params.emplace_back( new PARAM<int>( "find_replace.flags", &m_FindReplace.flags, 1 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "find_replace.find_string", |
|||
&m_FindReplace.find_string, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.find_history", |
|||
&m_FindReplace.find_history, {} ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "find_replace.replace_string", |
|||
&m_FindReplace.replace_string, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.replace_history", |
|||
&m_FindReplace.replace_history, {} ) ); |
|||
|
|||
#ifdef __WXMAC__
|
|||
// Cairo renderer doesn't handle Retina displays so default to OpenGL
|
|||
m_params.emplace_back( new PARAM<int>( "graphics.canvas_type", &m_Graphics.canvas_type, |
|||
EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ); |
|||
#else
|
|||
m_params.emplace_back( new PARAM<int>( "graphics.canvas_type", &m_Graphics.canvas_type, |
|||
EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ); |
|||
#endif
|
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<int>( "lib_tree.column_width", &m_LibTree.column_width, 360 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "printing.monochrome", &m_Printing.monochrome, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<double>( "printing.scale", &m_Printing.scale, 1.0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "printing.title_block", |
|||
&m_Printing.title_block, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_LIST<int>( "printing.layers", &m_Printing.layers, {} ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "system.first_run_shown", |
|||
&m_System.first_run_shown, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "system.max_undo_items", &m_System.max_undo_items, 0 ) ); |
|||
|
|||
|
|||
m_params.emplace_back( new PARAM_LIST<wxString>( "system.file_history", |
|||
&m_System.file_history, {} ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "system.units", &m_System.units, |
|||
static_cast<int>( EDA_UNITS::MILLIMETRES ) ) ); |
|||
|
|||
addParamsForWindow( &m_Window, "window" ); |
|||
} |
|||
|
|||
|
|||
bool APP_SETTINGS_BASE::MigrateFromLegacy( wxConfigBase* aCfg ) |
|||
{ |
|||
bool ret = true; |
|||
|
|||
const std::string f = getLegacyFrameName(); |
|||
|
|||
ret &= fromLegacyString( aCfg, "LastFindString", "find_replace.find_string" ); |
|||
ret &= fromLegacyString( aCfg, "LastReplaceString", "find_replace.replace_string" ); |
|||
|
|||
migrateFindReplace( aCfg ); |
|||
|
|||
ret &= fromLegacy<int>( aCfg, "canvas_type", "graphics.canvas_type" ); |
|||
|
|||
ret &= fromLegacy<int>( aCfg, "P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth", |
|||
"lib_tree.column_width" ); |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, "PrintMonochrome", "printing.monochrome" ); |
|||
ret &= fromLegacy<double>( aCfg, "PrintScale", "printing.scale" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PrintPageFrame", "printing.title_block" ); |
|||
|
|||
{ |
|||
nlohmann::json js = nlohmann::json::array(); |
|||
wxString key; |
|||
bool val = false; |
|||
|
|||
for( unsigned i = 0; i < PCB_LAYER_ID_COUNT; ++i ) |
|||
{ |
|||
key.Printf( wxT( "PlotLayer_%d" ), i ); |
|||
|
|||
if( aCfg->Read( key, &val ) && val ) |
|||
js.push_back( i ); |
|||
} |
|||
|
|||
( *this )[PointerFromString( "printing.layers" ) ] = js; |
|||
} |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, f + "FirstRunShown", "system.first_run_shown" ); |
|||
ret &= fromLegacy<int>( aCfg, f + "DevelMaxUndoItems", "system.max_undo_items" ); |
|||
ret &= fromLegacy<int>( aCfg, f + "Units", "system.units" ); |
|||
|
|||
{ |
|||
int max_history_size = Pgm().GetCommonSettings()->m_System.file_history_size; |
|||
wxString file, key; |
|||
nlohmann::json js = nlohmann::json::array(); |
|||
|
|||
for( int i = 1; i <= max_history_size; i++ ) |
|||
{ |
|||
key.Printf( "file%d", i ); |
|||
file = aCfg->Read( key, wxEmptyString ); |
|||
|
|||
if( !file.IsEmpty() ) |
|||
js.push_back( file.ToStdString() ); |
|||
} |
|||
|
|||
( *this )[PointerFromString( "system.file_history" )] = js; |
|||
} |
|||
|
|||
ret &= migrateWindowConfig( aCfg, f, "window" ); |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
|
|||
void APP_SETTINGS_BASE::migrateFindReplace( wxConfigBase* aCfg ) |
|||
{ |
|||
const int find_replace_history_size = 10; |
|||
nlohmann::json find_history = nlohmann::json::array(); |
|||
nlohmann::json replace_history = nlohmann::json::array(); |
|||
wxString tmp, find_key, replace_key; |
|||
|
|||
for( int i = 0; i < find_replace_history_size; ++i ) |
|||
{ |
|||
find_key.Printf( "FindStringHistoryList%d", i ); |
|||
replace_key.Printf( "ReplaceStringHistoryList%d", i ); |
|||
|
|||
if( aCfg->Read( find_key, &tmp ) ) |
|||
find_history.push_back( tmp.ToStdString() ); |
|||
|
|||
if( aCfg->Read( replace_key, &tmp ) ) |
|||
replace_history.push_back( tmp.ToStdString() ); |
|||
} |
|||
|
|||
( *this )[PointerFromString( "find_replace.find_history" )] = find_history; |
|||
( *this )[PointerFromString( "find_replace.replace_history" )] = replace_history; |
|||
} |
|||
|
|||
|
|||
bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::string& aFrame, |
|||
const std::string& aJsonPath ) |
|||
{ |
|||
bool ret = true; |
|||
|
|||
const std::string gd = "GalDisplayOptions"; |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, aFrame + "Maximized", aJsonPath + ".maximized" ); |
|||
ret &= fromLegacyString( aCfg, aFrame + "MostRecentlyUsedPath", aJsonPath + ".mru_path" ); |
|||
ret &= fromLegacy<int>( aCfg, aFrame + "Size_x", aJsonPath + ".size_x" ); |
|||
ret &= fromLegacy<int>( aCfg, aFrame + "Size_y", aJsonPath + ".size_y" ); |
|||
ret &= fromLegacyString( aCfg, aFrame + "Perspective", aJsonPath + ".perspective" ); |
|||
ret &= fromLegacy<int>( aCfg, aFrame + "Pos_x", aJsonPath + ".pos_x" ); |
|||
ret &= fromLegacy<int>( aCfg, aFrame + "Pos_y", aJsonPath + ".pos_y" ); |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, |
|||
aFrame + gd + "ForceDisplayCursor", aJsonPath + ".cursor.always_show_cursor" ); |
|||
ret &= fromLegacy<bool>( aCfg, |
|||
aFrame + gd + "CursorFullscreen", aJsonPath + ".cursor.fullscreen_cursor" ); |
|||
|
|||
ret &= fromLegacy<int>( aCfg, |
|||
aFrame + "_LastGridSize", aJsonPath + ".grid.last_size" ); |
|||
ret &= fromLegacy<bool>( aCfg, |
|||
aFrame + gd + "GridAxesEnabled", aJsonPath + ".grid.axes_enabled" ); |
|||
ret &= fromLegacy<double>( aCfg, |
|||
aFrame + gd + "GridLineWidth", aJsonPath + ".grid.line_width" ); |
|||
ret &= fromLegacy<double>( aCfg, |
|||
aFrame + gd + "GridMaxDensity", aJsonPath + ".grid.min_spacing" ); |
|||
ret &= fromLegacy<bool>( aCfg, aFrame + gd + "ShowGrid", aJsonPath + ".grid.show" ); |
|||
ret &= fromLegacy<int>( aCfg, aFrame + gd + "GridStyle", aJsonPath + ".grid.style" ); |
|||
ret &= fromLegacyColor( aCfg, aFrame + gd + "GridColor", aJsonPath + ".grid.color" ); |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, aFrame + "AutoZoom", aJsonPath + ".auto_zoom" ); |
|||
ret &= fromLegacy<double>( aCfg, aFrame + "Zoom", aJsonPath + ".zoom" ); |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
|
|||
void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std::string& aJsonPath ) |
|||
{ |
|||
m_params.emplace_back( |
|||
new PARAM<bool>( aJsonPath + ".maximized", &aWindow->maximized, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".mru_path", &aWindow->mru_path, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_x", &aWindow->size_x, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_y", &aWindow->size_y, 0 ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<wxString>( aJsonPath + ".perspective", &aWindow->perspective, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_x", &aWindow->pos_x, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_y", &aWindow->pos_y, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.axes_enabled", |
|||
&aWindow->grid.axes_enabled, false ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<int>( aJsonPath + ".grid.last_size", &aWindow->grid.last_size, 0 ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<double>( aJsonPath + ".grid.line_width", &aWindow->grid.line_width, 1.0 ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<double>( aJsonPath + ".grid.min_spacing", &aWindow->grid.min_spacing, 10 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.show", &aWindow->grid.show, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style", &aWindow->grid.style, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.always_show_cursor", |
|||
&aWindow->cursor.always_show_cursor, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.fullscreen_cursor", |
|||
&aWindow->cursor.fullscreen_cursor, false ) ); |
|||
} |
|||
@ -0,0 +1,345 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify it |
|||
* under the terms of the GNU General Public License as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <layers_id_colors_and_visibility.h>
|
|||
#include <settings/color_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
|
|||
|
|||
///! Update the schema version whenever a migration is required
|
|||
const int colorsSchemaVersion = 0; |
|||
|
|||
|
|||
COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) : |
|||
JSON_SETTINGS( std::move( aFilename ), SETTINGS_LOC::COLORS, colorsSchemaVersion ), |
|||
m_Palette(), m_colors(), m_color_context( COLOR_CONTEXT::PCB ) |
|||
{ |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "meta.name", &m_displayName, "KiCad Default" ) ); |
|||
|
|||
std::vector<COLOR4D> default_palette = { |
|||
COLOR4D( RED ), |
|||
COLOR4D( YELLOW ), |
|||
COLOR4D( LIGHTMAGENTA ), |
|||
COLOR4D( LIGHTRED ), |
|||
COLOR4D( CYAN ), |
|||
COLOR4D( GREEN ), |
|||
COLOR4D( BLUE ), |
|||
COLOR4D( DARKGRAY ), |
|||
COLOR4D( MAGENTA ), |
|||
COLOR4D( LIGHTGRAY ), |
|||
COLOR4D( MAGENTA ), |
|||
COLOR4D( RED ), |
|||
COLOR4D( BROWN ), |
|||
COLOR4D( LIGHTGRAY ), |
|||
COLOR4D( BLUE ), |
|||
COLOR4D( GREEN ) |
|||
}; |
|||
|
|||
// TODO(JE) in actual usage, how long does the default palette need to be?
|
|||
m_params.emplace_back( new PARAM_LIST<COLOR4D>( "palette", &m_Palette, default_palette ) ); |
|||
|
|||
#define CLR( x, y, z ) m_params.emplace_back( new COLOR_MAP_PARAM( x, y, z, &m_colors ) );
|
|||
|
|||
CLR( "schematic.background", LAYER_SCHEMATIC_BACKGROUND, COLOR4D( WHITE ) ); |
|||
CLR( "schematic.brightened", LAYER_BRIGHTENED, COLOR4D( PUREMAGENTA ) ); |
|||
CLR( "schematic.bus", LAYER_BUS, COLOR4D( BLUE ) ); |
|||
CLR( "schematic.component_body", LAYER_DEVICE_BACKGROUND, COLOR4D( LIGHTYELLOW ) ); |
|||
CLR( "schematic.component_outline", LAYER_DEVICE, COLOR4D( RED ) ); |
|||
CLR( "schematic.cursor", LAYER_SCHEMATIC_CURSOR, COLOR4D( BLACK ) ); |
|||
CLR( "schematic.erc_error", LAYER_ERC_ERR, COLOR4D( RED ).WithAlpha( 0.8 ) ); |
|||
CLR( "schematic.erc_warning", LAYER_ERC_WARN, COLOR4D( GREEN ).WithAlpha( 0.8 ) ); |
|||
CLR( "schematic.fields", LAYER_FIELDS, COLOR4D( MAGENTA ) ); |
|||
CLR( "schematic.grid", LAYER_SCHEMATIC_GRID, COLOR4D( DARKGRAY ) ); |
|||
CLR( "schematic.hidden", LAYER_HIDDEN, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "schematic.junction", LAYER_JUNCTION, COLOR4D( GREEN ) ); |
|||
CLR( "schematic.label_global", LAYER_GLOBLABEL, COLOR4D( RED ) ); |
|||
CLR( "schematic.label_hier", LAYER_HIERLABEL, COLOR4D( BROWN ) ); |
|||
CLR( "schematic.label_local", LAYER_LOCLABEL, COLOR4D( BLACK ) ); |
|||
CLR( "schematic.net_name", LAYER_NETNAM, COLOR4D( DARKGRAY ) ); |
|||
CLR( "schematic.no_connect", LAYER_NOCONNECT, COLOR4D( BLUE ) ); |
|||
CLR( "schematic.note", LAYER_NOTES, COLOR4D( LIGHTBLUE ) ); |
|||
CLR( "schematic.pin", LAYER_PIN, COLOR4D( RED ) ); |
|||
CLR( "schematic.pin_name", LAYER_PINNAM, COLOR4D( CYAN ) ); |
|||
CLR( "schematic.pin_number", LAYER_PINNUM, COLOR4D( RED ) ); |
|||
CLR( "schematic.reference", LAYER_REFERENCEPART, COLOR4D( CYAN ) ); |
|||
// Macs look better with a lighter shadow
|
|||
#ifdef __WXMAC__
|
|||
CLR( "schematic.shadow", LAYER_SELECTION_SHADOWS, COLOR4D( .78, .92, 1.0, 0.8 ) ); |
|||
#else
|
|||
CLR( "schematic.shadow", LAYER_SELECTION_SHADOWS, COLOR4D( .4, .7, 1.0, 0.8 ) ); |
|||
#endif
|
|||
CLR( "schematic.sheet", LAYER_SHEET, COLOR4D( MAGENTA ) ); |
|||
CLR( "schematic.sheet_filename", LAYER_SHEETFILENAME, COLOR4D( BROWN ) ); |
|||
CLR( "schematic.sheet_label", LAYER_SHEETLABEL, COLOR4D( CYAN ) ); |
|||
CLR( "schematic.sheet_name", LAYER_SHEETNAME, COLOR4D( CYAN ) ); |
|||
CLR( "schematic.value", LAYER_VALUEPART, COLOR4D( CYAN ) ); |
|||
CLR( "schematic.wire", LAYER_WIRE, COLOR4D( GREEN ) ); |
|||
CLR( "schematic.worksheet", LAYER_SCHEMATIC_WORKSHEET, COLOR4D( BLACK ) ); |
|||
|
|||
CLR( "gerbview.axes", LAYER_GERBVIEW_AXES, COLOR4D( BLUE ) ); |
|||
CLR( "gerbview.background", LAYER_GERBVIEW_BACKGROUND, COLOR4D( BLACK ) ); |
|||
CLR( "gerbview.dcodes", LAYER_DCODES, COLOR4D( WHITE ) ); |
|||
CLR( "gerbview.grid", LAYER_GERBVIEW_GRID, COLOR4D( MAGENTA ) ); |
|||
CLR( "gerbview.negative_objects", LAYER_NEGATIVE_OBJECTS, COLOR4D( DARKGRAY ) ); |
|||
CLR( "gerbview.worksheet", LAYER_GERBVIEW_WORKSHEET, COLOR4D( BLUE ) ); |
|||
|
|||
// TODO(JE) New default scheme for GerbView
|
|||
for( int i = 0, id = GERBVIEW_LAYER_ID_START; |
|||
id < GERBER_DRAWLAYERS_COUNT + GERBVIEW_LAYER_ID_START; ++i, ++id ) |
|||
{ |
|||
CLR( "gerbview.layers." + std::to_string( i ), id, |
|||
default_palette[ i % default_palette.size() ] ); |
|||
} |
|||
|
|||
CLR( "board.anchor", LAYER_ANCHOR, COLOR4D( BLUE ) ); |
|||
CLR( "board.aux_items", LAYER_AUX_ITEMS, COLOR4D( WHITE ) ); |
|||
CLR( "board.background", LAYER_PCB_BACKGROUND, COLOR4D( BLACK ) ); |
|||
CLR( "board.cursor", LAYER_CURSOR, COLOR4D( WHITE ) ); |
|||
CLR( "board.drc", LAYER_DRC, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.footprint_text_back", LAYER_MOD_TEXT_BK, COLOR4D( BLUE ) ); |
|||
CLR( "board.footprint_text_front", LAYER_MOD_TEXT_FR, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.footprint_text_invisible", LAYER_MOD_TEXT_INVISIBLE, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.grid", LAYER_GRID, COLOR4D( DARKGRAY ) ); |
|||
CLR( "board.grid_axes", LAYER_GRID_AXES, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.microvia", LAYER_VIA_MICROVIA, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.no_connect", LAYER_NO_CONNECTS, COLOR4D( BLUE ) ); |
|||
CLR( "board.pad_back", LAYER_PAD_BK, COLOR4D( GREEN ) ); |
|||
CLR( "board.pad_front", LAYER_PAD_FR, COLOR4D( RED ) ); |
|||
CLR( "board.pad_plated_hole", LAYER_PADS_PLATEDHOLES, COLOR4D( YELLOW ) ); |
|||
CLR( "board.pad_through_hole", LAYER_PADS_TH, COLOR4D( YELLOW ) ); |
|||
CLR( "board.plated_hole", LAYER_NON_PLATEDHOLES, COLOR4D( YELLOW ) ); |
|||
CLR( "board.ratsnest", LAYER_RATSNEST, COLOR4D( WHITE ) ); |
|||
CLR( "board.select_overlay", LAYER_SELECT_OVERLAY, COLOR4D( DARKRED ) ); |
|||
CLR( "board.through_via", LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.via", LAYER_VIAS, COLOR4D( BLACK ) ); |
|||
CLR( "board.via_blind_buried", LAYER_VIA_BBLIND, COLOR4D( BROWN ) ); |
|||
CLR( "board.via_hole", LAYER_VIAS_HOLES, COLOR4D( WHITE ) ); |
|||
CLR( "board.via_micro", LAYER_VIA_MICROVIA, COLOR4D( CYAN ) ); |
|||
CLR( "board.via_through", LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.worksheet", LAYER_WORKSHEET, COLOR4D( DARKRED ) ); |
|||
|
|||
CLR( "board.copper.f", F_Cu, COLOR4D( RED ) ); |
|||
CLR( "board.copper.in1", In1_Cu, COLOR4D( YELLOW ) ); |
|||
CLR( "board.copper.in2", In2_Cu, COLOR4D( LIGHTMAGENTA ) ); |
|||
CLR( "board.copper.in3", In3_Cu, COLOR4D( LIGHTRED ) ); |
|||
CLR( "board.copper.in4", In4_Cu, COLOR4D( CYAN ) ); |
|||
CLR( "board.copper.in5", In5_Cu, COLOR4D( GREEN ) ); |
|||
CLR( "board.copper.in6", In6_Cu, COLOR4D( BLUE ) ); |
|||
CLR( "board.copper.in7", In7_Cu, COLOR4D( DARKGRAY ) ); |
|||
CLR( "board.copper.in8", In8_Cu, COLOR4D( MAGENTA ) ); |
|||
CLR( "board.copper.in9", In9_Cu, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.copper.in10", In10_Cu, COLOR4D( MAGENTA ) ); |
|||
CLR( "board.copper.in11", In11_Cu, COLOR4D( RED ) ); |
|||
CLR( "board.copper.in12", In12_Cu, COLOR4D( BROWN ) ); |
|||
CLR( "board.copper.in13", In13_Cu, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.copper.in14", In14_Cu, COLOR4D( BLUE ) ); |
|||
CLR( "board.copper.in15", In15_Cu, COLOR4D( GREEN ) ); |
|||
CLR( "board.copper.in16", In16_Cu, COLOR4D( RED ) ); |
|||
CLR( "board.copper.in17", In17_Cu, COLOR4D( YELLOW ) ); |
|||
CLR( "board.copper.in18", In18_Cu, COLOR4D( LIGHTMAGENTA ) ); |
|||
CLR( "board.copper.in19", In19_Cu, COLOR4D( LIGHTRED ) ); |
|||
CLR( "board.copper.in20", In20_Cu, COLOR4D( CYAN ) ); |
|||
CLR( "board.copper.in21", In21_Cu, COLOR4D( GREEN ) ); |
|||
CLR( "board.copper.in22", In22_Cu, COLOR4D( BLUE ) ); |
|||
CLR( "board.copper.in23", In23_Cu, COLOR4D( DARKGRAY ) ); |
|||
CLR( "board.copper.in24", In24_Cu, COLOR4D( MAGENTA ) ); |
|||
CLR( "board.copper.in25", In25_Cu, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.copper.in26", In26_Cu, COLOR4D( MAGENTA ) ); |
|||
CLR( "board.copper.in27", In27_Cu, COLOR4D( RED ) ); |
|||
CLR( "board.copper.in28", In28_Cu, COLOR4D( BROWN ) ); |
|||
CLR( "board.copper.in29", In29_Cu, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.copper.in30", In30_Cu, COLOR4D( BLUE ) ); |
|||
CLR( "board.copper.b", B_Cu, COLOR4D( GREEN ) ); |
|||
|
|||
CLR( "board.b_adhes", B_Adhes, COLOR4D( BLUE ) ); |
|||
CLR( "board.f_adhes", F_Adhes, COLOR4D( MAGENTA ) ); |
|||
CLR( "board.b_paste", B_Paste, COLOR4D( LIGHTCYAN ) ); |
|||
CLR( "board.f_paste", F_Paste, COLOR4D( RED ) ); |
|||
CLR( "board.b_silks", B_SilkS, COLOR4D( MAGENTA ) ); |
|||
CLR( "board.f_silks", F_SilkS, COLOR4D( CYAN ) ); |
|||
CLR( "board.b_mask", B_Mask, COLOR4D( BROWN ) ); |
|||
CLR( "board.f_mask", F_Mask, COLOR4D( MAGENTA ) ); |
|||
CLR( "board.dwgs_user", Dwgs_User, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.cmts_user", Cmts_User, COLOR4D( BLUE ) ); |
|||
CLR( "board.eco1_user", Eco1_User, COLOR4D( GREEN ) ); |
|||
CLR( "board.eco2_user", Eco2_User, COLOR4D( YELLOW ) ); |
|||
CLR( "board.edge_cuts", Edge_Cuts, COLOR4D( YELLOW ) ); |
|||
CLR( "board.margin", Margin, COLOR4D( LIGHTMAGENTA ) ); |
|||
CLR( "board.b_crtyd", B_CrtYd, COLOR4D( DARKGRAY ) ); |
|||
CLR( "board.f_crtyd", F_CrtYd, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "board.b_fab", B_Fab, COLOR4D( BLUE ) ); |
|||
CLR( "board.f_fab", F_Fab, COLOR4D( DARKGRAY ) ); |
|||
|
|||
// TODO(JE) Storing fpedit colors here is a temporary hack to preserve user settings.
|
|||
// Ultimately, if a user wants to have different colors for pcbnew and the footprint editor,
|
|||
// they should simply choose a different named color theme for each.
|
|||
// While we only have a single color theme, we need to store two mappings of all the
|
|||
// pcb-related colors, one for pcbnew and one for footprint editor.
|
|||
// Once color themes are supported, we should bump the schema version of COLOR_SETTINGS
|
|||
// and in the migration split out the "User" theme to "User.FpEdit" or something, then set
|
|||
// the User.FpEdit scheme as active for the footprint editor.
|
|||
|
|||
#define FL FPEDIT_LAYER_ID_START
|
|||
|
|||
CLR( "fpedit.anchor", FL + LAYER_ANCHOR, COLOR4D( BLUE ) ); |
|||
CLR( "fpedit.aux_items", FL + LAYER_AUX_ITEMS, COLOR4D( WHITE ) ); |
|||
CLR( "fpedit.background", FL + LAYER_PCB_BACKGROUND, COLOR4D( BLACK ) ); |
|||
CLR( "fpedit.cursor", FL + LAYER_CURSOR, COLOR4D( WHITE ) ); |
|||
CLR( "fpedit.drc", FL + LAYER_DRC, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.footprint_text_back", FL + LAYER_MOD_TEXT_BK, COLOR4D( BLUE ) ); |
|||
CLR( "fpedit.footprint_text_front", FL + LAYER_MOD_TEXT_FR, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.footprint_text_invisible", FL + LAYER_MOD_TEXT_INVISIBLE, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.grid", FL + LAYER_GRID, COLOR4D( DARKGRAY ) ); |
|||
CLR( "fpedit.grid_axes", FL + LAYER_GRID_AXES, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.microvia", FL + LAYER_VIA_MICROVIA, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.no_connect", FL + LAYER_NO_CONNECTS, COLOR4D( BLUE ) ); |
|||
CLR( "fpedit.pad_back", FL + LAYER_PAD_BK, COLOR4D( GREEN ) ); |
|||
CLR( "fpedit.pad_front", FL + LAYER_PAD_FR, COLOR4D( RED ) ); |
|||
CLR( "fpedit.pad_plated_hole", FL + LAYER_PADS_PLATEDHOLES, COLOR4D( YELLOW ) ); |
|||
CLR( "fpedit.pad_through_hole", FL + LAYER_PADS_TH, COLOR4D( YELLOW ) ); |
|||
CLR( "fpedit.plated_hole", FL + LAYER_NON_PLATEDHOLES, COLOR4D( YELLOW ) ); |
|||
CLR( "fpedit.ratsnest", FL + LAYER_RATSNEST, COLOR4D( WHITE ) ); |
|||
CLR( "fpedit.select_overlay", FL + LAYER_SELECT_OVERLAY, COLOR4D( DARKRED ) ); |
|||
CLR( "fpedit.through_via", FL + LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.via", FL + LAYER_VIAS, COLOR4D( BLACK ) ); |
|||
CLR( "fpedit.via_blind_buried", FL + LAYER_VIA_BBLIND, COLOR4D( BROWN ) ); |
|||
CLR( "fpedit.via_hole", FL + LAYER_VIAS_HOLES, COLOR4D( WHITE ) ); |
|||
CLR( "fpedit.via_micro", FL + LAYER_VIA_MICROVIA, COLOR4D( CYAN ) ); |
|||
CLR( "fpedit.via_through", FL + LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.worksheet", FL + LAYER_WORKSHEET, COLOR4D( DARKRED ) ); |
|||
|
|||
CLR( "fpedit.copper.f", FL + F_Cu, COLOR4D( RED ) ); |
|||
CLR( "fpedit.copper.in1", FL + In1_Cu, COLOR4D( YELLOW ) ); |
|||
CLR( "fpedit.copper.in2", FL + In2_Cu, COLOR4D( LIGHTMAGENTA ) ); |
|||
CLR( "fpedit.copper.in3", FL + In3_Cu, COLOR4D( LIGHTRED ) ); |
|||
CLR( "fpedit.copper.in4", FL + In4_Cu, COLOR4D( CYAN ) ); |
|||
CLR( "fpedit.copper.in5", FL + In5_Cu, COLOR4D( GREEN ) ); |
|||
CLR( "fpedit.copper.in6", FL + In6_Cu, COLOR4D( BLUE ) ); |
|||
CLR( "fpedit.copper.in7", FL + In7_Cu, COLOR4D( DARKGRAY ) ); |
|||
CLR( "fpedit.copper.in8", FL + In8_Cu, COLOR4D( MAGENTA ) ); |
|||
CLR( "fpedit.copper.in9", FL + In9_Cu, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.copper.in10", FL + In10_Cu, COLOR4D( MAGENTA ) ); |
|||
CLR( "fpedit.copper.in11", FL + In11_Cu, COLOR4D( RED ) ); |
|||
CLR( "fpedit.copper.in12", FL + In12_Cu, COLOR4D( BROWN ) ); |
|||
CLR( "fpedit.copper.in13", FL + In13_Cu, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.copper.in14", FL + In14_Cu, COLOR4D( BLUE ) ); |
|||
CLR( "fpedit.copper.in15", FL + In15_Cu, COLOR4D( GREEN ) ); |
|||
CLR( "fpedit.copper.in16", FL + In16_Cu, COLOR4D( RED ) ); |
|||
CLR( "fpedit.copper.in17", FL + In17_Cu, COLOR4D( YELLOW ) ); |
|||
CLR( "fpedit.copper.in18", FL + In18_Cu, COLOR4D( LIGHTMAGENTA ) ); |
|||
CLR( "fpedit.copper.in19", FL + In19_Cu, COLOR4D( LIGHTRED ) ); |
|||
CLR( "fpedit.copper.in20", FL + In20_Cu, COLOR4D( CYAN ) ); |
|||
CLR( "fpedit.copper.in21", FL + In21_Cu, COLOR4D( GREEN ) ); |
|||
CLR( "fpedit.copper.in22", FL + In22_Cu, COLOR4D( BLUE ) ); |
|||
CLR( "fpedit.copper.in23", FL + In23_Cu, COLOR4D( DARKGRAY ) ); |
|||
CLR( "fpedit.copper.in24", FL + In24_Cu, COLOR4D( MAGENTA ) ); |
|||
CLR( "fpedit.copper.in25", FL + In25_Cu, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.copper.in26", FL + In26_Cu, COLOR4D( MAGENTA ) ); |
|||
CLR( "fpedit.copper.in27", FL + In27_Cu, COLOR4D( RED ) ); |
|||
CLR( "fpedit.copper.in28", FL + In28_Cu, COLOR4D( BROWN ) ); |
|||
CLR( "fpedit.copper.in29", FL + In29_Cu, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.copper.in30", FL + In30_Cu, COLOR4D( BLUE ) ); |
|||
CLR( "fpedit.copper.b", FL + B_Cu, COLOR4D( GREEN ) ); |
|||
|
|||
CLR( "fpedit.b_adhes", FL + B_Adhes, COLOR4D( BLUE ) ); |
|||
CLR( "fpedit.f_adhes", FL + F_Adhes, COLOR4D( MAGENTA ) ); |
|||
CLR( "fpedit.b_paste", FL + B_Paste, COLOR4D( LIGHTCYAN ) ); |
|||
CLR( "fpedit.f_paste", FL + F_Paste, COLOR4D( RED ) ); |
|||
CLR( "fpedit.b_silks", FL + B_SilkS, COLOR4D( MAGENTA ) ); |
|||
CLR( "fpedit.f_silks", FL + F_SilkS, COLOR4D( CYAN ) ); |
|||
CLR( "fpedit.b_mask", FL + B_Mask, COLOR4D( BROWN ) ); |
|||
CLR( "fpedit.f_mask", FL + F_Mask, COLOR4D( MAGENTA ) ); |
|||
CLR( "fpedit.dwgs_user", FL + Dwgs_User, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.cmts_user", FL + Cmts_User, COLOR4D( BLUE ) ); |
|||
CLR( "fpedit.eco1_user", FL + Eco1_User, COLOR4D( GREEN ) ); |
|||
CLR( "fpedit.eco2_user", FL + Eco2_User, COLOR4D( YELLOW ) ); |
|||
CLR( "fpedit.edge_cuts", FL + Edge_Cuts, COLOR4D( YELLOW ) ); |
|||
CLR( "fpedit.margin", FL + Margin, COLOR4D( LIGHTMAGENTA ) ); |
|||
CLR( "fpedit.b_crtyd", FL + B_CrtYd, COLOR4D( DARKGRAY ) ); |
|||
CLR( "fpedit.f_crtyd", FL + F_CrtYd, COLOR4D( LIGHTGRAY ) ); |
|||
CLR( "fpedit.b_fab", FL + B_Fab, COLOR4D( BLUE ) ); |
|||
CLR( "fpedit.f_fab", FL + F_Fab, COLOR4D( DARKGRAY ) ); |
|||
|
|||
// Colors for 3D viewer, which are used as defaults unless overridden by the board
|
|||
CLR( "3d_viewer.background_bottom", LAYER_3D_BACKGROUND_BOTTOM, COLOR4D( 0.4, 0.4, 0.5, 1.0 ) ); |
|||
CLR( "3d_viewer.background_top", LAYER_3D_BACKGROUND_TOP, COLOR4D( 0.8, 0.8, 0.9, 1.0 ) ); |
|||
CLR( "3d_viewer.board", LAYER_3D_BOARD, COLOR4D( 0.2, 0.17, 0.09, 1.0 ) ); |
|||
CLR( "3d_viewer.copper", LAYER_3D_COPPER, COLOR4D( 0.7, 0.61, 0.0, 1.0 ) ); |
|||
CLR( "3d_viewer.silkscreen_bottom", LAYER_3D_SILKSCREEN_BOTTOM, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) ); |
|||
CLR( "3d_viewer.silkscreen_top", LAYER_3D_SILKSCREEN_TOP, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) ); |
|||
CLR( "3d_viewer.soldermask", LAYER_3D_SOLDERMASK, COLOR4D( 0.08, 0.2, 0.14, 1.0 ) ); |
|||
CLR( "3d_viewer.solderpaste", LAYER_3D_SOLDERPASTE, COLOR4D( 0.5, 0.5, 0.5, 1.0 ) ); |
|||
} |
|||
|
|||
|
|||
bool COLOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
|
|||
COLOR4D COLOR_SETTINGS::GetColor( int aLayer ) const |
|||
{ |
|||
try |
|||
{ |
|||
if( m_color_context == COLOR_CONTEXT::FOOTPRINT && aLayer >= PCBNEW_LAYER_ID_START |
|||
&& aLayer <= GAL_LAYER_ID_END ) |
|||
aLayer += FPEDIT_LAYER_ID_START; |
|||
|
|||
return m_colors.at( aLayer ); |
|||
} |
|||
catch( std::out_of_range& ) |
|||
{ |
|||
return COLOR4D::UNSPECIFIED; |
|||
} |
|||
} |
|||
|
|||
|
|||
COLOR4D COLOR_SETTINGS::GetDefaultColor( int aLayer ) |
|||
{ |
|||
if( !m_defaultColors.count( aLayer ) ) |
|||
{ |
|||
if( m_color_context == COLOR_CONTEXT::FOOTPRINT && aLayer >= PCBNEW_LAYER_ID_START |
|||
&& aLayer <= GAL_LAYER_ID_END ) |
|||
aLayer += FPEDIT_LAYER_ID_START; |
|||
|
|||
COLOR_MAP_PARAM* p = nullptr; |
|||
|
|||
for( auto param : m_params ) |
|||
if( auto cmp = dynamic_cast<COLOR_MAP_PARAM*>( param ) ) |
|||
if( cmp->GetKey() == aLayer ) |
|||
p = cmp; |
|||
|
|||
wxASSERT( p ); |
|||
m_defaultColors[aLayer] = p->GetDefault(); |
|||
} |
|||
|
|||
return m_defaultColors.at( aLayer );; |
|||
} |
|||
|
|||
|
|||
void COLOR_SETTINGS::SetColor( int aLayer, COLOR4D aColor ) |
|||
{ |
|||
if( m_color_context == COLOR_CONTEXT::FOOTPRINT ) |
|||
aLayer += FPEDIT_LAYER_ID_START; |
|||
|
|||
m_colors[ aLayer ] = aColor; |
|||
} |
|||
@ -0,0 +1,169 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify it |
|||
* under the terms of the GNU General Public License as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <settings/common_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
#include <wx/config.h>
|
|||
#include <wx/log.h>
|
|||
|
|||
|
|||
extern const char* traceSettings; |
|||
|
|||
|
|||
///! Update the schema version whenever a migration is required
|
|||
const int commonSchemaVersion = 0; |
|||
|
|||
COMMON_SETTINGS::COMMON_SETTINGS() : |
|||
JSON_SETTINGS( "kicad_common", SETTINGS_LOC::USER, commonSchemaVersion ), |
|||
m_Appearance(), m_Env(), m_Input(), m_Graphics(), m_System() |
|||
{ |
|||
// This only effect the first time KiCad is run. The user's setting will be used for all
|
|||
// subsequent runs. Menu icons are off by default on OSX and on for all other platforms.
|
|||
#if defined( __WXMAC__ )
|
|||
bool defaultUseIconsInMenus = false; |
|||
#else
|
|||
bool defaultUseIconsInMenus = true; |
|||
#endif
|
|||
|
|||
m_params.emplace_back( new PARAM<double>( "appearance.canvas_scale", |
|||
&m_Appearance.canvas_scale, 1.0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "appearance.icon_scale", |
|||
&m_Appearance.icon_scale, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "appearance.use_icons_in_menus", |
|||
&m_Appearance.use_icons_in_menus, defaultUseIconsInMenus ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "environment.show_warning_dialog", |
|||
&m_Env.show_warning_dialog, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_MAP<wxString>( "environment.vars", &m_Env.vars, {} ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "input.auto_pan", &m_Input.auto_pan, false ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "input.center_on_zoom", &m_Input.center_on_zoom, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "input.immediate_actions", |
|||
&m_Input.immediate_actions, true ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "input.mousewheel_pan", &m_Input.mousewheel_pan, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "input.prefer_select_to_drag", |
|||
&m_Input.prefer_select_to_drag, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "input.warp_mouse_on_move", |
|||
&m_Input.warp_mouse_on_move, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "graphics.opengl_antialiasing_mode", |
|||
&m_Graphics.opengl_aa_mode, 0, 0, 4 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "graphics.cairo_antialiasing_mode", |
|||
&m_Graphics.cairo_aa_mode, 0, 0, 3 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "system.autosave_interval", |
|||
&m_System.autosave_interval, 600 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "system.editor_name", |
|||
&m_System.editor_name, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "system.file_history_size", |
|||
&m_System.file_history_size, 9 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "system.language", |
|||
&m_System.language, "Default" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "system.pdf_viewer_name", |
|||
&m_System.pdf_viewer_name, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "system.use_system_pdf_viewer", |
|||
&m_System.use_system_pdf_viewer, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "system.working_dir", |
|||
&m_System.working_dir, "" ) ); |
|||
} |
|||
|
|||
|
|||
bool COMMON_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) |
|||
{ |
|||
bool ret = true; |
|||
|
|||
ret &= fromLegacy<double>( aCfg, "CanvasScale", "appearance.canvas_scale" ); |
|||
ret &= fromLegacy<int>( aCfg, "IconScale", "appearance.icon_scale" ); |
|||
ret &= fromLegacy<bool>( aCfg, "UseIconsInMenus", "appearance.use_icons_in_menus" ); |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, "ShowEnvVarWarningDialog", "environment.show_warning_dialog" ); |
|||
|
|||
auto load_env_vars = [&] () { |
|||
wxString key, value; |
|||
long index = 0; |
|||
nlohmann::json::json_pointer ptr = PointerFromString( "environment.vars" ); |
|||
|
|||
aCfg->SetPath( "EnvironmentVariables" ); |
|||
( *this )[ptr] = nlohmann::json( {} ); |
|||
|
|||
while( aCfg->GetNextEntry( key, index ) ) |
|||
{ |
|||
value = aCfg->Read( key, wxEmptyString ); |
|||
|
|||
if( !value.IsEmpty() ) |
|||
{ |
|||
ptr.push_back( key.ToStdString() ); |
|||
|
|||
wxLogTrace( traceSettings, "Migrate Env: %s=%s", ptr.to_string(), value ); |
|||
( *this )[ptr] = value.ToUTF8(); |
|||
|
|||
ptr.pop_back(); |
|||
} |
|||
} |
|||
|
|||
aCfg->SetPath( ".." ); |
|||
}; |
|||
|
|||
load_env_vars(); |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, "AutoPAN", "input.auto_pan" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ImmediateActions", "input.immediate_actions" ); |
|||
ret &= fromLegacy<bool>( aCfg, "MousewheelPAN", "input.mousewheel_pan" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PreferSelectionToDragging", "input.prefer_select_to_drag" ); |
|||
ret &= fromLegacy<bool>( aCfg, "MoveWarpsCursor", "input.warp_mouse_on_move" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ZoomNoCenter", "input.center_on_zoom" ); |
|||
|
|||
// This was stored inverted in legacy config
|
|||
if( ret ) |
|||
{ |
|||
auto p = PointerFromString( "input.center_on_zoom" ); |
|||
( *this )[p] = !( *this )[p]; |
|||
} |
|||
|
|||
ret &= fromLegacy<int>( aCfg, "OpenGLAntialiasingMode", "graphics.opengl_antialiasing_mode" ); |
|||
ret &= fromLegacy<int>( aCfg, "CairoAntialiasingMode", "graphics.cairo_antialiasing_mode" ); |
|||
|
|||
ret &= fromLegacy<int>( aCfg, "AutoSaveInterval", "system.autosave_interval" ); |
|||
ret &= fromLegacyString( aCfg, "Editor", "system.editor_name" ); |
|||
ret &= fromLegacy<int>( aCfg, "FileHistorySize", "system.file_history_size" ); |
|||
ret &= fromLegacyString( aCfg, "LanguageID", "system.language" ); |
|||
ret &= fromLegacyString( aCfg, "PdfBrowserName", "system.pdf_viewer_name" ); |
|||
ret &= fromLegacy<bool>( aCfg, "UseSystemBrowser", "system.use_system_pdf_viewer" ); |
|||
ret &= fromLegacyString( aCfg, "WorkingDir", "system.working_dir" ); |
|||
|
|||
return ret; |
|||
} |
|||
@ -0,0 +1,412 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify it |
|||
* under the terms of the GNU General Public License as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <boost/algorithm/string.hpp>
|
|||
#include <boost/algorithm/string/replace.hpp>
|
|||
#include <fstream>
|
|||
#include <iomanip>
|
|||
#include <utility>
|
|||
|
|||
#include <common.h>
|
|||
#include <gal/color4d.h>
|
|||
#include <settings/json_settings.h>
|
|||
#include <settings/nested_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
#include <wx/config.h>
|
|||
#include <wx/debug.h>
|
|||
#include <wx/filename.h>
|
|||
|
|||
extern const char* traceSettings; |
|||
|
|||
|
|||
JSON_SETTINGS::JSON_SETTINGS( const std::string& aFilename, SETTINGS_LOC aLocation, |
|||
int aSchemaVersion, bool aCreateIfMissing, bool aWriteFile, |
|||
nlohmann::json aDefault ) : |
|||
nlohmann::json( std::move( aDefault ) ), m_filename( aFilename ), m_legacy_filename( "" ), |
|||
m_location( aLocation ), m_createIfMissing( aCreateIfMissing ), m_writeFile( aWriteFile ), |
|||
m_schemaVersion( aSchemaVersion ) |
|||
{ |
|||
m_params.emplace_back( |
|||
new PARAM<std::string>( "meta.filename", &m_filename, m_filename, true ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<int>( "meta.version", &m_schemaVersion, m_schemaVersion, true ) ); |
|||
} |
|||
|
|||
|
|||
JSON_SETTINGS::~JSON_SETTINGS() |
|||
{ |
|||
for( auto param: m_params ) |
|||
delete param; |
|||
|
|||
m_params.clear(); |
|||
} |
|||
|
|||
|
|||
void JSON_SETTINGS::Load() |
|||
{ |
|||
for( auto param : m_params ) |
|||
param->Load( this ); |
|||
} |
|||
|
|||
|
|||
void JSON_SETTINGS::LoadFromFile( const std::string& aDirectory ) |
|||
{ |
|||
// First, load all params to default values
|
|||
clear(); |
|||
Load(); |
|||
|
|||
bool migrated = false; |
|||
LOCALE_IO locale; |
|||
|
|||
auto migrateFromLegacy = [&] ( wxFileName& aPath ) { |
|||
wxConfigBase::DontCreateOnDemand(); |
|||
auto cfg = std::make_unique<wxFileConfig>( wxT( "" ), wxT( "" ), aPath.GetFullPath() ); |
|||
|
|||
// If migrate fails or is not implemented, fall back to built-in defaults that were
|
|||
// already loaded above
|
|||
if( !MigrateFromLegacy( cfg.get() ) ) |
|||
{ |
|||
wxLogTrace( traceSettings, |
|||
"%s: migrated; not all settings were found in legacy file", m_filename ); |
|||
} |
|||
else |
|||
{ |
|||
wxLogTrace( traceSettings, "%s: migrated from legacy format", m_filename ); |
|||
} |
|||
|
|||
// Either way, we want to clean up the old file afterwards
|
|||
migrated = true; |
|||
}; |
|||
|
|||
wxFileName path( aDirectory, m_filename, "json" ); |
|||
|
|||
if( !path.Exists() ) |
|||
{ |
|||
// Case 1: legacy migration, no .json extension yet
|
|||
path.ClearExt(); |
|||
|
|||
if( path.Exists() ) |
|||
{ |
|||
migrateFromLegacy( path ); |
|||
} |
|||
// Case 2: legacy filename is different from new one
|
|||
else if( !m_legacy_filename.empty() ) |
|||
{ |
|||
path.SetName( m_legacy_filename ); |
|||
|
|||
if( path.Exists() ) |
|||
migrateFromLegacy( path ); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
try |
|||
{ |
|||
std::ifstream in( path.GetFullPath().ToStdString() ); |
|||
in >> *this; |
|||
|
|||
// If parse succeeds, check if schema migration is required
|
|||
try |
|||
{ |
|||
int filever = at( PointerFromString( "meta.version" ) ).get<int>(); |
|||
|
|||
if( filever < m_schemaVersion ) |
|||
{ |
|||
wxLogTrace( traceSettings, "%s: attempting migration from version %d to %d", |
|||
m_filename, filever, m_schemaVersion ); |
|||
|
|||
if( !Migrate() ) |
|||
{ |
|||
wxLogTrace( traceSettings, "%s: migration failed!", m_filename ); |
|||
} |
|||
} |
|||
else if( filever > m_schemaVersion ) |
|||
{ |
|||
wxLogTrace( traceSettings, |
|||
"%s: warning: file version %d is newer than latest (%d)", m_filename, |
|||
filever, m_schemaVersion ); |
|||
} |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
wxLogTrace( traceSettings, "%s: file version could not be read!", m_filename ); |
|||
} |
|||
} |
|||
catch( nlohmann::json::parse_error& error ) |
|||
{ |
|||
wxLogTrace( |
|||
traceSettings, "Parse error reading %s: %s", path.GetFullPath(), error.what() ); |
|||
wxLogTrace( traceSettings, "Attempting migration in case file is in legacy format" ); |
|||
migrateFromLegacy( path ); |
|||
} |
|||
} |
|||
|
|||
// Now that we have new data in the JSON structure, load the params again
|
|||
Load(); |
|||
|
|||
// And finally load any nested settings
|
|||
for( auto settings : m_nested_settings ) |
|||
settings->LoadFromFile(); |
|||
|
|||
wxLogTrace( traceSettings, "Loaded %s with schema %d", GetFilename(), m_schemaVersion ); |
|||
|
|||
// If we migrated, clean up the legacy file (with no extension)
|
|||
if( migrated ) |
|||
{ |
|||
if( !wxRemoveFile( path.GetFullPath() ) ) |
|||
{ |
|||
wxLogTrace( |
|||
traceSettings, "Warning: could not remove legacy file %s", path.GetFullPath() ); |
|||
} |
|||
|
|||
// And write-out immediately so that we don't lose data if the program later crashes.
|
|||
SaveToFile( aDirectory ); |
|||
} |
|||
} |
|||
|
|||
|
|||
void JSON_SETTINGS::Store() |
|||
{ |
|||
for( auto param : m_params ) |
|||
param->Store( this ); |
|||
} |
|||
|
|||
|
|||
void JSON_SETTINGS::ResetToDefaults() |
|||
{ |
|||
for( auto param : m_params ) |
|||
param->SetDefault(); |
|||
} |
|||
|
|||
|
|||
void JSON_SETTINGS::SaveToFile( const std::string& aDirectory ) |
|||
{ |
|||
if( !m_writeFile ) |
|||
return; |
|||
|
|||
wxLogTrace( traceSettings, "Saving %s", m_filename ); |
|||
|
|||
wxFileName path( aDirectory, m_filename, "json" ); |
|||
|
|||
if( !m_createIfMissing && !path.FileExists() ) |
|||
return; |
|||
|
|||
if( !path.DirExists() && !path.Mkdir() ) |
|||
{ |
|||
wxLogTrace( traceSettings, "Warning: could not create path %s, can't save %s", |
|||
path.GetPath(), m_filename ); |
|||
return; |
|||
} |
|||
|
|||
for( auto settings : m_nested_settings ) |
|||
settings->SaveToFile(); |
|||
|
|||
Store(); |
|||
|
|||
LOCALE_IO dummy; |
|||
|
|||
try |
|||
{ |
|||
std::ofstream file( path.GetFullPath().ToStdString() ); |
|||
file << std::setw( 2 ) << *this << std::endl; |
|||
} |
|||
catch( const std::exception& e ) |
|||
{ |
|||
wxLogTrace( traceSettings, "Warning: could not save %s: %s", m_filename, e.what() ); |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
|
|||
nlohmann::json JSON_SETTINGS::GetJson( std::string aPath ) const |
|||
{ |
|||
nlohmann::json ret( {} ); |
|||
|
|||
// Will throw an exception if the path is not found
|
|||
try |
|||
{ |
|||
ret = this->at( PointerFromString( std::move( aPath ) ) ); |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
} |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
|
|||
bool JSON_SETTINGS::Migrate() |
|||
{ |
|||
wxLogTrace( traceSettings, "Migrate() not implemented for %s", typeid( *this ).name() ); |
|||
return false; |
|||
} |
|||
|
|||
|
|||
bool JSON_SETTINGS::MigrateFromLegacy( wxConfigBase* aLegacyConfig ) |
|||
{ |
|||
wxLogTrace( traceSettings, |
|||
"MigrateFromLegacy() not implemented for %s", typeid( *this ).name() ); |
|||
return false; |
|||
} |
|||
|
|||
|
|||
nlohmann::json::json_pointer JSON_SETTINGS::PointerFromString( std::string aPath ) |
|||
{ |
|||
boost::replace_all( aPath, ".", "/" ); |
|||
aPath.insert( 0, "/" ); |
|||
|
|||
nlohmann::json::json_pointer p; |
|||
|
|||
try |
|||
{ |
|||
p = nlohmann::json::json_pointer( aPath ); |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
wxASSERT_MSG( false, wxT( "Invalid pointer path in PointerFromString!" ) ); |
|||
} |
|||
|
|||
return p; |
|||
} |
|||
|
|||
|
|||
template<typename ValueType> |
|||
bool JSON_SETTINGS::fromLegacy( wxConfigBase* aConfig, const std::string& aKey, |
|||
const std::string& aDest ) |
|||
{ |
|||
ValueType val; |
|||
|
|||
if( aConfig->Read( aKey, &val ) ) |
|||
{ |
|||
try |
|||
{ |
|||
( *this )[PointerFromString( aDest )] = val; |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
wxASSERT_MSG( false, wxT( "Could not write value in fromLegacy!" ) ); |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
|
|||
// Explicitly declare these because we only support a few types anyway, and it means we can keep
|
|||
// wxConfig detail out of the header file
|
|||
template bool JSON_SETTINGS::fromLegacy<int>( wxConfigBase*, const std::string&, |
|||
const std::string& ); |
|||
|
|||
template bool JSON_SETTINGS::fromLegacy<double>( wxConfigBase*, const std::string&, |
|||
const std::string& ); |
|||
|
|||
template bool JSON_SETTINGS::fromLegacy<bool>( wxConfigBase*, const std::string&, |
|||
const std::string& ); |
|||
|
|||
|
|||
bool JSON_SETTINGS::fromLegacyString( wxConfigBase* aConfig, const std::string& aKey, |
|||
const std::string& aDest ) |
|||
{ |
|||
wxString str; |
|||
|
|||
if( aConfig->Read( aKey, &str ) ) |
|||
{ |
|||
try |
|||
{ |
|||
( *this )[PointerFromString( aDest )] = str.ToUTF8(); |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
wxASSERT_MSG( false, wxT( "Could not write value in fromLegacyString!" ) ); |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
|
|||
bool JSON_SETTINGS::fromLegacyColor( wxConfigBase* aConfig, const std::string& aKey, |
|||
const std::string& aDest ) |
|||
{ |
|||
wxString str; |
|||
|
|||
if( aConfig->Read( aKey, &str ) ) |
|||
{ |
|||
KIGFX::COLOR4D color; |
|||
color.SetFromWxString( str ); |
|||
|
|||
try |
|||
{ |
|||
nlohmann::json js = nlohmann::json::array( { color.r, color.g, color.b, color.a } ); |
|||
( *this )[PointerFromString( aDest )] = js; |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
wxASSERT_MSG( false, wxT( "Could not write value in fromLegacyColor!" ) ); |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
|
|||
void JSON_SETTINGS::AddNestedSettings( NESTED_SETTINGS* aSettings ) |
|||
{ |
|||
m_nested_settings.push_back( aSettings ); |
|||
} |
|||
|
|||
|
|||
// Specializations to allow conversion between wxString and std::string via JSON_SETTINGS API
|
|||
|
|||
template<> wxString JSON_SETTINGS::Get( std::string aPath ) const |
|||
{ |
|||
return wxString( GetJson( std::move( aPath ) ).get<std::string>().c_str(), wxConvUTF8 ); |
|||
} |
|||
|
|||
|
|||
template<> void JSON_SETTINGS::Set<wxString>( std::string aPath, wxString aVal ) |
|||
{ |
|||
( *this )[PointerFromString( std::move( aPath ) ) ] = aVal.ToUTF8(); |
|||
} |
|||
|
|||
// Specializations to allow directly reading/writing wxStrings from JSON
|
|||
|
|||
void to_json( nlohmann::json& aJson, const wxString& aString ) |
|||
{ |
|||
aJson = aString.ToUTF8(); |
|||
} |
|||
|
|||
|
|||
void from_json( const nlohmann::json& aJson, wxString& aString ) |
|||
{ |
|||
aString = wxString( aJson.get<std::string>().c_str(), wxConvUTF8 ); |
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify it |
|||
* under the terms of the GNU General Public License as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <wx/log.h>
|
|||
|
|||
#include <settings/nested_settings.h>
|
|||
|
|||
extern const char* traceSettings; |
|||
|
|||
|
|||
NESTED_SETTINGS::NESTED_SETTINGS( const std::string& aName, int aVersion, JSON_SETTINGS* aParent, |
|||
const std::string& aPath, nlohmann::json aDefault ) : |
|||
JSON_SETTINGS( aName, SETTINGS_LOC::NESTED, aVersion, std::move( aDefault ) ), |
|||
m_parent( aParent ), m_path( aPath ) |
|||
{ |
|||
wxASSERT( m_parent ); |
|||
m_parent->AddNestedSettings( this ); |
|||
|
|||
// In case we were created after the parent's ctor
|
|||
LoadFromFile(); |
|||
} |
|||
|
|||
|
|||
void NESTED_SETTINGS::LoadFromFile( const std::string& aDirectory ) |
|||
{ |
|||
clear(); |
|||
|
|||
try |
|||
{ |
|||
update( ( *m_parent )[PointerFromString( m_path ) ] ); |
|||
|
|||
wxLogTrace( traceSettings, "Loaded NESTED_SETTINGS %s with schema %d", |
|||
GetFilename(), m_schemaVersion ); |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
wxLogTrace( traceSettings, "NESTED_SETTINGS %s: Could not load from %s at %s", |
|||
m_filename, m_parent->GetFilename(), m_path ); |
|||
} |
|||
|
|||
Load(); |
|||
} |
|||
|
|||
|
|||
void NESTED_SETTINGS::SaveToFile( const std::string& aDirectory ) |
|||
{ |
|||
Store(); |
|||
|
|||
try |
|||
{ |
|||
( *m_parent )[PointerFromString( m_path ) ].update( *this ); |
|||
|
|||
wxLogTrace( traceSettings, "Stored NESTED_SETTINGS %s with schema %d", |
|||
GetFilename(), m_schemaVersion ); |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
wxLogTrace( traceSettings, "NESTED_SETTINGS %s: Could not store to %s at %s", |
|||
m_filename, m_parent->GetFilename(), m_path ); |
|||
} |
|||
} |
|||
@ -0,0 +1,545 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify it |
|||
* under the terms of the GNU General Public License as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <regex>
|
|||
#include <wx/debug.h>
|
|||
#include <wx/filename.h>
|
|||
#include <wx/stdpaths.h>
|
|||
#include <wx/utils.h>
|
|||
|
|||
#include <build_version.h>
|
|||
#include <confirm.h>
|
|||
#include <dialogs/dialog_migrate_settings.h>
|
|||
#include <gestfich.h>
|
|||
#include <macros.h>
|
|||
#include <settings/app_settings.h>
|
|||
#include <settings/common_settings.h>
|
|||
#include <settings/settings_manager.h>
|
|||
#include <settings/color_settings.h>
|
|||
|
|||
|
|||
/**
|
|||
* Flag to enable settings tracing |
|||
* @ingroup trace_env_vars |
|||
*/ |
|||
const char* traceSettings = "SETTINGS"; |
|||
|
|||
|
|||
SETTINGS_MANAGER::SETTINGS_MANAGER() : |
|||
m_common_settings( nullptr ), m_migration_source() |
|||
{ |
|||
// Check if the settings directory already exists, and if not, perform a migration if possible
|
|||
if( !MigrateIfNeeded() ) |
|||
{ |
|||
m_ok = false; |
|||
return; |
|||
} |
|||
|
|||
m_ok = true; |
|||
|
|||
// create the common settings shared by all applications. Not loaded immediately
|
|||
m_common_settings = |
|||
static_cast<COMMON_SETTINGS*>( RegisterSettings( new COMMON_SETTINGS, false ) ); |
|||
|
|||
// create the default color settings
|
|||
m_color_settings["default"] = |
|||
static_cast<COLOR_SETTINGS*>( RegisterSettings( new COLOR_SETTINGS ) ); |
|||
} |
|||
|
|||
SETTINGS_MANAGER::~SETTINGS_MANAGER() |
|||
{ |
|||
m_settings.clear(); |
|||
m_color_settings.clear(); |
|||
} |
|||
|
|||
|
|||
JSON_SETTINGS* SETTINGS_MANAGER::RegisterSettings( JSON_SETTINGS* aSettings, bool aLoadNow ) |
|||
{ |
|||
std::unique_ptr<JSON_SETTINGS> ptr( aSettings ); |
|||
|
|||
wxLogTrace( traceSettings, "Registered new settings object %s", ptr->GetFilename() ); |
|||
|
|||
if( aLoadNow ) |
|||
ptr->LoadFromFile( GetPathForSettingsFile( ptr.get() ) ); |
|||
|
|||
m_settings.push_back( std::move( ptr ) ); |
|||
return m_settings.back().get(); |
|||
} |
|||
|
|||
|
|||
void SETTINGS_MANAGER::Load() |
|||
{ |
|||
// TODO(JE) We should check for dirty settings here and write them if so, because
|
|||
// Load() could be called late in the application lifecycle
|
|||
|
|||
for( auto&& settings : m_settings ) |
|||
settings->LoadFromFile( GetPathForSettingsFile( settings.get() ) ); |
|||
} |
|||
|
|||
|
|||
void SETTINGS_MANAGER::Load( JSON_SETTINGS* aSettings ) |
|||
{ |
|||
auto it = std::find_if( m_settings.begin(), m_settings.end(), |
|||
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr ) { |
|||
return aPtr.get() == aSettings; |
|||
} ); |
|||
|
|||
if( it != m_settings.end() ) |
|||
( *it )->LoadFromFile( GetPathForSettingsFile( it->get() ) ); |
|||
} |
|||
|
|||
|
|||
void SETTINGS_MANAGER::Save() |
|||
{ |
|||
for( auto&& settings : m_settings ) |
|||
{ |
|||
// Never automatically save color settings, caller should use SaveColorSettings
|
|||
if( dynamic_cast<COLOR_SETTINGS*>( settings.get() ) ) |
|||
continue; |
|||
|
|||
settings->SaveToFile( GetPathForSettingsFile( settings.get() ) ); |
|||
} |
|||
} |
|||
|
|||
|
|||
void SETTINGS_MANAGER::Save( JSON_SETTINGS* aSettings ) |
|||
{ |
|||
auto it = std::find_if( m_settings.begin(), m_settings.end(), |
|||
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr ) { |
|||
return aPtr.get() == aSettings; |
|||
} ); |
|||
|
|||
if( it != m_settings.end() ) |
|||
{ |
|||
wxLogTrace( traceSettings, "Saving %s", ( *it )->GetFilename() ); |
|||
( *it )->SaveToFile( GetPathForSettingsFile( it->get() ) ); |
|||
} |
|||
} |
|||
|
|||
|
|||
void SETTINGS_MANAGER::FlushAndRelease( JSON_SETTINGS* aSettings ) |
|||
{ |
|||
auto it = std::find_if( m_settings.begin(), m_settings.end(), |
|||
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr ) { |
|||
return aPtr.get() == aSettings; |
|||
} ); |
|||
|
|||
if( it != m_settings.end() ) |
|||
{ |
|||
wxLogTrace( traceSettings, "Flush and release %s", ( *it )->GetFilename() ); |
|||
( *it )->SaveToFile( GetPathForSettingsFile( it->get() ) ); |
|||
m_settings.erase( it ); |
|||
} |
|||
} |
|||
|
|||
|
|||
COLOR_SETTINGS* SETTINGS_MANAGER::GetColorSettings( std::string aName ) |
|||
{ |
|||
COLOR_SETTINGS* ret = nullptr; |
|||
|
|||
try |
|||
{ |
|||
ret = m_color_settings.at( aName ); |
|||
} |
|||
catch( std::out_of_range& ) |
|||
{ |
|||
// This had better work
|
|||
ret = m_color_settings.at( "default" ); |
|||
} |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
|
|||
void SETTINGS_MANAGER::SaveColorSettings( COLOR_SETTINGS* aSettings, const std::string& aNamespace ) |
|||
{ |
|||
// The passed settings should already be managed
|
|||
wxASSERT( std::find_if( m_color_settings.begin(), m_color_settings.end(), |
|||
[aSettings] ( const auto& el ) { |
|||
return el.second == aSettings; |
|||
} ) != m_color_settings.end() ); |
|||
|
|||
nlohmann::json::json_pointer ptr = JSON_SETTINGS::PointerFromString( aNamespace ); |
|||
|
|||
aSettings->Store(); |
|||
|
|||
wxASSERT( aSettings->contains( ptr ) ); |
|||
|
|||
wxLogTrace( traceSettings, "Saving color scheme %s, preserving &s", |
|||
aSettings->GetFilename(), aNamespace ); |
|||
|
|||
nlohmann::json backup = aSettings->at( ptr ); |
|||
std::string path = GetColorSettingsPath(); |
|||
|
|||
aSettings->LoadFromFile( path ); |
|||
|
|||
( *aSettings )[ptr].update( backup ); |
|||
aSettings->Load(); |
|||
|
|||
aSettings->SaveToFile( path ); |
|||
} |
|||
|
|||
|
|||
std::string SETTINGS_MANAGER::GetPathForSettingsFile( JSON_SETTINGS* aSettings ) |
|||
{ |
|||
wxASSERT( aSettings ); |
|||
|
|||
switch( aSettings->GetLocation() ) |
|||
{ |
|||
case SETTINGS_LOC::USER: |
|||
return GetUserSettingsPath(); |
|||
|
|||
case SETTINGS_LOC::PROJECT: |
|||
// TODO(JE)
|
|||
return ""; |
|||
|
|||
case SETTINGS_LOC::COLORS: |
|||
return GetColorSettingsPath(); |
|||
|
|||
default: |
|||
wxASSERT_MSG( false, "Unknown settings location!" ); |
|||
} |
|||
|
|||
return ""; |
|||
} |
|||
|
|||
|
|||
class MIGRATION_TRAVERSER : public wxDirTraverser |
|||
{ |
|||
private: |
|||
wxString m_src; |
|||
wxString m_dest; |
|||
wxString m_errors; |
|||
|
|||
public: |
|||
MIGRATION_TRAVERSER( const wxString& aSrcDir, const wxString& aDestDir ) : |
|||
m_src( aSrcDir ), m_dest( aDestDir ) |
|||
{ |
|||
} |
|||
|
|||
wxString GetErrors() { return m_errors; } |
|||
|
|||
virtual wxDirTraverseResult OnFile( const wxString& aSrcFilePath ) override |
|||
{ |
|||
wxFileName file( aSrcFilePath ); |
|||
wxString path = file.GetPath(); |
|||
|
|||
path.Replace( m_src, m_dest, false ); |
|||
file.SetPath( path ); |
|||
|
|||
wxLogTrace( traceSettings, "Copying %s to %s", aSrcFilePath, file.GetFullPath() ); |
|||
|
|||
// For now, just copy everything
|
|||
CopyFile( aSrcFilePath, file.GetFullPath(), m_errors ); |
|||
|
|||
return wxDIR_CONTINUE; |
|||
} |
|||
|
|||
virtual wxDirTraverseResult OnDir( const wxString& dirPath ) override |
|||
{ |
|||
wxFileName dir( dirPath ); |
|||
|
|||
// Whitelist of directories to migrate
|
|||
if( dir.GetName() == "colors" || |
|||
dir.GetName() == "3d" ) |
|||
{ |
|||
|
|||
wxString path = dir.GetPath(); |
|||
|
|||
path.Replace( m_src, m_dest, false ); |
|||
dir.SetPath( path ); |
|||
|
|||
wxMkdir( dir.GetFullPath() ); |
|||
|
|||
return wxDIR_CONTINUE; |
|||
} |
|||
else |
|||
{ |
|||
return wxDIR_IGNORE; |
|||
} |
|||
} |
|||
}; |
|||
|
|||
|
|||
bool SETTINGS_MANAGER::MigrateIfNeeded() |
|||
{ |
|||
wxFileName path( GetUserSettingsPath(), "" ); |
|||
wxLogTrace( traceSettings, "Using settings path %s", path.GetFullPath() ); |
|||
|
|||
if( path.DirExists() ) |
|||
{ |
|||
wxFileName common = path; |
|||
common.SetName( "kicad_common" ); |
|||
common.SetExt( "json" ); |
|||
|
|||
if( common.Exists() ) |
|||
{ |
|||
wxLogTrace( traceSettings, "Path exists and has a kicad_common, continuing!" ); |
|||
return true; |
|||
} |
|||
} |
|||
|
|||
// Now we have an empty path, let's figure out what to put in it
|
|||
DIALOG_MIGRATE_SETTINGS dlg( this ); |
|||
|
|||
if( dlg.ShowModal() != wxID_OK ) |
|||
{ |
|||
wxLogTrace( traceSettings, "Migration dialog canceled; exiting" ); |
|||
return false; |
|||
} |
|||
|
|||
if( !path.DirExists() ) |
|||
{ |
|||
wxLogTrace( traceSettings, "Path didn't exist; creating it" ); |
|||
path.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ); |
|||
} |
|||
|
|||
if( m_migration_source.IsEmpty() ) |
|||
{ |
|||
wxLogTrace( traceSettings, "No migration source given; starting with defaults" ); |
|||
return true; |
|||
} |
|||
|
|||
MIGRATION_TRAVERSER traverser( m_migration_source, path.GetFullPath() ); |
|||
wxDir source_dir( m_migration_source ); |
|||
|
|||
source_dir.Traverse( traverser ); |
|||
|
|||
if( !traverser.GetErrors().empty() ) |
|||
DisplayErrorMessage( nullptr, traverser.GetErrors() ); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
bool SETTINGS_MANAGER::GetPreviousVersionPaths( std::vector<wxString>* aPaths ) |
|||
{ |
|||
wxASSERT( aPaths ); |
|||
|
|||
aPaths->clear(); |
|||
|
|||
wxDir dir; |
|||
std::vector<wxFileName> base_paths; |
|||
|
|||
base_paths.emplace_back( wxFileName( calculateUserSettingsPath( false ), "" ) ); |
|||
|
|||
// If the env override is set, also check the default paths
|
|||
if( wxGetEnv( wxT( "KICAD_CONFIG_HOME" ), nullptr ) ) |
|||
base_paths.emplace_back( wxFileName( calculateUserSettingsPath( false, false ), "" ) ); |
|||
|
|||
wxString subdir; |
|||
std::string mine = GetSettingsVersion(); |
|||
|
|||
auto check_dir = [&] ( const wxString& aSubDir ) |
|||
{ |
|||
// Only older versions are valid for migration
|
|||
if( compareVersions( aSubDir.ToStdString(), mine ) <= 0 ) |
|||
{ |
|||
wxString sub_path = dir.GetNameWithSep() + aSubDir; |
|||
|
|||
if( IsSettingsPathValid( sub_path ) ) |
|||
{ |
|||
aPaths->push_back( sub_path ); |
|||
wxLogTrace( traceSettings, "GetPreviousVersionName: %s is valid", sub_path ); |
|||
} |
|||
} |
|||
}; |
|||
|
|||
for( auto base_path : base_paths ) |
|||
{ |
|||
if( !dir.Open( base_path.GetFullPath() ) ) |
|||
{ |
|||
wxLogTrace( traceSettings, "GetPreviousVersionName: could not open base path %s", |
|||
base_path.GetFullPath() ); |
|||
continue; |
|||
} |
|||
|
|||
wxLogTrace( traceSettings, "GetPreviousVersionName: checking base path %s", |
|||
base_path.GetFullPath() ); |
|||
|
|||
if( dir.GetFirst( &subdir, wxEmptyString, wxDIR_DIRS ) ) |
|||
{ |
|||
if( subdir != mine ) |
|||
check_dir( subdir ); |
|||
|
|||
while( dir.GetNext( &subdir ) ) |
|||
{ |
|||
if( subdir != mine ) |
|||
check_dir( subdir ); |
|||
} |
|||
} |
|||
|
|||
// If we didn't find one yet, check for legacy settings without a version directory
|
|||
if( IsSettingsPathValid( dir.GetNameWithSep() ) ) |
|||
{ |
|||
wxLogTrace( traceSettings, |
|||
"GetPreviousVersionName: root path %s is valid", dir.GetName() ); |
|||
aPaths->push_back( dir.GetName() ); |
|||
} |
|||
} |
|||
|
|||
return aPaths->size() > 0; |
|||
} |
|||
|
|||
|
|||
bool SETTINGS_MANAGER::IsSettingsPathValid( const wxString& aPath ) |
|||
{ |
|||
wxFileName test( aPath, "kicad_common" ); |
|||
return test.Exists(); |
|||
} |
|||
|
|||
|
|||
std::string SETTINGS_MANAGER::GetColorSettingsPath() |
|||
{ |
|||
wxFileName path; |
|||
|
|||
path.AssignDir( GetUserSettingsPath() ); |
|||
path.AppendDir( "colors" ); |
|||
|
|||
return path.GetPath().ToStdString(); |
|||
} |
|||
|
|||
|
|||
std::string SETTINGS_MANAGER::GetUserSettingsPath() |
|||
{ |
|||
static std::string user_settings_path; |
|||
|
|||
if( user_settings_path.empty() ) |
|||
user_settings_path = calculateUserSettingsPath(); |
|||
|
|||
return user_settings_path; |
|||
} |
|||
|
|||
|
|||
std::string SETTINGS_MANAGER::calculateUserSettingsPath( bool aIncludeVer, bool aUseEnv ) |
|||
{ |
|||
wxFileName cfgpath; |
|||
|
|||
// http://docs.wxwidgets.org/3.0/classwx_standard_paths.html#a7c7cf595d94d29147360d031647476b0
|
|||
cfgpath.AssignDir( wxStandardPaths::Get().GetUserConfigDir() ); |
|||
|
|||
// GetUserConfigDir() does not default to ~/.config which is the current standard
|
|||
// configuration file location on Linux. This has been fixed in later versions of wxWidgets.
|
|||
#if !defined( __WXMSW__ ) && !defined( __WXMAC__ )
|
|||
wxArrayString dirs = cfgpath.GetDirs(); |
|||
|
|||
if( dirs.Last() != ".config" ) |
|||
cfgpath.AppendDir( ".config" ); |
|||
#endif
|
|||
|
|||
wxString envstr; |
|||
|
|||
// This shouldn't cause any issues on Windows or MacOS.
|
|||
if( wxGetEnv( wxT( "XDG_CONFIG_HOME" ), &envstr ) && !envstr.IsEmpty() ) |
|||
{ |
|||
// Override the assignment above with XDG_CONFIG_HOME
|
|||
cfgpath.AssignDir( envstr ); |
|||
} |
|||
|
|||
cfgpath.AppendDir( TO_STR( KICAD_CONFIG_DIR ) ); |
|||
|
|||
// Use KICAD_CONFIG_HOME to allow the user to force a specific configuration path.
|
|||
if( aUseEnv && wxGetEnv( wxT( "KICAD_CONFIG_HOME" ), &envstr ) && !envstr.IsEmpty() ) |
|||
{ |
|||
// Override the assignment above with KICAD_CONFIG_HOME
|
|||
cfgpath.AssignDir( envstr ); |
|||
} |
|||
|
|||
if( aIncludeVer ) |
|||
cfgpath.AppendDir( GetSettingsVersion() ); |
|||
|
|||
return cfgpath.GetPath().ToStdString(); |
|||
} |
|||
|
|||
|
|||
std::string SETTINGS_MANAGER::GetSettingsVersion() |
|||
{ |
|||
wxString version = GetBuildVersion().BeforeLast( '.' ); |
|||
|
|||
// A full build version looks like (x.y.z-nnn-g1234567) or x.y.z-xxx
|
|||
// We want to extract the x.y portion here
|
|||
if( version.StartsWith( '(' ) ) |
|||
version = version.Mid( 1 ); |
|||
|
|||
return version.ToStdString(); |
|||
} |
|||
|
|||
|
|||
int SETTINGS_MANAGER::compareVersions( const std::string& aFirst, const std::string& aSecond ) |
|||
{ |
|||
int a_maj = 0; |
|||
int a_min = 0; |
|||
int b_maj = 0; |
|||
int b_min = 0; |
|||
|
|||
if( !extractVersion( aFirst, &a_maj, &a_min ) || !extractVersion( aSecond, &b_maj, &b_min ) ) |
|||
{ |
|||
wxLogTrace( traceSettings, "compareSettingsVersions: bad input (%s, %s)", aFirst, aSecond ); |
|||
return -1; |
|||
} |
|||
|
|||
if( a_maj < b_maj ) |
|||
{ |
|||
return -1; |
|||
} |
|||
else if( a_maj > b_maj ) |
|||
{ |
|||
return 1; |
|||
} |
|||
else |
|||
{ |
|||
if( a_min < b_min ) |
|||
{ |
|||
return -1; |
|||
} |
|||
else if( a_min > b_min ) |
|||
{ |
|||
return 1; |
|||
} |
|||
else |
|||
{ |
|||
return 0; |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
bool SETTINGS_MANAGER::extractVersion( const std::string& aVersionString, int* aMajor, int* aMinor ) |
|||
{ |
|||
std::regex re_version( "(\\d+)\\.(\\d+)" ); |
|||
std::smatch match; |
|||
|
|||
if( std::regex_match( aVersionString, match, re_version ) ) |
|||
{ |
|||
try |
|||
{ |
|||
*aMajor = std::stoi( match[1].str() ); |
|||
*aMinor = std::stoi( match[2].str() ); |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#include <cvpcb_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
#include <wx/config.h>
|
|||
|
|||
|
|||
///! Update the schema version whenever a migration is required
|
|||
const int cvpcbSchemaVersion = 0; |
|||
|
|||
CVPCB_SETTINGS::CVPCB_SETTINGS() : |
|||
APP_SETTINGS_BASE( "cvpcb", cvpcbSchemaVersion ) |
|||
{ |
|||
m_params.emplace_back( new PARAM<int>( "filter_footprint", &m_FilterFootprint, 0 ) ); |
|||
|
|||
addParamsForWindow( &m_FootprintViewer, "footprint_viewer" ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "footprint_viewer.pad_fill", |
|||
&m_FootprintViewerDisplayOptions.m_DisplayPadFill, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.pad_numbers", |
|||
&m_FootprintViewerDisplayOptions.m_DisplayPadNum, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.footprint_text_fill", |
|||
&m_FootprintViewerDisplayOptions.m_DisplayModTextFill, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.graphic_items_fill", |
|||
&m_FootprintViewerDisplayOptions.m_DisplayDrawItemsFill, true ) ); |
|||
} |
|||
|
|||
|
|||
bool CVPCB_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) |
|||
{ |
|||
bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg ); |
|||
|
|||
ret &= fromLegacy<int>( aCfg, "FilterFootprint", "filter_footprint" ); |
|||
|
|||
ret &= migrateWindowConfig( aCfg, "FootprintViewerFrame", "footprint_viewer" ); |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadFi", "footprint_viewer.pad_fill" ); |
|||
ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadNu", "footprint_viewer.pad_numbers" ); |
|||
ret &= fromLegacy<bool>( |
|||
aCfg, "FootprintViewerFrameDiModTx", "footprint_viewer.footprint_text_fill" ); |
|||
|
|||
return ret; |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#ifndef _CVPCB_SETTINGS_H |
|||
#define _CVPCB_SETTINGS_H |
|||
|
|||
#include <pcb_display_options.h> |
|||
#include <settings/app_settings.h> |
|||
|
|||
class CVPCB_SETTINGS : public APP_SETTINGS_BASE |
|||
{ |
|||
public: |
|||
CVPCB_SETTINGS(); |
|||
|
|||
virtual ~CVPCB_SETTINGS() {} |
|||
|
|||
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override; |
|||
|
|||
WINDOW_SETTINGS m_FootprintViewer; |
|||
|
|||
PCB_DISPLAY_OPTIONS m_FootprintViewerDisplayOptions; |
|||
|
|||
int m_FilterFootprint; |
|||
|
|||
protected: |
|||
|
|||
virtual std::string getLegacyFrameName() const override { return "CvpcbFrame"; } |
|||
}; |
|||
|
|||
|
|||
#endif |
|||
@ -0,0 +1,500 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#include <eeschema_settings.h>
|
|||
#include <layers_id_colors_and_visibility.h>
|
|||
#include <libedit_settings.h>
|
|||
#include <pgm_base.h>
|
|||
#include <settings/common_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
#include <settings/settings_manager.h>
|
|||
#include <wx/config.h>
|
|||
|
|||
|
|||
///! Update the schema version whenever a migration is required
|
|||
const int eeschemaSchemaVersion = 0; |
|||
|
|||
|
|||
EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : APP_SETTINGS_BASE( "eeschema", eeschemaSchemaVersion ) |
|||
{ |
|||
m_params.emplace_back( new PARAM<wxString>( "appearance.edit_component_visible_columns", |
|||
&m_Appearance.edit_component_visible_columns, "0 1 2 3 4 5 6 7" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "appearance.footprint_preview", |
|||
&m_Appearance.footprint_preview, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "appearance.navigator_stays_open", |
|||
&m_Appearance.navigator_stays_open, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "appearance.print_sheet_reference", |
|||
&m_Appearance.print_sheet_reference, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "appearance.show_hidden_pins", |
|||
&m_Appearance.show_hidden_pins, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "appearance.show_illegal_symbol_lib_dialog", |
|||
&m_Appearance.show_illegal_symbol_lib_dialog, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "appearance.show_page_limits", |
|||
&m_Appearance.show_page_limits, true ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "appearance.show_sheet_filename_case_sensitivity_dialog", |
|||
&m_Appearance.show_sheet_filename_case_sensitivity_dialog, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "autoplace_fields.enable", |
|||
&m_AutoplaceFields.enable, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "autoplace_fields.allow_rejustify", |
|||
&m_AutoplaceFields.allow_rejustify, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "autoplace_fields.align_to_grid", |
|||
&m_AutoplaceFields.align_to_grid, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "drawing.default_bus_thickness", |
|||
&m_Drawing.default_bus_thickness, 12 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "drawing.default_junction_size", |
|||
&m_Drawing.default_junction_size, 40 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "drawing.default_line_thickness", |
|||
&m_Drawing.default_line_thickness, 6 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_x", |
|||
&m_Drawing.default_repeat_offset_x, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_y", |
|||
&m_Drawing.default_repeat_offset_y, 100 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "drawing.default_wire_thickness", |
|||
&m_Drawing.default_wire_thickness, 6 ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<wxString>( "drawing.field_names", &m_Drawing.field_names, "" ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "drawing.hv_lines_only", &m_Drawing.hv_lines_only, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "drawing.repeat_label_increment", |
|||
&m_Drawing.repeat_label_increment, 1, -10, 10 ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<int>( "drawing.text_markup_flags", &m_Drawing.text_markup_flags, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "input.drag_is_move", &m_Input.drag_is_move, true ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<int>( "selection.thickness", &m_Selection.thickness, 3 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "selection.draw_selected_children", |
|||
&m_Selection.draw_selected_children, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "selection.fill_shapes", |
|||
&m_Selection.fill_shapes, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "selection.select_pin_selects_symbol", |
|||
&m_Selection.select_pin_selects_symbol, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "selection.text_as_box", |
|||
&m_Selection.text_as_box, false ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<int>( "annotation.method", &m_AnnotatePanel.method, 0, 0, 2 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "annotation.messages_filter", |
|||
&m_AnnotatePanel.messages_filter, -1 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "annotation.sort_order", |
|||
&m_AnnotatePanel.sort_order, 0, 0, 1 ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<wxString>( "bom.selected_plugin", &m_BomPanel.selected_plugin, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "bom.plugins", &m_BomPanel.plugins, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_revision", |
|||
&m_PageSettings.export_revision, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_date", |
|||
&m_PageSettings.export_date, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_title", |
|||
&m_PageSettings.export_title, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_company", |
|||
&m_PageSettings.export_company, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment1", |
|||
&m_PageSettings.export_comment1, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment2", |
|||
&m_PageSettings.export_comment2, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment3", |
|||
&m_PageSettings.export_comment3, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment4", |
|||
&m_PageSettings.export_comment4, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment5", |
|||
&m_PageSettings.export_comment5, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment6", |
|||
&m_PageSettings.export_comment6, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment7", |
|||
&m_PageSettings.export_comment7, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment8", |
|||
&m_PageSettings.export_comment8, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment9", |
|||
&m_PageSettings.export_comment9, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_MAP<bool>( "field_editor.fields_show", |
|||
&m_FieldEditorPanel.fields_show, {} ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_MAP<bool>( "field_editor.fields_group_by", |
|||
&m_FieldEditorPanel.fields_group_by, {} ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "plot.color", &m_PlotPanel.color, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "plot.format", &m_PlotPanel.format, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "plot.frame_reference", |
|||
&m_PlotPanel.frame_reference, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "plot.hpgl_paper_size", |
|||
&m_PlotPanel.hpgl_paper_size, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<double>( "plot.hpgl_pen_size", |
|||
&m_PlotPanel.hpgl_pen_size, 0.5 ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "plot.hpgl_origin", &m_PlotPanel.hpgl_origin, false ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<int>( "simulator.window.pos_x", &m_Simulator.window.pos_x, 0 ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<int>( "simulator.window.pos_y", &m_Simulator.window.pos_y, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "simulator.window.size_x", |
|||
&m_Simulator.window.size_x, 500 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "simulator.window.size_y", |
|||
&m_Simulator.window.size_y, 400 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "simulator.window.maximized", |
|||
&m_Simulator.window.maximized, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "simulator.window.perspective", |
|||
&m_Simulator.window.perspective, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_width", |
|||
&m_Simulator.plot_panel_width, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_height", |
|||
&m_Simulator.plot_panel_height, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "simulator.signal_panel_height", |
|||
&m_Simulator.signal_panel_height, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "simulator.cursors_panel_height", |
|||
&m_Simulator.cursors_panel_height, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "simulator.white_background", |
|||
&m_Simulator.white_background, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_h", |
|||
&m_SymChooserPanel.sash_pos_h, -1 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_v", |
|||
&m_SymChooserPanel.sash_pos_v, -1 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "symbol_chooser.width", |
|||
&m_SymChooserPanel.width, -1 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "symbol_chooser.height", |
|||
&m_SymChooserPanel.height, -1 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "symbol_chooser.keep_symbol", |
|||
&m_SymChooserPanel.keep_symbol, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "symbol_chooser.place_all_units", |
|||
&m_SymChooserPanel.place_all_units, true ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "system.never_show_rescue_dialog", |
|||
&m_RescueNeverShow, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "lib_view.window.pos_x", |
|||
&m_LibViewPanel.window.pos_x, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "lib_view.window.pos_y", |
|||
&m_LibViewPanel.window.pos_y, 0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "lib_view.window.size_x", |
|||
&m_LibViewPanel.window.size_x, 500 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "lib_view.window.size_y", |
|||
&m_LibViewPanel.window.size_y, 400 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "lib_view.window.maximized", |
|||
&m_LibViewPanel.window.maximized, false ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "lib_view.window.perspective", |
|||
&m_LibViewPanel.window.perspective, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "lib_view.lib_list_width", |
|||
&m_LibViewPanel.lib_list_width, 150 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<int>( "lib_view.cmp_list_width", |
|||
&m_LibViewPanel.cmp_list_width, 150 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<bool>( "lib_view.show_pin_electrical_type", |
|||
&m_LibViewPanel.show_pin_electrical_type, true ) ); |
|||
} |
|||
|
|||
|
|||
bool EESCHEMA_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) |
|||
{ |
|||
bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg ); |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, "FootprintPreview", "appearance.footprint_preview" ); |
|||
ret &= fromLegacy<bool>( aCfg, "NavigatorStaysOpen", "appearance.navigator_stays_open" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PrintSheetReferenceAndTitleBlock", |
|||
"appearance.print_sheet_reference" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowHiddenPins", "appearance.show_hidden_pins" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowIllegalSymbolLibDialog", |
|||
"appearance.show_illegal_symbol_lib_dialog" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowPageLimits", "appearance.show_page_limits" ); |
|||
ret &= fromLegacy<bool>( aCfg, "ShowSheetFileNameCaseSensitivityDlg", |
|||
"appearance.show_sheet_filename_case_sensitivity_dialog" ); |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, "AutoplaceFields", "autoplace_fields.enable" ); |
|||
ret &= fromLegacy<bool>( aCfg, "AutoplaceJustify", "autoplace_fields.allow_rejustify" ); |
|||
ret &= fromLegacy<bool>( aCfg, "AutoplaceAlign", "autoplace_fields.align_to_grid" ); |
|||
|
|||
ret &= fromLegacy<int>( aCfg, "DefaultBusWidth", "drawing.default_bus_thickness" ); |
|||
ret &= fromLegacy<int>( aCfg, "DefaultJunctionSize", "drawing.default_junction_size" ); |
|||
ret &= fromLegacy<int>( aCfg, "DefaultDrawLineWidth", "drawing.default_line_thickness" ); |
|||
ret &= fromLegacy<int>( aCfg, "RepeatStepX", "drawing.default_repeat_offset_x" ); |
|||
ret &= fromLegacy<int>( aCfg, "RepeatStepY", "drawing.default_repeat_offset_y" ); |
|||
ret &= fromLegacy<int>( aCfg, "DefaultWireWidth", "drawing.default_wire_thickness" ); |
|||
ret &= fromLegacyString( aCfg, "FieldNames", "drawing.field_names" ); |
|||
ret &= fromLegacy<bool>( aCfg, "HorizVertLinesOnly", "drawing.hv_lines_only" ); |
|||
ret &= fromLegacy<int>( aCfg, "RepeatLabelIncrement", "drawing.repeat_label_increment" ); |
|||
ret &= fromLegacy<int>( aCfg, "TextMarkupFlags", "drawing.text_markup_flags" ); |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, "DragActionIsMove", "input.drag_is_move" ); |
|||
|
|||
ret &= fromLegacy<int>( aCfg, "SelectionThickness", "selection.thickness" ); |
|||
ret &= fromLegacy<bool>( aCfg, "SelectionDrawChildItems", "selection.draw_selected_children" ); |
|||
ret &= fromLegacy<bool>( aCfg, "SelectionFillShapes", "selection.fill_shapes" ); |
|||
ret &= fromLegacy<bool>( aCfg, "SelectPinSelectSymbolOpt", |
|||
"selection.select_pin_selects_symbol" ); |
|||
ret &= fromLegacy<bool>( aCfg, "SelectionTextAsBox", "selection.text_as_box" ); |
|||
|
|||
ret &= fromLegacy<int>( aCfg, "AnnotateAlgoOption", "annotation.method" ); |
|||
ret &= fromLegacy<int>( aCfg, "AnnotateFilterMsg", "annotation.messages_filter" ); |
|||
ret &= fromLegacy<int>( aCfg, "AnnotateSortOption", "annotation.sort_order" ); |
|||
|
|||
ret &= fromLegacyString( aCfg, "bom_plugin_selected", "bom.selected_plugin" ); |
|||
ret &= fromLegacyString( aCfg, "bom_plugins", "bom.plugins" ); |
|||
|
|||
ret &= fromLegacyString( aCfg, "SymbolFieldsShownColumns", |
|||
"edit_sch_component.visible_columns" ); |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportRevision", "page_settings.export_revision" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportDate", "page_settings.export_date" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportTitle", "page_settings.export_title" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportCompany", "page_settings.export_company" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment1", "page_settings.export_comment1" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment2", "page_settings.export_comment2" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment3", "page_settings.export_comment3" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment4", "page_settings.export_comment4" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment5", "page_settings.export_comment5" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment6", "page_settings.export_comment6" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment7", "page_settings.export_comment7" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment8", "page_settings.export_comment8" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment9", "page_settings.export_comment9" ); |
|||
|
|||
{ |
|||
constexpr int max_custom_commands = 8; // from DIALOG_NETLIST
|
|||
nlohmann::json js_cmd = nlohmann::json::array(); |
|||
nlohmann::json js_title = nlohmann::json::array(); |
|||
wxString cmd_key, title_key, cmd, title; |
|||
|
|||
for( int i = 1; i <= max_custom_commands; ++i ) |
|||
{ |
|||
// Only migrate if both title and command are specified
|
|||
cmd_key.Printf( "CustomNetlistCommand%d", i ); |
|||
title_key.Printf( "CustomNetlistTitle%d", i ); |
|||
|
|||
if( aCfg->Read( cmd_key, &cmd ) && aCfg->Read( title_key, &title ) |
|||
&& !cmd.IsEmpty() && !title.IsEmpty() ) |
|||
{ |
|||
js_cmd.push_back( cmd.ToUTF8() ); |
|||
js_title.push_back( title.ToUTF8() ); |
|||
} |
|||
} |
|||
|
|||
( *this )[PointerFromString( "netlist.custom_command_titles" )] = js_title; |
|||
( *this )[PointerFromString( "netlist.custom_command_paths" )] = js_cmd; |
|||
} |
|||
|
|||
{ |
|||
// NOTE(JE) These parameters should move to project-local storage before V6, but we are
|
|||
// migrating them here in order to preserve data. There is a bug here that is preserved:
|
|||
// keys are taken directly from the (translated) UI and stored in the config, so if the user
|
|||
// changes languages the keys will no longer work.
|
|||
aCfg->SetPath( "SymbolFieldEditor/Show/" ); |
|||
|
|||
nlohmann::json js = nlohmann::json( {} ); |
|||
wxString key; |
|||
bool value = false; |
|||
long index = 0; |
|||
|
|||
while( aCfg->GetNextEntry( key, index ) ) |
|||
{ |
|||
if( aCfg->Read( key, &value ) ) |
|||
{ |
|||
std::string key_utf( key.ToUTF8() ); |
|||
js[PointerFromString( key_utf )] = value; |
|||
} |
|||
} |
|||
|
|||
( *this )[PointerFromString( "field_editor.fields_show" ) ] = js; |
|||
|
|||
aCfg->SetPath( "../GroupBy" ); |
|||
|
|||
while( aCfg->GetNextEntry( key, index ) ) |
|||
{ |
|||
if( aCfg->Read( key, &value ) ) |
|||
{ |
|||
std::string key_utf( key.ToUTF8() ); |
|||
js[PointerFromString( key_utf )] = value; |
|||
} |
|||
} |
|||
|
|||
( *this )[PointerFromString( "field_editor.fields_group_by" ) ] = js; |
|||
|
|||
aCfg->SetPath( "../.." ); |
|||
} |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, "PlotModeColor", "plot.color" ); |
|||
ret &= fromLegacy<int>( aCfg, "PlotFormat", "plot.format" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PlotFrameRef", "plot.frame_reference" ); |
|||
ret &= fromLegacy<bool>( aCfg, "PlotHPGLOrg", "plot.hpgl_origin" ); |
|||
ret &= fromLegacy<int>( aCfg, "PlotHPGLPaperSize", "plot.hpgl_paper_size" ); |
|||
ret &= fromLegacy<double>( aCfg, "PlotHPGLPenSize", "plot.hpgl_pen_size" ); |
|||
|
|||
ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_x", "simulator.window.pos_x" ); |
|||
ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_y", "simulator.window.pos_y" ); |
|||
ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_x", "simulator.window.size_x" ); |
|||
ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_y", "simulator.window.size_y" ); |
|||
ret &= fromLegacy<bool>( aCfg, "SIM_PLOT_FRAMEMaximized", "simulator.window.maximized" ); |
|||
ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEPerspective", "simulator.window.perspective" ); |
|||
ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEMostRecentlyUsedPath", "simulator.mru_path" ); |
|||
ret &= fromLegacy<int>( aCfg, "SimPlotPanelWidth", "simulator.plot_panel_width" ); |
|||
ret &= fromLegacy<int>( aCfg, "SimPlotPanelHeight", "simulator.plot_panel_height" ); |
|||
ret &= fromLegacy<int>( aCfg, "SimSignalPanelHeight", "simulator.signal_panel_height" ); |
|||
ret &= fromLegacy<int>( aCfg, "SimCursorsPanelHeight", "simulator.cursors_panel_height" ); |
|||
ret &= fromLegacy<bool>( aCfg, "SimPlotWhiteBg", "simulator.white_background" ); |
|||
|
|||
ret &= fromLegacy<int>( aCfg, "SymbolChooserHSashPosition", "symbol_chooser.sash_pos_h" ); |
|||
ret &= fromLegacy<int>( aCfg, "SymbolChooserVSashPosition", "symbol_chooser.sash_pos_v" ); |
|||
ret &= fromLegacy<int>( aCfg, "SymbolChooserWidth", "symbol_chooser.width" ); |
|||
ret &= fromLegacy<int>( aCfg, "SymbolChooserHeight", "symbol_chooser.height" ); |
|||
ret &= fromLegacy<bool>( aCfg, "SymbolChooserKeepSymbol", "symbol_chooser.keep_symbol" ); |
|||
ret &= fromLegacy<bool>( aCfg, "SymbolChooserUseUnits", "symbol_chooser.place_all_units" ); |
|||
|
|||
const std::string vlf = "ViewlibFrame"; |
|||
ret &= fromLegacy<bool>( aCfg, vlf + "Maximized", "lib_view.window.maximized" ); |
|||
ret &= fromLegacyString( aCfg, vlf + "MostRecentlyUsedPath", "lib_view.window.mru_path" ); |
|||
ret &= fromLegacy<int>( aCfg, vlf + "Size_x", "lib_view.window.size_x" ); |
|||
ret &= fromLegacy<int>( aCfg, vlf + "Size_y", "lib_view.window.size_y" ); |
|||
ret &= fromLegacyString( aCfg, vlf + "Perspective", "lib_view.window.perspective" ); |
|||
ret &= fromLegacy<int>( aCfg, vlf + "Pos_x", "lib_view.window.pos_x" ); |
|||
ret &= fromLegacy<int>( aCfg, vlf + "Pos_y", "lib_view.window.pos_y" ); |
|||
ret &= fromLegacy<int>( aCfg, "ViewLiblistWidth", "lib_view.lib_list_width" ); |
|||
ret &= fromLegacy<int>( aCfg, "ViewCmplistWidth", "lib_view.cmp_list_width" ); |
|||
ret &= fromLegacy<bool>( aCfg, |
|||
"ViewCmpShowPinElectricalType", "lib_view.show_pin_electrical_type" ); |
|||
ret &= fromLegacy<bool>( aCfg, vlf + "ShowGrid", "lib_view.grid.show" ); |
|||
ret &= fromLegacy<int>( aCfg, vlf + "_LastGridSize", "lib_view.grid.last_size" ); |
|||
|
|||
ret &= fromLegacy<bool>( aCfg, "RescueNeverShow", "system.never_show_rescue_dialog" ); |
|||
|
|||
// Legacy version stored this setting in eeschema, so move it to common if it exists
|
|||
aCfg->Read( "MoveWarpsCursor", &Pgm().GetCommonSettings()->m_Input.warp_mouse_on_move ); |
|||
|
|||
COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings(); |
|||
|
|||
auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) { |
|||
wxString str; |
|||
|
|||
if( aCfg->Read( aKey, &str ) ) |
|||
cs->SetColor( aLayerId, COLOR4D( str ) ); |
|||
}; |
|||
|
|||
migrateLegacyColor( "Color4DBgCanvasEx", LAYER_SCHEMATIC_BACKGROUND ); |
|||
migrateLegacyColor( "Color4DBodyBgEx", LAYER_DEVICE_BACKGROUND ); |
|||
migrateLegacyColor( "Color4DBodyEx", LAYER_DEVICE ); |
|||
migrateLegacyColor( "Color4DBrightenedEx", LAYER_BRIGHTENED ); |
|||
migrateLegacyColor( "Color4DBusEx", LAYER_BUS ); |
|||
migrateLegacyColor( "Color4DConnEx", LAYER_JUNCTION ); |
|||
migrateLegacyColor( "Color4DCursorEx", LAYER_SCHEMATIC_CURSOR ); |
|||
migrateLegacyColor( "Color4DErcEEx", LAYER_ERC_ERR ); |
|||
migrateLegacyColor( "Color4DErcWEx", LAYER_ERC_WARN ); |
|||
migrateLegacyColor( "Color4DFieldEx", LAYER_FIELDS ); |
|||
migrateLegacyColor( "Color4DGLabelEx", LAYER_GLOBLABEL ); |
|||
migrateLegacyColor( "Color4DGridEx", LAYER_SCHEMATIC_GRID ); |
|||
migrateLegacyColor( "Color4DHLabelEx", LAYER_HIERLABEL ); |
|||
migrateLegacyColor( "Color4DHiddenEx", LAYER_HIDDEN ); |
|||
migrateLegacyColor( "Color4DLLabelEx", LAYER_LOCLABEL ); |
|||
migrateLegacyColor( "Color4DNetNameEx", LAYER_NETNAM ); |
|||
migrateLegacyColor( "Color4DNoConnectEx", LAYER_NOCONNECT ); |
|||
migrateLegacyColor( "Color4DNoteEx", LAYER_NOTES ); |
|||
migrateLegacyColor( "Color4DPinEx", LAYER_PIN ); |
|||
migrateLegacyColor( "Color4DPinNameEx", LAYER_PINNAM ); |
|||
migrateLegacyColor( "Color4DPinNumEx", LAYER_PINNUM ); |
|||
migrateLegacyColor( "Color4DReferenceEx", LAYER_REFERENCEPART ); |
|||
migrateLegacyColor( "Color4DShadowEx", LAYER_SELECTION_SHADOWS ); |
|||
migrateLegacyColor( "Color4DSheetEx", LAYER_SHEET ); |
|||
migrateLegacyColor( "Color4DSheetFileNameEx", LAYER_SHEETFILENAME ); |
|||
migrateLegacyColor( "Color4DSheetLabelEx", LAYER_SHEETLABEL ); |
|||
migrateLegacyColor( "Color4DSheetNameEx", LAYER_SHEETNAME ); |
|||
migrateLegacyColor( "Color4DValueEx", LAYER_VALUEPART ); |
|||
migrateLegacyColor( "Color4DWireEx", LAYER_WIRE ); |
|||
migrateLegacyColor( "Color4DWorksheetEx", LAYER_SCHEMATIC_WORKSHEET ); |
|||
|
|||
// LibEdit settings were stored with eeschema. If eeschema is the first app to run,
|
|||
// we need to migrate the LibEdit settings here
|
|||
|
|||
auto libedit = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>( false ); |
|||
libedit->MigrateFromLegacy( aCfg ); |
|||
libedit->Load(); |
|||
|
|||
return ret; |
|||
} |
|||
@ -0,0 +1,203 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#ifndef _EESCHEMA_SETTINGS_H |
|||
#define _EESCHEMA_SETTINGS_H |
|||
|
|||
#include <settings/app_settings.h> |
|||
|
|||
|
|||
class EESCHEMA_SETTINGS : public APP_SETTINGS_BASE |
|||
{ |
|||
public: |
|||
|
|||
struct APPEARANCE |
|||
{ |
|||
wxString edit_component_visible_columns; |
|||
bool footprint_preview; |
|||
bool navigator_stays_open; |
|||
bool print_sheet_reference; |
|||
bool show_hidden_pins; |
|||
bool show_illegal_symbol_lib_dialog; |
|||
bool show_page_limits; |
|||
bool show_sheet_filename_case_sensitivity_dialog; |
|||
}; |
|||
|
|||
struct AUTOPLACE_FIELDS |
|||
{ |
|||
bool enable; |
|||
bool allow_rejustify; |
|||
bool align_to_grid; |
|||
}; |
|||
|
|||
struct DRAWING |
|||
{ |
|||
int default_bus_thickness; |
|||
int default_junction_size; |
|||
int default_line_thickness; |
|||
int default_repeat_offset_x; |
|||
int default_repeat_offset_y; |
|||
int default_wire_thickness; |
|||
wxString field_names; |
|||
bool hv_lines_only; |
|||
int repeat_label_increment; |
|||
int text_markup_flags; |
|||
}; |
|||
|
|||
struct INPUT |
|||
{ |
|||
bool drag_is_move; |
|||
}; |
|||
|
|||
struct SELECTION |
|||
{ |
|||
int thickness; |
|||
bool draw_selected_children; |
|||
bool fill_shapes; |
|||
bool select_pin_selects_symbol; |
|||
bool text_as_box; |
|||
}; |
|||
|
|||
struct PAGE_SETTINGS |
|||
{ |
|||
bool export_revision; |
|||
bool export_date; |
|||
bool export_title; |
|||
bool export_company; |
|||
bool export_comment1; |
|||
bool export_comment2; |
|||
bool export_comment3; |
|||
bool export_comment4; |
|||
bool export_comment5; |
|||
bool export_comment6; |
|||
bool export_comment7; |
|||
bool export_comment8; |
|||
bool export_comment9; |
|||
}; |
|||
|
|||
struct PANEL_ANNOTATE |
|||
{ |
|||
int method; |
|||
int messages_filter; |
|||
int sort_order; |
|||
}; |
|||
|
|||
struct PANEL_BOM |
|||
{ |
|||
wxString selected_plugin; |
|||
wxString plugins; |
|||
}; |
|||
|
|||
struct PANEL_FIELD_EDITOR |
|||
{ |
|||
std::map<std::string, bool> fields_show; |
|||
std::map<std::string, bool> fields_group_by; |
|||
}; |
|||
|
|||
struct PANEL_LIB_VIEW |
|||
{ |
|||
int lib_list_width; |
|||
int cmp_list_width; |
|||
bool show_pin_electrical_type; |
|||
WINDOW_SETTINGS window; |
|||
}; |
|||
|
|||
struct PANEL_NETLIST |
|||
{ |
|||
std::vector<wxString> custom_command_titles; |
|||
std::vector<wxString> custom_command_paths; |
|||
}; |
|||
|
|||
struct PANEL_PLOT |
|||
{ |
|||
bool color; |
|||
int format; |
|||
bool frame_reference; |
|||
int hpgl_paper_size; |
|||
double hpgl_pen_size; |
|||
bool hpgl_origin; |
|||
}; |
|||
|
|||
struct PANEL_SYM_CHOOSER |
|||
{ |
|||
int sash_pos_h; |
|||
int sash_pos_v; |
|||
int width; |
|||
int height; |
|||
bool keep_symbol; |
|||
bool place_all_units; |
|||
}; |
|||
|
|||
struct SIMULATOR |
|||
{ |
|||
int plot_panel_width; |
|||
int plot_panel_height; |
|||
int signal_panel_height; |
|||
int cursors_panel_height; |
|||
bool white_background; |
|||
WINDOW_SETTINGS window; |
|||
}; |
|||
|
|||
EESCHEMA_SETTINGS(); |
|||
|
|||
virtual ~EESCHEMA_SETTINGS() {} |
|||
|
|||
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override; |
|||
|
|||
APPEARANCE m_Appearance; |
|||
|
|||
AUTOPLACE_FIELDS m_AutoplaceFields; |
|||
|
|||
DRAWING m_Drawing; |
|||
|
|||
INPUT m_Input; |
|||
|
|||
PAGE_SETTINGS m_PageSettings; |
|||
|
|||
PANEL_ANNOTATE m_AnnotatePanel; |
|||
|
|||
PANEL_BOM m_BomPanel; |
|||
|
|||
PANEL_FIELD_EDITOR m_FieldEditorPanel; |
|||
|
|||
PANEL_LIB_VIEW m_LibViewPanel; |
|||
|
|||
PANEL_NETLIST m_NetlistPanel; |
|||
|
|||
PANEL_PLOT m_PlotPanel; |
|||
|
|||
PANEL_SYM_CHOOSER m_SymChooserPanel; |
|||
|
|||
SELECTION m_Selection; |
|||
|
|||
SIMULATOR m_Simulator; |
|||
|
|||
bool m_RescueNeverShow; |
|||
|
|||
protected: |
|||
|
|||
virtual std::string getLegacyFrameName() const override { return "SchematicFrame"; } |
|||
}; |
|||
|
|||
|
|||
#endif |
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue