| 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 FtlWarningThreshold,
44 CurrWarningThreshold,
45 ShowToLgdCurrency,
46 ShowLicCurrency,
47 ShowTrCurrency,
48 ShowLckCurrency,
49 ShowMedCurrency,
50 ShowCustom1Currency,
51 ShowCustom2Currency,
52 Custom1CurrencyName,
53 Custom2CurrencyName,
54 };
55
56 enum class FlightLogging {
57 Function,
58 Approach,
59 NightLoggingEnabled,
60 LogIFR,
61 FlightNumberPrefix,
62 PilotFlying,
63 NightAngle,
64 //FlightTimeFormat,
65 };
66
70 static void setup();
71 static void resetToDefaults();
72
73 static QVariant read(const Main key);
74 static void write(const Main key, const QVariant &val);
75
76 static QVariant read(const FlightLogging key);
77 static void write(const UserData key, const QVariant &val);
78
79 static QVariant read(const UserData key);
80 static void write(const FlightLogging key, const QVariant &val);
81
85 static QString groupOfKey(const Main key);
86 static QString groupOfKey(const FlightLogging key);
87 static QString groupOfKey(const UserData key);
88
92 static QString stringOfKey(const Main key);
93 static QString stringOfKey(const FlightLogging key);
94 static QString stringOfKey(const UserData key);
95
96 static QSettings settings();
97 static void sync() { QSettings().sync(); }
98
99 private:
100 static QMap<Main, QString> mainMap;
101 static QMap<UserData, QString> userDataMap;
102 static QMap<FlightLogging, QString> flightLoggingMap;
103 };
104
105 #endif // ASETTINGS_H
ASettings
Thin wrapper for the QSettings class, simplifying reading and writing of settings.
Definition: asettings.h:27
ASettings::resetToDefaults
static void resetToDefaults()
ASettings::resetToDefaults (Re-)sets all settings to the default value.
Definition: asettings.cpp:69
ASettings::setup
static void setup()
Should be called after QCoreApplication::set...Name have been called.
Definition: asettings.cpp:60
ASettings::groupOfKey
static QString groupOfKey(const Main key)
Return string representation of group of key: "ini_header/key".
Definition: asettings.cpp:119
ASettings::stringOfKey
static QString stringOfKey(const Main key)
Return string representation of key.
Definition: asettings.cpp:131