From ed5a8059292c7743120fa4a089f92f4e84ee14b6 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Jun 2014 15:39:42 -0700 Subject: Fix tank size display In commit 11380a5deb07 ("Really display liters with script el") I inadvertantly broke the display of cylinder sizes in the imperial case. This patch restores that and also tries to give slightly more useful guidance on the number of decimals to display. Signed-off-by: Dirk Hohndel --- qt-gui.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'qt-gui.cpp') diff --git a/qt-gui.cpp b/qt-gui.cpp index f8b6b8637..52b26febd 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -281,6 +281,14 @@ QString get_volume_string(volume_t volume, bool showunit, int mbar) const char *unit; int decimals; double value = get_volume_units(volume.mliter, &decimals, &unit); + if (mbar) { + // we are showing a tank size + // fix the weird imperial way of denominating size and provide + // reasonable number of decimals + if (prefs.units.volume == units::CUFT) + value *= bar_to_atm(mbar / 1000.0); + decimals = (value > 20.0) ? 0 : (value > 2.0) ? 1 : 2; + } return QString("%1%2").arg(value, 0, 'f', decimals).arg(showunit ? unit : ""); } -- cgit v1.2.3-70-g09d2