settings.h
/*
*openPilotLog - A FOSS Pilot Logbook Application
*Copyright (C) 2020-2022 Felix Turowsky
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef SETTINGS_H
#define SETTINGS_H
#include <QtCore>
#include <QSettings>
class Settings {
public:
enum class Main {
SetupComplete,
Style,
Font,
FontSize,
UseSystemFont,
LogbookView,
DateFormat,
};
enum class UserData {
DisplaySelfAs,
TailSortColumn,
PilotSortColumn,
FtlWarningThreshold,
CurrWarningThreshold,
ShowToLgdCurrency,
ShowLicCurrency,
ShowTrCurrency,
ShowLckCurrency,
ShowMedCurrency,
ShowCustom1Currency,
ShowCustom2Currency,
Custom1CurrencyName,
Custom2CurrencyName,
};
enum class FlightLogging {
Function,
Approach,
NightLoggingEnabled,
LogIFR,
FlightNumberPrefix,
PilotFlying,
NightAngle,
//FlightTimeFormat,
};
static void setup();
static void resetToDefaults();
static QVariant read(const Main key);
static void write(const Main key, const QVariant &val);
static QVariant read(const FlightLogging key);
static void write(const UserData key, const QVariant &val);
static QVariant read(const UserData key);
static void write(const FlightLogging key, const QVariant &val);
static QString groupOfKey(const Main key);
static QString groupOfKey(const FlightLogging key);
static QString groupOfKey(const UserData key);
static QString stringOfKey(const Main key);
static QString stringOfKey(const FlightLogging key);
static QString stringOfKey(const UserData key);
static QSettings settings();
static void sync() { QSettings().sync(); }
private:
static QMap<Main, QString> mainMap;
static QMap<UserData, QString> userDataMap;
static QMap<FlightLogging, QString> flightLoggingMap;
};
#endif // SETTINGS_H
Settings
Thin wrapper for the QSettings class, simplifying reading and writing of settings.
Definition: settings.h:27
Settings::setup
static void setup()
Should be called after QCoreApplication::set...Name have been called.
Definition: settings.cpp:60
Settings::groupOfKey
static QString groupOfKey(const Main key)
Return string representation of group of key: "ini_header/key".
Definition: settings.cpp:119
Settings::stringOfKey
static QString stringOfKey(const Main key)
Return string representation of key.
Definition: settings.cpp:131
Settings::resetToDefaults
static void resetToDefaults()
Settings::resetToDefaults (Re-)sets all settings to the default value.
Definition: settings.cpp:69