diff options
author | Robert C. Helling <helling@atdotde.de> | 2016-03-22 23:44:59 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-03-22 16:32:39 -0700 |
commit | e167506bdbdd3534372f5c3be12c50250ff0fd3a (patch) | |
tree | 756b5b46c882b6acefb080d202226bb02c5aeea5 | |
parent | 0d080f32491ed57ca61bfb9250d2033513ad8b89 (diff) | |
download | subsurface-e167506bdbdd3534372f5c3be12c50250ff0fd3a.tar.gz |
Make the reserve gas units aware
In the planner, for recreational mode, there is a setting indicating
the pressure at which the diver should be back at the surface. This
pressure was hardcoded to bar.
Fixes #1027
[Dirk Hohndel: small modifications, more reasonable step for psi,
more reasonable maxima]
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-models/diveplannermodel.cpp | 5 | ||||
-rw-r--r-- | qt-ui/diveplanner.cpp | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 70a7c6f62..91144c2ba 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -479,7 +479,10 @@ void DivePlannerPointsModel::setSafetyStop(bool value) void DivePlannerPointsModel::setReserveGas(int reserve) { - prefs.reserve_gas = reserve * 1000; + if (prefs.units.pressure == units::BAR) + prefs.reserve_gas = reserve * 1000; + else + prefs.reserve_gas = psi_to_mbar(reserve); emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); } diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index b4413d11a..c6bb555c0 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -306,7 +306,6 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) ui.display_runtime->setChecked(prefs.display_runtime); ui.display_transitions->setChecked(prefs.display_transitions); ui.safetystop->setChecked(prefs.safetystop); - ui.reserve_gas->setValue(prefs.reserve_gas / 1000); ui.bottompo2->setValue(prefs.bottompo2 / 1000.0); ui.decopo2->setValue(prefs.decopo2 / 1000.0); ui.backgasBreaks->setChecked(prefs.doo2breaks); @@ -448,6 +447,18 @@ void PlannerSettingsWidget::settingsChanged() ui.bottomSAC->setValue((double) prefs.bottomsac / 1000.0); ui.decoStopSAC->setValue((double) prefs.decosac / 1000.0); } + if(get_units()->pressure == units::BAR) { + ui.reserve_gas->setSuffix(tr("bar")); + ui.reserve_gas->setSingleStep(1); + ui.reserve_gas->setMaximum(100); + ui.reserve_gas->setValue(prefs.reserve_gas / 1000); + } else { + ui.reserve_gas->setSuffix(tr("psi")); + ui.reserve_gas->setSingleStep(10); + ui.reserve_gas->setMaximum(1500); + ui.reserve_gas->setValue(mbar_to_PSI(prefs.reserve_gas)); + } + ui.bottomSAC->blockSignals(false); ui.decoStopSAC->blockSignals(false); updateUnitsUI(); |