Settings update: Fix "Units"

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2016-08-10 14:10:38 -03:00 committed by Dirk Hohndel
parent b5e98ec993
commit 4f2057cd30

View file

@ -2,6 +2,7 @@
#include "ui_preferences_units.h" #include "ui_preferences_units.h"
#include "core/prefs-macros.h" #include "core/prefs-macros.h"
#include "core/qthelper.h" #include "core/qthelper.h"
#include "core/subsurface-qt/SettingsObjectWrapper.h"
#include <QSettings> #include <QSettings>
@ -44,17 +45,16 @@ void PreferencesUnits::refreshSettings()
void PreferencesUnits::syncSettings() void PreferencesUnits::syncSettings()
{ {
QSettings s; auto units = SettingsObjectWrapper::instance()->unit_settings;
s.beginGroup("Units");
QString unitSystem[] = {"metric", "imperial", "personal"}; QString unitSystem[] = {"metric", "imperial", "personal"};
short unitValue = ui->metric->isChecked() ? METRIC : (ui->imperial->isChecked() ? IMPERIAL : PERSONALIZE); short unitValue = ui->metric->isChecked() ? METRIC : (ui->imperial->isChecked() ? IMPERIAL : PERSONALIZE);
SAVE_OR_REMOVE_SPECIAL("unit_system", default_prefs.unit_system, unitValue, unitSystem[unitValue]);
s.setValue("temperature", ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS); units->setUnitSystem(unitSystem[unitValue]);
s.setValue("length", ui->feet->isChecked() ? units::FEET : units::METERS); units->setTemperature(ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS);
s.setValue("pressure", ui->psi->isChecked() ? units::PSI : units::BAR); units->setLength(ui->feet->isChecked() ? units::FEET : units::METERS);
s.setValue("volume", ui->cuft->isChecked() ? units::CUFT : units::LITER); units->setPressure(ui->psi->isChecked() ? units::PSI : units::BAR);
s.setValue("weight", ui->lbs->isChecked() ? units::LBS : units::KG); units->setVolume(ui->cuft->isChecked() ? units::CUFT : units::LITER);
s.setValue("vertical_speed_time", ui->vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS); units->setWeight(ui->lbs->isChecked() ? units::LBS : units::KG);
s.setValue("coordinates", ui->gpsTraditional->isChecked()); units->setVerticalSpeedTime(ui->vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS);
s.endGroup(); units->setCoordinatesTraditional(ui->gpsTraditional->isChecked());
} }