mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 09:13:08 -07:00
Increased number of digits after the decimal point for Gibibytes and above
This commit is contained in:
parent
bec4617128
commit
311b060c70
2 changed files with 10 additions and 1 deletions
|
@ -358,12 +358,20 @@ QString Utils::Misc::friendlyUnit(qint64 bytesValue, bool isSpeed)
|
||||||
if (unit == SizeUnit::Byte)
|
if (unit == SizeUnit::Byte)
|
||||||
ret = QString::number(bytesValue) + " " + unitString(unit);
|
ret = QString::number(bytesValue) + " " + unitString(unit);
|
||||||
else
|
else
|
||||||
ret = Utils::String::fromDouble(friendlyVal, 1) + " " + unitString(unit);
|
ret = Utils::String::fromDouble(friendlyVal, friendlyUnitPrecision(unit)) + " " + unitString(unit);
|
||||||
if (isSpeed)
|
if (isSpeed)
|
||||||
ret += QCoreApplication::translate("misc", "/s", "per second");
|
ret += QCoreApplication::translate("misc", "/s", "per second");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Utils::Misc::friendlyUnitPrecision(SizeUnit unit)
|
||||||
|
{
|
||||||
|
// friendlyUnit's number of digits after the decimal point
|
||||||
|
if (unit <= SizeUnit::MebiByte) return 1;
|
||||||
|
else if (unit == SizeUnit::GibiByte) return 2;
|
||||||
|
else return 3;
|
||||||
|
}
|
||||||
|
|
||||||
qlonglong Utils::Misc::sizeInBytes(qreal size, Utils::Misc::SizeUnit unit)
|
qlonglong Utils::Misc::sizeInBytes(qreal size, Utils::Misc::SizeUnit unit)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < static_cast<int>(unit); ++i)
|
for (int i = 0; i < static_cast<int>(unit); ++i)
|
||||||
|
|
|
@ -88,6 +88,7 @@ namespace Utils
|
||||||
// value must be given in bytes
|
// value must be given in bytes
|
||||||
bool friendlyUnit(qint64 sizeInBytes, qreal& val, SizeUnit& unit);
|
bool friendlyUnit(qint64 sizeInBytes, qreal& val, SizeUnit& unit);
|
||||||
QString friendlyUnit(qint64 bytesValue, bool isSpeed = false);
|
QString friendlyUnit(qint64 bytesValue, bool isSpeed = false);
|
||||||
|
int friendlyUnitPrecision(SizeUnit unit);
|
||||||
qint64 sizeInBytes(qreal size, SizeUnit unit);
|
qint64 sizeInBytes(qreal size, SizeUnit unit);
|
||||||
|
|
||||||
bool isPreviewable(const QString& extension);
|
bool isPreviewable(const QString& extension);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue