1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// SPDX-License-Identifier: GPL-2.0
#include "qPrefUnit.h"
#include "qPrefPrivate.h"
static const QString group = QStringLiteral("Units");
qPrefUnits *qPrefUnits::instance()
{
static qPrefUnits *self = new qPrefUnits;
return self;
}
void qPrefUnits::loadSync(bool doSync)
{
disk_coordinates_traditional(doSync);
disk_duration_units(doSync);
disk_length(doSync);
disk_pressure(doSync);
disk_show_units_table(doSync);
disk_temperature(doSync);
disk_unit_system(doSync);
disk_vertical_speed_time(doSync);
disk_volume(doSync);
disk_weight(doSync);
}
HANDLE_PREFERENCE_BOOL(Units, "coordinates", coordinates_traditional);
SET_PREFERENCE_ENUM_EXT(Units, units::DURATION, duration_units, units.);
DISK_LOADSYNC_ENUM_EXT(Units, "duration_units", units::DURATION, duration_units, units.);
SET_PREFERENCE_ENUM_EXT(Units, units::LENGTH, length, units.);
DISK_LOADSYNC_ENUM_EXT(Units, "length", units::LENGTH, length, units.);
SET_PREFERENCE_ENUM_EXT(Units, units::PRESSURE, pressure, units.);
DISK_LOADSYNC_ENUM_EXT(Units, "pressure", units::PRESSURE, pressure, units.);
HANDLE_PREFERENCE_BOOL_EXT(Units, "show_units_table", show_units_table, units.);
SET_PREFERENCE_ENUM_EXT(Units, units::TEMPERATURE, temperature, units.);
DISK_LOADSYNC_ENUM_EXT(Units, "temperature", units::TEMPERATURE, temperature, units.);
void qPrefUnits::set_unit_system(unit_system_values value)
{
prefs.unit_system = value;
if (prefs.unit_system == METRIC) {
// make sure all types are updated when changing
set_volume(units::VOLUME::LITER);
set_weight(units::WEIGHT::KG);
set_length(units::LENGTH::METERS);
set_pressure(units::PRESSURE::BAR);
set_temperature(units::TEMPERATURE::CELSIUS);
// this statement need to be AFTER the setters are called
// because it sets all of prefs.units without calling the
// setters
prefs.units = SI_units;
} else if (prefs.unit_system == IMPERIAL) {
// make sure all types are updated when changing
set_volume(units::VOLUME::CUFT);
set_weight(units::WEIGHT::LBS);
set_length(units::LENGTH::FEET);
set_pressure(units::PRESSURE::PSI);
set_temperature(units::TEMPERATURE::FAHRENHEIT);
// this statement need to be AFTER the setters are called
// because it sets all of prefs.units without calling the
// setters
prefs.units = IMPERIAL_units;
}
disk_unit_system(true);
emit instance()->unit_systemChanged(value);
}
DISK_LOADSYNC_ENUM(Units, "unit_system", unit_system_values, unit_system);
SET_PREFERENCE_ENUM_EXT(Units, units::TIME, vertical_speed_time, units.);
DISK_LOADSYNC_ENUM_EXT(Units, "vertical_speed_time", units::TIME, vertical_speed_time, units.);
SET_PREFERENCE_ENUM_EXT(Units, units::VOLUME, volume, units.);
DISK_LOADSYNC_ENUM_EXT(Units, "volume", units::VOLUME, volume, units.);
SET_PREFERENCE_ENUM_EXT(Units, units::WEIGHT, weight, units.);
DISK_LOADSYNC_ENUM_EXT(Units, "weight", units::WEIGHT, weight, units.);
|