diff options
| author | Al12rs <gabriel.cortesi@outlook.com> | 2018-07-16 14:18:25 +0200 |
|---|---|---|
| committer | Al12rs <gabriel.cortesi@outlook.com> | 2018-07-16 14:18:25 +0200 |
| commit | 5efddbd5156f914de9406775f06111b899060177 (patch) | |
| tree | c4f8076b471907e2534b891c859a566112a2f7e5 | |
| parent | 181de232f43941b5ffefbccca78a6076e1e854a9 (diff) | |
Chnged download speed to be a little more consistant in display, to avoid the progrss bar jumping around all the time. Chnaged the kb->MB jumps to happen at 1000 instead of 1024 to avoid going in the 4 digits, but still divide by 1024 to keep units acuurate.
| -rw-r--r-- | src/downloadmanager.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 6d8658c9..9761fee4 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -64,7 +64,7 @@ DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createNew(const Mo info->m_DownloadID = s_NextDownloadID++;
info->m_StartTime.start();
info->m_PreResumeSize = 0LL;
- info->m_Progress = std::make_pair<int, QString>(0, "0 bytes/sec");
+ info->m_Progress = std::make_pair<int, QString>(0, " 0.0 Bytes/s ");
info->m_ResumePos = 0;
info->m_FileInfo = new ModRepositoryFileInfo(*fileInfo);
info->m_Urls = URLs;
@@ -1277,19 +1277,19 @@ void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) double speed = (std::get<4>(info->m_SpeedDiff) * 1000.0) / (5 * 1000);
QString unit;
- if (speed < 1024) {
- unit = "bytes/sec";
+ if (speed < 1000) {
+ unit = "Bytes/s";
}
- else if (speed < 1024 * 1024) {
+ else if (speed/1024 < 1000) {
speed /= 1024;
- unit = "kB/s";
+ unit = "KB/s";
}
else {
speed /= 1024 * 1024;
unit = "MB/s";
}
- info->m_Progress.second = QString::fromLatin1("%1% - %2 %3").arg(info->m_Progress.first).arg(speed, 3, 'f', 1).arg(unit);
+ info->m_Progress.second = QString::fromLatin1("%1% - %2 %3").arg(info->m_Progress.first).arg(speed, 8, 'f', 1,' ').arg(unit, -8, ' ');
TaskProgressManager::instance().updateProgress(info->m_TaskProgressId, bytesReceived, bytesTotal);
emit update(index);
|
