diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index d3cd951d8..e04d824fb 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -376,11 +376,17 @@ void MainWindow::readSettings() settings.endGroup(); settings.beginGroup("Units"); - GET_UNIT(v, "length", length, units::FEET, units::METERS); - GET_UNIT(v, "pressure", pressure, units::PSI, units::BAR); - GET_UNIT(v, "volume", volume, units::CUFT, units::LITER); - GET_UNIT(v, "temperature", temperature, units::FAHRENHEIT, units::CELSIUS); - GET_UNIT(v, "weight", weight, units::LBS, units::KG); + if (settings.value("unit_system").toString() == "metric") { + prefs.units = SI_units; + } else if (settings.value("unit_system").toString() == "imperial") { + prefs.units = IMPERIAL_units; + } else { + GET_UNIT(v, "length", length, units::FEET, units::METERS); + GET_UNIT(v, "pressure", pressure, units::PSI, units::BAR); + GET_UNIT(v, "volume", volume, units::CUFT, units::LITER); + GET_UNIT(v, "temperature", temperature, units::FAHRENHEIT, units::CELSIUS); + GET_UNIT(v, "weight", weight, units::LBS, units::KG); + } settings.endGroup(); settings.beginGroup("DisplayListColumns"); GET_BOOL(v, "CYLINDER", prefs.visible_cols.cylinder); diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index dd484b6e8..551d7965a 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -1,6 +1,7 @@ #include "preferences.h" #include "ui_preferences.h" #include +#include PreferencesDialog* PreferencesDialog::instance() { @@ -43,6 +44,7 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial ui->increment_3m->setChecked(B(calcceiling3m, calc_ceiling_3m_incr)); ui->all_tissues->setEnabled(ui->calculated_ceiling->isChecked()); ui->all_tissues->setChecked(B(calcalltissues, calc_all_tissues)); + ui->groupBox->setEnabled(ui->personalize->isChecked()); ui->gflow->setValue((int)(I(gflow, gflow))); ui->gfhigh->setValue((int)(I(gfhigh, gfhigh))); @@ -121,7 +123,8 @@ void PreferencesDialog::syncSettings() // Units s.beginGroup("Units"); - s.setValue("units_metric", ui->metric->isChecked()); + QString unitSystem = ui->metric->isChecked() ? "metric" : (ui->imperial->isChecked() ? "imperial" : "personal"); + s.setValue("unit_system", unitSystem); s.setValue("temperature", ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS); s.setValue("length", ui->feet->isChecked() ? units::FEET : units::METERS); s.setValue("pressure", ui->psi->isChecked() ? units::PSI : units::BAR); diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui index 3cef8785a..07a423834 100644 --- a/qt-ui/preferences.ui +++ b/qt-ui/preferences.ui @@ -116,7 +116,7 @@ - 2 + 1 @@ -224,6 +224,9 @@ Metric + + buttonGroup_6 + @@ -231,6 +234,19 @@ Imperial + + buttonGroup_6 + + + + + + + Personalize + + + buttonGroup_6 + @@ -238,10 +254,10 @@ - Personalize + - true + false false @@ -948,6 +964,22 @@ + + personalize + toggled(bool) + groupBox + setEnabled(bool) + + + 613 + 41 + + + 634 + 72 + + + @@ -955,5 +987,6 @@ +