Do display floating points with precision of 1

For several GB of quota, we might end up showing
<1% far too long. So show one decimal number,
unless it's zero.
This commit is contained in:
Daniel Molkentin 2013-07-10 09:22:04 +02:00
parent 4fde3f4a65
commit d2657bc154

View file

@ -465,18 +465,8 @@ void Application::slotRefreshQuotaDisplay( qint64 total, qint64 used )
return;
}
double percent = used/(double)total * 100;
QString percentFormatted;
// Don't display floating point numbers. Nobody cares.
if ((int)percent == 0) {
if (percent == .0) {
percentFormatted = QLatin1String("0");
} else {
percentFormatted = QLatin1String("<1");
}
} else {
percentFormatted = QString::number((int)percent);
}
double percent = used/(double)total*100;
QString percentFormatted = Utility::compactFormatDouble(percent, 1);
QString totalFormatted = Utility::octetsToString(total);
_actionQuota->setText(tr("%1% of %2 used").arg(percentFormatted).arg(totalFormatted));
}