2018-07-31 13:04:12 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#ifndef QPREFUNIT_H
|
|
|
|
#define QPREFUNIT_H
|
|
|
|
#include "core/pref.h"
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
|
|
|
|
class qPrefUnits : public QObject {
|
|
|
|
Q_OBJECT
|
2019-02-11 19:27:30 +00:00
|
|
|
Q_PROPERTY(bool coordinates_traditional READ coordinates_traditional WRITE set_coordinates_traditional NOTIFY coordinates_traditionalChanged)
|
2019-01-18 07:07:00 +00:00
|
|
|
Q_PROPERTY(QString duration_units READ duration_units WRITE set_duration_units NOTIFY duration_unitsStringChanged)
|
|
|
|
Q_PROPERTY(QString length READ length WRITE set_length NOTIFY lengthStringChanged)
|
|
|
|
Q_PROPERTY(QString pressure READ pressure WRITE set_pressure NOTIFY pressureStringChanged)
|
2019-02-11 19:27:30 +00:00
|
|
|
Q_PROPERTY(bool show_units_table READ show_units_table WRITE set_show_units_table NOTIFY show_units_tableChanged)
|
2019-01-18 07:07:00 +00:00
|
|
|
Q_PROPERTY(QString temperature READ temperature WRITE set_temperature NOTIFY temperatureStringChanged)
|
2019-02-11 19:27:30 +00:00
|
|
|
Q_PROPERTY(QString unit_system READ unit_system WRITE set_unit_system NOTIFY unit_systemChanged)
|
2019-01-18 07:07:00 +00:00
|
|
|
Q_PROPERTY(QString vertical_speed_time READ vertical_speed_time WRITE set_vertical_speed_time NOTIFY vertical_speed_timeStringChanged)
|
|
|
|
Q_PROPERTY(QString volume READ volume WRITE set_volume NOTIFY volumeStringChanged)
|
|
|
|
Q_PROPERTY(QString weight READ weight WRITE set_weight NOTIFY weightStringChanged)
|
2018-07-31 13:04:12 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
static qPrefUnits *instance();
|
|
|
|
|
|
|
|
// Load/Sync local settings (disk) and struct preference
|
2018-08-14 08:30:07 +00:00
|
|
|
static void loadSync(bool doSync);
|
|
|
|
static void load() { loadSync(false); }
|
|
|
|
static void sync() { loadSync(true); }
|
2018-07-31 13:04:12 +00:00
|
|
|
|
|
|
|
public:
|
2018-08-02 16:32:51 +00:00
|
|
|
static bool coordinates_traditional() { return prefs.coordinates_traditional; }
|
2019-01-18 07:07:00 +00:00
|
|
|
static QString duration_units();
|
|
|
|
static QString length();
|
|
|
|
static QString pressure();
|
2018-08-02 16:32:51 +00:00
|
|
|
static bool show_units_table() { return prefs.units.show_units_table; }
|
2019-01-18 07:07:00 +00:00
|
|
|
static QString temperature();
|
2018-07-31 13:04:12 +00:00
|
|
|
static QString unit_system();
|
2019-01-18 07:07:00 +00:00
|
|
|
static QString vertical_speed_time();
|
|
|
|
static QString volume();
|
|
|
|
static QString weight();
|
2018-07-31 13:04:12 +00:00
|
|
|
|
|
|
|
public slots:
|
2018-08-14 08:30:07 +00:00
|
|
|
static void set_coordinates_traditional(bool value);
|
|
|
|
static void set_duration_units(units::DURATION value);
|
2019-01-18 07:07:00 +00:00
|
|
|
static void set_duration_units(const QString& value);
|
2018-08-14 08:30:07 +00:00
|
|
|
static void set_length(units::LENGTH value);
|
2019-01-18 07:07:00 +00:00
|
|
|
static void set_length(const QString& value);
|
2018-08-14 08:30:07 +00:00
|
|
|
static void set_pressure(units::PRESSURE value);
|
2019-01-18 07:07:00 +00:00
|
|
|
static void set_pressure(const QString& value);
|
2018-08-14 08:30:07 +00:00
|
|
|
static void set_show_units_table(bool value);
|
|
|
|
static void set_temperature(units::TEMPERATURE value);
|
2019-01-18 07:07:00 +00:00
|
|
|
static void set_temperature(const QString& value);
|
2018-08-14 08:30:07 +00:00
|
|
|
static void set_unit_system(const QString& value);
|
|
|
|
static void set_vertical_speed_time(units::TIME value);
|
2019-01-18 07:07:00 +00:00
|
|
|
static void set_vertical_speed_time(const QString& value);
|
2018-08-14 08:30:07 +00:00
|
|
|
static void set_volume(units::VOLUME value);
|
2019-01-18 07:07:00 +00:00
|
|
|
static void set_volume(const QString& value);
|
2018-08-14 08:30:07 +00:00
|
|
|
static void set_weight(units::WEIGHT value);
|
2019-01-18 07:07:00 +00:00
|
|
|
static void set_weight(const QString& value);
|
2018-07-31 13:04:12 +00:00
|
|
|
|
|
|
|
signals:
|
2019-01-18 07:07:00 +00:00
|
|
|
// Normally the same signal name are used with different parameters:
|
|
|
|
// void weightChanged(int value);
|
|
|
|
// void weightChanged(const QString& value);
|
|
|
|
// This works perfect, however connect() cannot automatically determine
|
|
|
|
// which signal to catch, for that purpose SIGNAL() / SLOT() macros are used,
|
|
|
|
// since they include the parameter type.
|
|
|
|
// However there is a design decision, not to use the macros, so
|
|
|
|
// signal must have unique names.
|
2018-09-02 11:58:04 +00:00
|
|
|
void coordinates_traditionalChanged(bool value);
|
|
|
|
void duration_unitsChanged(int value);
|
2019-01-18 07:07:00 +00:00
|
|
|
void duration_unitsStringChanged(const QString& value);
|
2018-09-02 11:58:04 +00:00
|
|
|
void lengthChanged(int value);
|
2019-01-18 07:07:00 +00:00
|
|
|
void lengthStringChanged(const QString& value);
|
2018-09-02 11:58:04 +00:00
|
|
|
void pressureChanged(int value);
|
2019-01-18 07:07:00 +00:00
|
|
|
void pressureStringChanged(const QString& value);
|
2018-09-02 11:58:04 +00:00
|
|
|
void show_units_tableChanged(bool value);
|
|
|
|
void temperatureChanged(int value);
|
2019-01-18 07:07:00 +00:00
|
|
|
void temperatureStringChanged(const QString& value);
|
2018-09-02 11:58:04 +00:00
|
|
|
void unit_systemChanged(const QString& value);
|
|
|
|
void vertical_speed_timeChanged(int value);
|
2019-01-18 07:07:00 +00:00
|
|
|
void vertical_speed_timeStringChanged(const QString& value);
|
2018-09-02 11:58:04 +00:00
|
|
|
void volumeChanged(int value);
|
2019-01-18 07:07:00 +00:00
|
|
|
void volumeStringChanged(const QString& value);
|
2018-09-02 11:58:04 +00:00
|
|
|
void weightChanged(int value);
|
2019-01-18 07:07:00 +00:00
|
|
|
void weightStringChanged(const QString& value);
|
2018-07-31 13:04:12 +00:00
|
|
|
private:
|
2018-09-14 10:25:18 +00:00
|
|
|
qPrefUnits() {}
|
|
|
|
|
2018-08-14 08:30:07 +00:00
|
|
|
static void disk_coordinates_traditional(bool doSync);
|
|
|
|
static void disk_duration_units(bool doSync);
|
|
|
|
static void disk_length(bool doSync);
|
|
|
|
static void disk_pressure(bool doSync);
|
|
|
|
static void disk_show_units_table(bool doSync);
|
|
|
|
static void disk_temperature(bool doSync);
|
|
|
|
static void disk_unit_system(bool doSync);
|
|
|
|
static void disk_vertical_speed_time(bool doSync);
|
|
|
|
static void disk_volume(bool doSync);
|
|
|
|
static void disk_weight(bool doSync);
|
2018-07-31 13:04:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|