blob: 2717688a6fc0fff1868d4f5616a0b78f95515947 (
plain) (
blame)
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
|
// SPDX-License-Identifier: GPL-2.0
#include "preferences_units.h"
#include "ui_preferences_units.h"
#include "core/prefs-macros.h"
#include "core/qthelper.h"
#include "core/subsurface-qt/SettingsObjectWrapper.h"
PreferencesUnits::PreferencesUnits(): AbstractPreferencesWidget(tr("Units"),QIcon(":units"),1), ui(new Ui::PreferencesUnits())
{
ui->setupUi(this);
}
PreferencesUnits::~PreferencesUnits()
{
}
void PreferencesUnits::refreshSettings()
{
switch(prefs.unit_system) {
case METRIC: ui->metric->setChecked(true); break;
case IMPERIAL: ui->imperial->setChecked(true); break;
default: ui->personalize->setChecked(true); break;
}
ui->gpsTraditional->setChecked(prefs.coordinates_traditional);
ui->gpsDecimal->setChecked(!prefs.coordinates_traditional);
ui->celsius->setChecked(prefs.units.temperature == units::CELSIUS);
ui->fahrenheit->setChecked(prefs.units.temperature == units::FAHRENHEIT);
ui->meter->setChecked(prefs.units.length == units::METERS);
ui->feet->setChecked(prefs.units.length == units::FEET);
ui->bar->setChecked(prefs.units.pressure == units::BAR);
ui->psi->setChecked(prefs.units.pressure == units::PSI);
ui->liter->setChecked(prefs.units.volume == units::LITER);
ui->cuft->setChecked(prefs.units.volume == units::CUFT);
ui->kg->setChecked(prefs.units.weight == units::KG);
ui->lbs->setChecked(prefs.units.weight == units::LBS);
ui->units_group->setEnabled(ui->personalize->isChecked());
ui->vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
ui->vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
}
void PreferencesUnits::syncSettings()
{
auto units = SettingsObjectWrapper::instance()->unit_settings;
QString unitSystem[] = {"metric", "imperial", "personal"};
short unitValue = ui->metric->isChecked() ? METRIC : (ui->imperial->isChecked() ? IMPERIAL : PERSONALIZE);
units->setUnitSystem(unitSystem[unitValue]);
units->setTemperature(ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS);
units->setLength(ui->feet->isChecked() ? units::FEET : units::METERS);
units->setPressure(ui->psi->isChecked() ? units::PSI : units::BAR);
units->setVolume(ui->cuft->isChecked() ? units::CUFT : units::LITER);
units->setWeight(ui->lbs->isChecked() ? units::LBS : units::KG);
units->setVerticalSpeedTime(ui->vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS);
units->setCoordinatesTraditional(ui->gpsTraditional->isChecked());
}
|