mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-22 09:16:05 +03:00
COSMETIC: Display speeds with more user friendly units instead of always using KiB/s
This commit is contained in:
parent
c52e0cf841
commit
8b41d1973c
5 changed files with 9 additions and 8 deletions
|
@ -41,6 +41,7 @@
|
|||
- COSMETIC: Display Seeds and Peers in two separate columns
|
||||
- COSMETIC: New deletion confirmation dialog (Merged delete/delete permanently actions)
|
||||
- COSMETIC: Improved status bar layout spacing
|
||||
- COSMETIC: Display speeds with more user friendly units instead of always using KiB/s
|
||||
|
||||
* Thu Sep 3 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.5.0
|
||||
- FEATURE: Added Magnet URI support
|
||||
|
|
|
@ -157,14 +157,14 @@ public:
|
|||
// use Binary prefix standards from IEC 60027-2
|
||||
// see http://en.wikipedia.org/wiki/Kilobyte
|
||||
// value must be given in bytes
|
||||
static QString friendlyUnit(float val) {
|
||||
static QString friendlyUnit(double val) {
|
||||
if(val < 0)
|
||||
return tr("Unknown", "Unknown (size)");
|
||||
const QString units[5] = {tr("B", "bytes"), tr("KiB", "kibibytes (1024 bytes)"), tr("MiB", "mebibytes (1024 kibibytes)"), tr("GiB", "gibibytes (1024 mibibytes)"), tr("TiB", "tebibytes (1024 gibibytes)")};
|
||||
char i = 0;
|
||||
while(val > 1024. && i++<6)
|
||||
val /= 1024.;
|
||||
return QString(QByteArray::number(val, 'f', 1)) + units[(int)i];
|
||||
return QString(QByteArray::number(val, 'f', 1)) + " " + units[(int)i];
|
||||
}
|
||||
|
||||
static bool isPreviewable(QString extension){
|
||||
|
|
|
@ -306,11 +306,11 @@ void PropertiesWidget::loadDynamicData() {
|
|||
if(h.upload_limit() <= 0)
|
||||
lbl_uplimit->setText(tr("Unlimited"));
|
||||
else
|
||||
lbl_uplimit->setText(QString::number(h.upload_limit(), 'f', 1)+" "+tr("KiB/s"));
|
||||
lbl_uplimit->setText(misc::friendlyUnit(h.upload_limit())+tr("/s", "/second (i.e. per second)"));
|
||||
if(h.download_limit() <= 0)
|
||||
lbl_dllimit->setText(tr("Unlimited"));
|
||||
else
|
||||
lbl_dllimit->setText(QString::number(h.download_limit(), 'f', 1)+" "+tr("KiB/s"));
|
||||
lbl_dllimit->setText(misc::friendlyUnit(h.download_limit())+tr("/s", "/second (i.e. per second)"));
|
||||
QString elapsed_txt = misc::userFriendlyDuration(h.active_time());
|
||||
if(h.is_seed()) {
|
||||
elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")";
|
||||
|
|
|
@ -160,8 +160,8 @@ public slots:
|
|||
//statusSep1->setVisible(false);
|
||||
}
|
||||
// Update speed labels
|
||||
dlSpeedLbl->setText(tr("D: %1 KiB/s - T: %2", "Download speed: x KiB/s - Transferred: xMiB").arg(QString::number(sessionStatus.payload_download_rate/1024., 'f', 1)).arg(misc::friendlyUnit(sessionStatus.total_payload_download)));
|
||||
upSpeedLbl->setText(tr("U: %1 KiB/s - T: %2", "Upload speed: x KiB/s - Transferred: xMiB").arg(QString::number(sessionStatus.payload_upload_rate/1024., 'f', 1)).arg(misc::friendlyUnit(sessionStatus.total_payload_upload)));
|
||||
dlSpeedLbl->setText(tr("D: %1/s - T: %2", "Download speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_download_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_download)));
|
||||
upSpeedLbl->setText(tr("U: %1/s - T: %2", "Upload speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_upload_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_upload)));
|
||||
}
|
||||
|
||||
void capDownloadSpeed() {
|
||||
|
|
|
@ -112,9 +112,9 @@ public:
|
|||
case TR_UPSPEED:
|
||||
case TR_DLSPEED:{
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
double speed = index.data().toDouble();
|
||||
qulonglong speed = index.data().toULongLong();
|
||||
opt.displayAlignment = Qt::AlignRight;
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(speed/1024., 'f', 1)+" "+tr("KiB/s"));
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)"));
|
||||
break;
|
||||
}
|
||||
case TR_RATIO:{
|
||||
|
|
Loading…
Reference in a new issue