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.

110 lines
3.6 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 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. #ifndef ADVANCED_CFG__H
  24. #define ADVANCED_CFG__H
  25. class wxConfigBase;
  26. /**
  27. * Class containing "advanced" configuration options.
  28. *
  29. * Options set here are for developer or advanced users only. If a general user
  30. * needs to set one of these for normal KiCad use, either:
  31. * * They are working around some bug that should be fixed, or
  32. * * The parameter they are setting is of general interest and should be in the
  33. * main application config, with UI provided.
  34. *
  35. * Options in this class are, in general, preferable to #defines, as they
  36. * allow more flexible configuration by developers, and don't hide code from
  37. * the compiler on other configurations, which can result in broken builds.
  38. *
  39. * Never use advanced configs in an untestable way. If a function depends on
  40. * advanced config such that you cannot test it without changing the config,
  41. * "lift" the config to a higher level and make pass it as parameter of the code
  42. * under test. The tests can pass their own values as needed.
  43. *
  44. * This also applies to code that does not depend on "common" - it cannot
  45. * use this class, so you must pass configuration in as proper parameters.
  46. *
  47. * Sometimes you can just use values directly, and sometimes helper functions
  48. * might be provided to allow extra logic (for example when a advanced config
  49. * applies only on certain platforms).
  50. *
  51. * For more information on what config keys set these parameters in the
  52. * config files, and why you might want to set them, see #AC_KEYS
  53. *
  54. */
  55. class ADVANCED_CFG
  56. {
  57. public:
  58. /**
  59. * Get the singleton instance's config, which is shared by all
  60. * consumers of advanced config.
  61. *
  62. * This configuration is read-only - to set options, users should
  63. * add the parameters to their config files at ~/.config/kicad/advanced, or the
  64. * platform equivalent.
  65. */
  66. static const ADVANCED_CFG& GetCfg();
  67. /**
  68. * Enable SVG import.
  69. */
  70. bool m_enableSvgImport;
  71. /**
  72. * Do real-time connectivity
  73. */
  74. bool m_realTimeConnectivity;
  75. /**
  76. * Helper to determine if legacy canvas is allowed (according to platform
  77. * and config)
  78. * @return true if legacy canvas should be shown
  79. */
  80. bool AllowLegacyCanvas() const;
  81. private:
  82. /*
  83. * These settings are private, as there is extra logic provide by helper
  84. * functions above.
  85. */
  86. bool m_allowLegacyCanvasInGtk3;
  87. private:
  88. ADVANCED_CFG();
  89. /**
  90. * Load the config from the normal config file
  91. */
  92. void loadFromConfigFile();
  93. /*
  94. * Load config from the given config base
  95. */
  96. void loadSettings( wxConfigBase& aCfg );
  97. };
  98. #endif // ADVANCED_CFG__H