openPilotLog
asettings.h
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 
27 class ASettings {
28 public:
29  enum class Main {
30  SetupComplete,
31  Style,
32  Font,
33  FontSize,
34  UseSystemFont,
35  LogbookView,
36  DateFormat,
37  };
38 
39  enum class UserData {
40  DisplaySelfAs,
41  TailSortColumn,
42  PilotSortColumn,
43  AcftAllowIncomplete,
44  FtlWarningThreshold,
45  CurrWarningEnabled,
46  CurrWarningThreshold,
47  ShowToLgdCurrency,
48  ShowLicCurrency,
49  ShowTrCurrency,
50  ShowLckCurrency,
51  ShowMedCurrency,
52  ShowCustom1Currency,
53  ShowCustom2Currency,
54  Custom1CurrencyName,
55  Custom2CurrencyName,
56  };
57 
58  enum class FlightLogging {
59  Function,
60  Approach,
61  NightLoggingEnabled,
62  LogIFR,
63  FlightNumberPrefix,
64  NumberTakeoffs,
65  NumberLandings,
66  PilotFlying,
67  NightAngle,
68  Rules,
69  FlightTimeFormat,
70  FunctionComboBox,
71  };
72 
76  static void setup();
77  static void resetToDefaults();
78 
79  static QVariant read(const Main key);
80  static void write(const Main key, const QVariant &val);
81 
82  static QVariant read(const FlightLogging key);
83  static void write(const UserData key, const QVariant &val);
84 
85  static QVariant read(const UserData key);
86  static void write(const FlightLogging key, const QVariant &val);
87 
91  static QString groupOfKey(const Main key);
92  static QString groupOfKey(const FlightLogging key);
93  static QString groupOfKey(const UserData key);
94 
98  static QString stringOfKey(const Main key);
99  static QString stringOfKey(const FlightLogging key);
100  static QString stringOfKey(const UserData key);
101 
102  static QSettings settings();
103 
104 private:
105  static QMap<Main, QString> mainMap;
106  static QMap<UserData, QString> userDataMap;
107  static QMap<FlightLogging, QString> flightLoggingMap;
108 };
109 
110 #endif // ASETTINGS_H
ASettings::resetToDefaults
static void resetToDefaults()
ASettings::resetToDefaults (Re-)sets all settings to the default value.
Definition: asettings.cpp:75
ASettings::setup
static void setup()
Should be called after QCoreApplication::set...Name have been called.
Definition: asettings.cpp:66
ASettings
Thin wrapper for the QSettings class, simplifying reading and writing of settings.
Definition: asettings.h:27
ASettings::stringOfKey
static QString stringOfKey(const Main key)
Return string representation of key.
Definition: asettings.cpp:140
ASettings::groupOfKey
static QString groupOfKey(const Main key)
Return string representation of group of key: "ini_header/key".
Definition: asettings.cpp:128