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.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2022 Andrew Lutsenko, anlutsenko at gmail dot com
  5. * Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include "panel_packages_and_updates.h"
  25. #include <pgm_base.h>
  26. #include <settings/kicad_settings.h>
  27. #include <settings/settings_manager.h>
  28. #include <widgets/ui_common.h>
  29. PANEL_PACKAGES_AND_UPDATES::PANEL_PACKAGES_AND_UPDATES( wxWindow* parent ) :
  30. PANEL_PACKAGES_AND_UPDATES_BASE( parent )
  31. {
  32. wxSize minSize = m_libPrefix->GetMinSize();
  33. int minWidth = m_libPrefix->GetTextExtent( wxT( "XXX.XXX" ) ).GetWidth();
  34. m_libPrefix->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
  35. #ifndef KICAD_UPDATE_CHECK
  36. m_generalLabel->Hide();
  37. m_staticline3->Hide();
  38. m_cbKicadUpdate->Hide();
  39. #endif
  40. }
  41. bool PANEL_PACKAGES_AND_UPDATES::TransferDataToWindow()
  42. {
  43. SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
  44. KICAD_SETTINGS* settings = mgr.GetAppSettings<KICAD_SETTINGS>();
  45. m_cbKicadUpdate->SetValue( settings->m_KiCadUpdateCheck );
  46. m_cbPcmUpdate->SetValue( settings->m_PcmUpdateCheck );
  47. m_libAutoAdd->SetValue( settings->m_PcmLibAutoAdd );
  48. m_libAutoRemove->SetValue( settings->m_PcmLibAutoRemove );
  49. m_libPrefix->SetValue( settings->m_PcmLibPrefix );
  50. return true;
  51. }
  52. bool PANEL_PACKAGES_AND_UPDATES::TransferDataFromWindow()
  53. {
  54. SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
  55. KICAD_SETTINGS* settings = mgr.GetAppSettings<KICAD_SETTINGS>();
  56. settings->m_KiCadUpdateCheck = m_cbKicadUpdate->GetValue();
  57. settings->m_PcmUpdateCheck = m_cbPcmUpdate->GetValue();
  58. settings->m_PcmLibAutoAdd = m_libAutoAdd->GetValue();
  59. settings->m_PcmLibAutoRemove = m_libAutoRemove->GetValue();
  60. settings->m_PcmLibPrefix = m_libPrefix->GetValue();
  61. return true;
  62. }