summaryrefslogtreecommitdiffstats
path: root/core/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2018-02-19 21:55:18 +0100
committerGravatar Robert C. Helling <helling@atdotde.de>2018-03-05 16:28:18 +0100
commitaacc6886705e720809d253d22e0f6f49444993e0 (patch)
tree4d8026cae13f8706d2bb904f7115089d60a7d603 /core/qthelper.cpp
parent18c034ea37f830880e4cbf3636819c6be43d0464 (diff)
downloadsubsurface-aacc6886705e720809d253d22e0f6f49444993e0.tar.gz
Use correct numeric format based on selected locale (Qt domain part)
This changes the numeric format of many values printed to the UI to reflect the correct numeric format of the selected locale: - dot or comma as decimal separator - comma or dot as thousands separator In the Qt domain the `L` flag is used case specific mostly in qthelper.cpp. Then the helper functions get_xxx_string() are used more consistently. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r--core/qthelper.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index d012e2d29..798d98c20 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -46,10 +46,10 @@ QString weight_string(int weight_in_grams)
QString str;
if (get_units()->weight == units::KG) {
double kg = (double) weight_in_grams / 1000.0;
- str = QString("%1").arg(kg, 0, 'f', kg >= 20.0 ? 0 : 1);
+ str = QString("%L1").arg(kg, 0, 'f', kg >= 20.0 ? 0 : 1);
} else {
double lbs = grams_to_lbs(weight_in_grams);
- str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1);
+ str = QString("%L1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1);
}
return str;
}
@@ -582,10 +582,10 @@ QString get_depth_string(int mm, bool showunit, bool showdecimal)
{
if (prefs.units.length == units::METERS) {
double meters = mm / 1000.0;
- return QString("%1%2").arg(meters, 0, 'f', (showdecimal && meters < 20.0) ? 1 : 0).arg(showunit ? translate("gettextFromC", "m") : "");
+ return QString("%L1%2").arg(meters, 0, 'f', (showdecimal && meters < 20.0) ? 1 : 0).arg(showunit ? translate("gettextFromC", "m") : "");
} else {
double feet = mm_to_feet(mm);
- return QString("%1%2").arg(feet, 0, 'f', 0).arg(showunit ? translate("gettextFromC", "ft") : "");
+ return QString("%L1%2").arg(feet, 0, 'f', 0).arg(showunit ? translate("gettextFromC", "ft") : "");
}
}
@@ -627,10 +627,10 @@ QString get_temperature_string(temperature_t temp, bool showunit)
return ""; //temperature not defined
} else if (prefs.units.temperature == units::CELSIUS) {
double celsius = mkelvin_to_C(temp.mkelvin);
- return QString("%1%2%3").arg(celsius, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE) : "").arg(showunit ? translate("gettextFromC", "C") : "");
+ return QString("%L1%2%3").arg(celsius, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE) : "").arg(showunit ? translate("gettextFromC", "C") : "");
} else {
double fahrenheit = mkelvin_to_F(temp.mkelvin);
- return QString("%1%2%3").arg(fahrenheit, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE) : "").arg(showunit ? translate("gettextFromC", "F") : "");
+ return QString("%L1%2%3").arg(fahrenheit, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE) : "").arg(showunit ? translate("gettextFromC", "F") : "");
}
}
@@ -642,12 +642,17 @@ QString get_temp_unit()
return QString(UTF8_DEGREE "F");
}
-QString get_volume_string(volume_t volume, bool showunit)
+QString get_volume_string(int mliter, bool showunit)
{
const char *unit;
int decimals;
- double value = get_volume_units(volume.mliter, &decimals, &unit);
- return QString("%1%2").arg(value, 0, 'f', decimals).arg(showunit ? unit : "");
+ double value = get_volume_units(mliter, &decimals, &unit);
+ return QString("%L1%2").arg(value, 0, 'f', decimals).arg(showunit ? unit : "");
+}
+
+QString get_volume_string(volume_t volume, bool showunit)
+{
+ return get_volume_string(volume.mliter, showunit);
}
QString get_volume_unit()
@@ -661,10 +666,10 @@ QString get_pressure_string(pressure_t pressure, bool showunit)
{
if (prefs.units.pressure == units::BAR) {
double bar = pressure.mbar / 1000.0;
- return QString("%1%2").arg(bar, 0, 'f', 1).arg(showunit ? translate("gettextFromC", "bar") : "");
+ return QString("%L1%2").arg(bar, 0, 'f', 1).arg(showunit ? translate("gettextFromC", "bar") : "");
} else {
double psi = mbar_to_PSI(pressure.mbar);
- return QString("%1%2").arg(psi, 0, 'f', 0).arg(showunit ? translate("gettextFromC", "psi") : "");
+ return QString("%L1%2").arg(psi, 0, 'f', 0).arg(showunit ? translate("gettextFromC", "psi") : "");
}
}