diff options
author | jan Iversen <jan@casacondor.com> | 2020-01-02 11:55:27 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-01-04 10:56:55 -0800 |
commit | 80be2b570b81ff5997f9412fd1206164c60e5b36 (patch) | |
tree | 6da31a36b71a102e638a57cdfe08cae2b4279177 /backend-shared/plannershared.cpp | |
parent | 347a002923978f39d6252eb136403588f369a8d2 (diff) | |
download | subsurface-80be2b570b81ff5997f9412fd1206164c60e5b36.tar.gz |
backend-shared: add slot to detect switch METER <-> FEET
This allows to update plannermodel etc. and thus avoiding a restart when
changing units for length.
Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'backend-shared/plannershared.cpp')
-rw-r--r-- | backend-shared/plannershared.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/backend-shared/plannershared.cpp b/backend-shared/plannershared.cpp index d516e96b7..f4d21fa21 100644 --- a/backend-shared/plannershared.cpp +++ b/backend-shared/plannershared.cpp @@ -2,6 +2,7 @@ #include "plannershared.h" #include "core/settings/qPrefDivePlanner.h" #include "core/settings/qPrefTechnicalDetails.h" +#include "core/settings/qPrefUnit.h" #include "qt-models/diveplannermodel.h" #include "qt-models/cylindermodel.h" @@ -10,6 +11,12 @@ plannerShared *plannerShared::instance() static plannerShared *self = new plannerShared; return self; } +plannerShared::plannerShared() +{ + // Be informed when user switches METER <-> FEET + connect(qPrefUnits::instance(), &qPrefUnits::lengthChanged, this, &unit_lengthChangedSlot); +} + // Used to convert between meter/feet and keep the qPref variables independent #define TO_MM_BY_SEC ((prefs.units.length == units::METERS) ? 1000.0 / 60.0 : feet_to_mm(1) / 60.0) @@ -301,3 +308,14 @@ void plannerShared::set_display_variations(bool value) { DivePlannerPointsModel::instance()->setDisplayVariations(value); } + +// Handle when user changes length measurement type +void plannerShared::unit_lengthChangedSlot(int value) +{ + // Provoke recalculation of model and send of signals + set_ascratelast6m(ascratelast6m()); + set_ascratestops(ascratestops()); + set_ascrate50(ascrate50()); + set_ascrate75(ascrate75()); + set_descrate(descrate()); +} |