You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #include <settings/parameters.h>
  24. #include <wx/config.h>
  25. #include "pl_editor_settings.h"
  26. ///! Update the schema version whenever a migration is required
  27. const int plEditorSchemaVersion = 0;
  28. PL_EDITOR_SETTINGS::PL_EDITOR_SETTINGS() :
  29. APP_SETTINGS_BASE( "pl_editor", plEditorSchemaVersion )
  30. {
  31. // Make Coverity happy:
  32. m_CornerOrigin = 0;
  33. m_PropertiesFrameWidth = 150;
  34. m_LastCustomWidth = 17000;
  35. m_LastCustomHeight = 11000;
  36. m_LastWasPortrait = false;
  37. m_BlackBackground = false;
  38. // Build settings:
  39. m_params.emplace_back(
  40. new PARAM<int>( "properties_frame_width", &m_PropertiesFrameWidth, 150 ) );
  41. m_params.emplace_back( new PARAM<int>( "corner_origin", &m_CornerOrigin, 0 ) );
  42. m_params.emplace_back( new PARAM<bool>( "black_background", &m_BlackBackground, false ) );
  43. m_params.emplace_back( new PARAM<wxString>( "last_paper_size", &m_LastPaperSize, "A3" ) );
  44. m_params.emplace_back( new PARAM<int>( "last_custom_width", &m_LastCustomWidth, 17000 ) );
  45. m_params.emplace_back( new PARAM<int>( "last_custom_height", &m_LastCustomHeight, 11000 ) );
  46. m_params.emplace_back( new PARAM<bool>( "last_was_portrait", &m_LastWasPortrait, false ) );
  47. }
  48. bool PL_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
  49. {
  50. bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
  51. ret &= fromLegacy<int>( aCfg, "PropertiesFrameWidth", "properties_frame_width" );
  52. ret &= fromLegacy<int>( aCfg, "CornerOriginChoice", "corner_origin" );
  53. ret &= fromLegacy<bool>( aCfg, "BlackBgColor", "black_background" );
  54. ret &= fromLegacy<int>( aCfg, "LastUsedPaperSize", "last_paper_size" );
  55. ret &= fromLegacy<int>( aCfg, "LastUsedCustomWidth", "last_custom_width" );
  56. ret &= fromLegacy<int>( aCfg, "LastUsedCustomHeight", "last_custom_height" );
  57. ret &= fromLegacy<bool>( aCfg, "LastUsedWasPortrait", "last_was_portrait" );
  58. return ret;
  59. }