mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Fix tank size display
In commit 11380a5deb
("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 <dirk@hohndel.org>
This commit is contained in:
parent
1b2d3c29d3
commit
ed5a805929
1 changed files with 8 additions and 0 deletions
|
@ -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 : "");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue