summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-12-24 19:13:16 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-10 15:57:39 -0800
commite61466e178e9062a7202f24f609baa12d21df5ea (patch)
tree0c043a75b65318596a3f31ef66f3ac7471030499
parent9c0b6436fd7d948e3b2ad191882ac36889c82179 (diff)
downloadsubsurface-e61466e178e9062a7202f24f609baa12d21df5ea.tar.gz
profile: turn static into member variable
When the settings change, the depth axis is redrawn to reflect metric/imperial units. To check whether the units changed, the old length unit is saved in a static variable. This makes no sense and allows for only one depth axis. Make this a normal member variable that is initialized in the constructor. Also remove the settingsChanged() call in the constructor, since this is a no-op (the depth unit is unchanged). Contains a whitespace fix. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--profile-widget/divecartesianaxis.cpp7
-rw-r--r--profile-widget/divecartesianaxis.h1
2 files changed, 4 insertions, 4 deletions
diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp
index 944b636cc..8ee74e7f1 100644
--- a/profile-widget/divecartesianaxis.cpp
+++ b/profile-widget/divecartesianaxis.cpp
@@ -361,17 +361,16 @@ QColor DepthAxis::colorForValue(double) const
return QColor(Qt::red);
}
-DepthAxis::DepthAxis(ProfileWidget2 *widget) : DiveCartesianAxis(widget)
+DepthAxis::DepthAxis(ProfileWidget2 *widget) : DiveCartesianAxis(widget),
+ unitSystem(prefs.units.length)
{
connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DepthAxis::settingsChanged);
changed = true;
- settingsChanged();
}
void DepthAxis::settingsChanged()
{
- static int unitSystem = prefs.units.length;
- if ( unitSystem == prefs.units.length )
+ if (unitSystem == prefs.units.length)
return;
changed = true;
updateTicks();
diff --git a/profile-widget/divecartesianaxis.h b/profile-widget/divecartesianaxis.h
index d22dc3e1f..a72e53f6c 100644
--- a/profile-widget/divecartesianaxis.h
+++ b/profile-widget/divecartesianaxis.h
@@ -84,6 +84,7 @@ public:
private:
QString textForValue(double value) const override;
QColor colorForValue(double value) const override;
+ int unitSystem;
private
slots:
void settingsChanged();