summaryrefslogtreecommitdiffstats
path: root/backend-shared
diff options
context:
space:
mode:
authorGravatar jan Iversen <jan@casacondor.com>2020-01-02 11:55:27 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-01-04 10:56:55 -0800
commit80be2b570b81ff5997f9412fd1206164c60e5b36 (patch)
tree6da31a36b71a102e638a57cdfe08cae2b4279177 /backend-shared
parent347a002923978f39d6252eb136403588f369a8d2 (diff)
downloadsubsurface-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')
-rw-r--r--backend-shared/plannershared.cpp18
-rw-r--r--backend-shared/plannershared.h5
2 files changed, 22 insertions, 1 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());
+}
diff --git a/backend-shared/plannershared.h b/backend-shared/plannershared.h
index 33c280aa2..4add244a2 100644
--- a/backend-shared/plannershared.h
+++ b/backend-shared/plannershared.h
@@ -174,8 +174,11 @@ signals:
void verbatim_planChanged(bool value);
void display_variationsChanged(bool value);
+private slots:
+ static void unit_lengthChangedSlot(int value);
+
private:
- plannerShared() {}
+ plannerShared();
};
#endif // PLANNERSHARED_H