aboutsummaryrefslogtreecommitdiff
path: root/launcher/net
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-04-01 10:41:07 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2023-05-01 10:48:00 -0700
commitcdccb25fe30cdf772ffdbf73b6c283c98f152075 (patch)
tree13da605dd5ef83544c3e1356d3e1d329a7f6f8e4 /launcher/net
parentb6452215c16f6b1ee45fea746f9498767e48d049 (diff)
downloadPrismLauncher-cdccb25fe30cdf772ffdbf73b6c283c98f152075.tar.gz
PrismLauncher-cdccb25fe30cdf772ffdbf73b6c283c98f152075.tar.bz2
PrismLauncher-cdccb25fe30cdf772ffdbf73b6c283c98f152075.zip
feat: add download size to download details alongside speed
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/net')
-rw-r--r--launcher/net/Download.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp
index 86e4bd97..e7536dc9 100644
--- a/launcher/net/Download.cpp
+++ b/launcher/net/Download.cpp
@@ -52,6 +52,7 @@
#include "Application.h"
#include "logging.h"
+#include "net/NetAction.h"
namespace Net {
@@ -190,13 +191,23 @@ void Download::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
auto now = m_clock.now();
auto elapsed = now - m_last_progress_time;
+
+ // use milliseconds for speed precision
auto elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count();
auto bytes_recived_since = bytesReceived - m_last_progress_bytes;
+
+ // current bytes out of total bytes
+ QString dl_progress = tr("%1 / %2").arg(humanReadableFileSize(bytesReceived)).arg(humanReadableFileSize(bytesTotal));
+
+ QString dl_speed;
if (elapsed_ms > 0) {
- setDetails(humanReadableFileSize(bytes_recived_since / elapsed_ms * 1000) + "/s");
+ // bytes per second
+ dl_speed = tr("%1/s").arg(humanReadableFileSize(bytes_recived_since / elapsed_ms * 1000));
} else {
- setDetails("0 b/s");
- }
+ dl_speed = tr("0 b/s");
+ }
+
+ setDetails(dl_progress + "\n" + dl_speed);
setProgress(bytesReceived, bytesTotal);
}