diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-04-30 02:54:37 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-04-30 02:54:37 +0200 |
commit | 794102b32cb9b9c0ddb0c8268c572acb256dd6ba (patch) | |
tree | 86aff77c02ee18479cb18da035ae70d0a5c8e758 /api/logic/net/NetJob.cpp | |
parent | 1be99b075ab1911e65a165e3b47513a3a8e290f3 (diff) | |
download | MultiMC-794102b32cb9b9c0ddb0c8268c572acb256dd6ba.tar MultiMC-794102b32cb9b9c0ddb0c8268c572acb256dd6ba.tar.gz MultiMC-794102b32cb9b9c0ddb0c8268c572acb256dd6ba.tar.lz MultiMC-794102b32cb9b9c0ddb0c8268c572acb256dd6ba.tar.xz MultiMC-794102b32cb9b9c0ddb0c8268c572acb256dd6ba.zip |
NOISSUE less jumpy download progress bars and redirect URL fix
Diffstat (limited to 'api/logic/net/NetJob.cpp')
-rw-r--r-- | api/logic/net/NetJob.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/api/logic/net/NetJob.cpp b/api/logic/net/NetJob.cpp index cf04998f..ff2c711b 100644 --- a/api/logic/net/NetJob.cpp +++ b/api/logic/net/NetJob.cpp @@ -69,14 +69,16 @@ void NetJob::partProgress(qint64 bytesReceived, qint64 bytesTotal) void NetJob::setPartProgress(int index, qint64 bytesReceived, qint64 bytesTotal) { auto &slot = m_parts[index]; - - current_progress -= slot.current_progress; slot.current_progress = bytesReceived; - current_progress += slot.current_progress; - - total_progress -= slot.total_progress; slot.total_progress = bytesTotal; - total_progress += slot.total_progress; + qint64 current_progress = m_done.count() * 100; + qint64 total_progress = m_parts.count() * 100; + for(auto iter = m_doing.begin(); iter != m_doing.end(); iter++) + { + auto &part = m_parts[*iter]; + float percentage = (float(part.current_progress) / float(part.total_progress)) * 100.0f; + current_progress += (qint64) percentage; + } setProgress(current_progress, total_progress); } @@ -196,14 +198,8 @@ void NetJob::addNetAction(NetActionPtr action) } m_parts.append(pi); - total_progress += pi.total_progress; - current_progress += pi.current_progress; - - // if this is already running, the action needs to be started right away! if (isRunning()) { - setProgress(current_progress, total_progress); - connectAction(action.get()); - action->start(); + m_todo.enqueue(m_parts.size() - 1); } } |