Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit usage #245

Merged
merged 2 commits into from
Sep 13, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions qt/progressdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ void ProgressDialog::setValue(float current)

void ProgressDialog::setSpeed(qint64 speed)
{
static constexpr double Kb = 1000;
static constexpr double Mb = 1000 * Kb; //haha
static constexpr double Gb = 1000 * Mb;
if (speed < 2 * Mb)
ui->speedLabel->setText(tr("Speed: %1 Kb/s").arg(speed / Kb, 0, 'f', 1));
else if (speed < 2 * Gb)
ui->speedLabel->setText(tr("Speed: %1 Mb/s").arg(speed / Mb, 0, 'f', 1));
static constexpr double kB = 1000;
static constexpr double MB = 1000 * kB; // k, M, G are metric prefixes
static constexpr double GB = 1000 * MB; // 1024 is for binary prefixes
if (speed < 2 * MB)
ui->speedLabel->setText(tr("Speed: %1 kB/s").arg(speed / kB, 0, 'f', 1));
huupoke12 marked this conversation as resolved.
Show resolved Hide resolved
else if (speed < 2 * GB)
ui->speedLabel->setText(tr("Speed: %1 MB/s").arg(speed / MB, 0, 'f', 1));
else
ui->speedLabel->setText(tr("Speed: %1 Gb/s").arg(speed / Gb, 0, 'f', 1));
ui->speedLabel->setText(tr("Speed: %1 GB/s").arg(speed / GB, 0, 'f', 1));
}

void ProgressDialog::setFilename(const QString &filename)
Expand Down