asettings.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. DateFormat,
  36. };
  37. enum class UserData {
  38. DisplaySelfAs,
  39. TailSortColumn,
  40. PilotSortColumn,
  41. AcftAllowIncomplete,
  42. FtlWarningThreshold,
  43. CurrWarningEnabled,
  44. CurrWarningThreshold,
  45. ShowToLgdCurrency,
  46. ShowLicCurrency,
  47. ShowTrCurrency,
  48. ShowLckCurrency,
  49. ShowMedCurrency,
  50. ShowCustom1Currency,
  51. ShowCustom2Currency,
  52. Custom1CurrencyName,
  53. Custom2CurrencyName,
  54. };
  55. enum class FlightLogging {
  56. Function,
  57. Approach,
  58. NightLoggingEnabled,
  59. LogIFR,
  60. FlightNumberPrefix,
  61. NumberTakeoffs,
  62. NumberLandings,
  63. PopupCalendar,
  64. PilotFlying,
  65. NightAngle,
  66. Rules,
  67. FlightTimeFormat,
  68. FunctionComboBox,
  69. CalendarCheckBox,
  70. };
  71. /*!
  72. * \brief Should be called after QCoreApplication::set...Name have been called.
  73. */
  74. static void setup();
  75. static void resetToDefaults();
  76. static QVariant read(const Main key);
  77. static void write(const Main key, const QVariant &val);
  78. static QVariant read(const FlightLogging key);
  79. static void write(const UserData key, const QVariant &val);
  80. static QVariant read(const UserData key);
  81. static void write(const FlightLogging key, const QVariant &val);
  82. /*!
  83. * \brief Return string representation of group of key: "ini_header/key"
  84. */
  85. static QString groupOfKey(const Main key);
  86. static QString groupOfKey(const FlightLogging key);
  87. static QString groupOfKey(const UserData key);
  88. /*!
  89. * \brief Return string representation of key
  90. */
  91. static QString stringOfKey(const Main key);
  92. static QString stringOfKey(const FlightLogging key);
  93. static QString stringOfKey(const UserData key);
  94. static QSettings settings();
  95. private:
  96. static QMap<Main, QString> mainMap;
  97. static QMap<UserData, QString> userDataMap;
  98. static QMap<FlightLogging, QString> flightLoggingMap;
  99. };
  100. #endif // ASETTINGS_H