asettings.h 3.2 KB

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