On 22.03.2016, at 19:45, Robert C. Helling <[email protected]> wrote:

Yesterday, I filed two bugs that should easily be fixed: 

Make the reserve of recreational mode units aware and warn when running as root. 

here is the patch that fixes the first:

From 7727d83b46c6522add245cc05f86eb2295108987 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Tue, 22 Mar 2016 23:44:59 +0100
Subject: [PATCH] Make the reserve gas units aware
To: [email protected]

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

Signed-off-by: Robert C. Helling <[email protected]>
---
 desktop-widgets/diveplanner.cpp | 13 ++++++++++++-
 qt-models/diveplannermodel.cpp  |  5 ++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index e6fe612..32797f0 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/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(5000);
+               ui.reserve_gas->setValue(prefs.reserve_gas / 1000);
+       } else {
+               ui.reserve_gas->setSuffix(tr("psi"));
+               ui.reserve_gas->setSingleStep(1);
+               ui.reserve_gas->setMaximum(5000);
+               ui.reserve_gas->setValue(mbar_to_PSI(prefs.reserve_gas));
+       }
+
        ui.bottomSAC->blockSignals(false);
        ui.decoStopSAC->blockSignals(false);
        updateUnitsUI();
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index f7570fd..c3996d0 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -481,7 +481,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));
 }
 
-- 
2.5.4 (Apple Git-61)

While working on this, I found two more problems for which right now I don’t have time to fix them, so I created two tickets.

Best
Robert

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to