asettings.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. *openPilotLog - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020-2021 Felix Turowsky
  4. *
  5. *This program is free software: you can redistribute it and/or modify
  6. *it under the terms of the GNU General Public License as published by
  7. *the Free Software Foundation, either version 3 of the License, or
  8. *(at your option) any later version.
  9. *
  10. *This program is distributed in the hope that it will be useful,
  11. *but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. *GNU General Public License for more details.
  14. *
  15. *You should have received a copy of the GNU General Public License
  16. *along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. #ifndef ASETTINGS_H
  19. #define ASETTINGS_H
  20. #include <QtCore>
  21. #include <QSettings>
  22. /*!
  23. * \brief Thin wrapper for the QSettings class,
  24. * simplifying reading and writing of settings.
  25. */
  26. class ASettings {
  27. public:
  28. enum class Main {
  29. SetupComplete,
  30. Style,
  31. Font,
  32. FontSize,
  33. UseSystemFont,
  34. LogbookView,
  35. };
  36. enum class UserData {
  37. DisplaySelfAs,
  38. AcftSortColumn,
  39. PilSortColumn,
  40. AcAllowIncomplete,
  41. FtlWarningThreshold,
  42. };
  43. enum class FlightLogging {
  44. Function,
  45. Approach,
  46. NightLogging,
  47. LogIFR,
  48. FlightNumberPrefix,
  49. NumberTakeoffs,
  50. NumberLandings,
  51. PopupCalendar,
  52. PilotFlying,
  53. NightAngle,
  54. Rules,
  55. FlightTimeFormat,
  56. FunctionComboBox,
  57. CalendarCheckBox,
  58. };
  59. /*!
  60. * \brief Should be called after QCoreApplication::set...Name have been called.
  61. */
  62. static void setup();
  63. static QVariant read(const Main key);
  64. static void write(const Main key, const QVariant &val);
  65. static QVariant read(const FlightLogging key);
  66. static void write(const UserData key, const QVariant &val);
  67. static QVariant read(const UserData key);
  68. static void write(const FlightLogging key, const QVariant &val);
  69. /*!
  70. * \brief Return string representation of group of key: "ini_header/key"
  71. */
  72. static QString groupOfKey(const Main key);
  73. static QString groupOfKey(const FlightLogging key);
  74. static QString groupOfKey(const UserData key);
  75. /*!
  76. * \brief Return string representation of key
  77. */
  78. static QString stringOfKey(const Main key);
  79. static QString stringOfKey(const FlightLogging key);
  80. static QString stringOfKey(const UserData key);
  81. static QSettings settings();
  82. private:
  83. static QMap<Main, QString> mainMap;
  84. static QMap<UserData, QString> userDataMap;
  85. static QMap<FlightLogging, QString> flightLoggingMap;
  86. };
  87. #endif // ASETTINGS_H