mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
347a002923
commit
80be2b570b
2 changed files with 22 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "plannershared.h"
|
#include "plannershared.h"
|
||||||
#include "core/settings/qPrefDivePlanner.h"
|
#include "core/settings/qPrefDivePlanner.h"
|
||||||
#include "core/settings/qPrefTechnicalDetails.h"
|
#include "core/settings/qPrefTechnicalDetails.h"
|
||||||
|
#include "core/settings/qPrefUnit.h"
|
||||||
#include "qt-models/diveplannermodel.h"
|
#include "qt-models/diveplannermodel.h"
|
||||||
#include "qt-models/cylindermodel.h"
|
#include "qt-models/cylindermodel.h"
|
||||||
|
|
||||||
|
@ -10,6 +11,12 @@ plannerShared *plannerShared::instance()
|
||||||
static plannerShared *self = new plannerShared;
|
static plannerShared *self = new plannerShared;
|
||||||
return self;
|
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
|
// 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)
|
#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);
|
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());
|
||||||
|
}
|
||||||
|
|
|
@ -174,8 +174,11 @@ signals:
|
||||||
void verbatim_planChanged(bool value);
|
void verbatim_planChanged(bool value);
|
||||||
void display_variationsChanged(bool value);
|
void display_variationsChanged(bool value);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
static void unit_lengthChangedSlot(int value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
plannerShared() {}
|
plannerShared();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLANNERSHARED_H
|
#endif // PLANNERSHARED_H
|
||||||
|
|
Loading…
Reference in a new issue