DolphinQt: Make block size configurable in convert dialog

This commit is contained in:
JosJuice
2020-04-10 15:14:03 +02:00
parent acd00723ad
commit 466b2d7202
4 changed files with 86 additions and 7 deletions

View File

@ -453,7 +453,7 @@ void EnableScreenSaver(bool enable)
#endif
}
std::string FormatSize(u64 bytes)
std::string FormatSize(u64 bytes, int decimals)
{
// i18n: The symbol for the unit "bytes"
const char* const unit_symbols[] = {_trans("B"), _trans("KiB"), _trans("MiB"), _trans("GiB"),
@ -468,7 +468,7 @@ std::string FormatSize(u64 bytes)
// Don't need exact values, only 5 most significant digits
const double unit_size = std::pow(2, unit * 10);
std::ostringstream ss;
ss << std::fixed << std::setprecision(2);
ss << std::fixed << std::setprecision(decimals);
ss << bytes / unit_size << ' ' << Common::GetStringT(unit_symbols[unit]);
return ss.str();
}