summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Jocke <j.bygdell@gmail.com>2018-09-18 17:22:01 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-19 14:41:34 -0700
commit148bc8fbf192c42c25e7f7897384e6fbc6562267 (patch)
treee7e9c682da098c126d15a7d9d93d4bee076048fc /core
parent09e7fdc253aefcd05b2133d0745dceba34955247 (diff)
downloadsubsurface-148bc8fbf192c42c25e7f7897384e6fbc6562267.tar.gz
Mobile: always update the preferences when set_unit_system is called
Unit_system is read from git storage but units are set from locale when the app starts. To prevent a miss-match between unit and unit_system we have to always update the preferences variable when set_unit_system is called so that the user doesn't end up with imperial units when the preferences say metric. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r--core/settings/qPrefUnit.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/core/settings/qPrefUnit.cpp b/core/settings/qPrefUnit.cpp
index ec50f7da3..d8e1911eb 100644
--- a/core/settings/qPrefUnit.cpp
+++ b/core/settings/qPrefUnit.cpp
@@ -53,19 +53,17 @@ void qPrefUnits::set_unit_system(const QString& value)
short int v = value == QStringLiteral("metric") ? METRIC :
value == QStringLiteral("imperial")? IMPERIAL :
PERSONALIZE;
- if (v != prefs.unit_system) {
- if (v == METRIC) {
- prefs.unit_system = METRIC;
- prefs.units = SI_units;
- } else if (v == IMPERIAL) {
- prefs.unit_system = IMPERIAL;
- prefs.units = IMPERIAL_units;
- } else {
- prefs.unit_system = PERSONALIZE;
- }
- disk_unit_system(true);
- emit instance()->unit_systemChanged(value);
+ if (v == METRIC) {
+ prefs.unit_system = METRIC;
+ prefs.units = SI_units;
+ } else if (v == IMPERIAL) {
+ prefs.unit_system = IMPERIAL;
+ prefs.units = IMPERIAL_units;
+ } else {
+ prefs.unit_system = PERSONALIZE;
}
+ disk_unit_system(true);
+ emit instance()->unit_systemChanged(value);
}
DISK_LOADSYNC_ENUM(Units, "unit_system", unit_system_values, unit_system);