From 3bdf262068bfb6cf5bef58172447acfbc0f47001 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Tue, 24 Sep 2024 12:05:29 +0200 Subject: [PATCH] give raw time remaining estimate based on rate --- src/chat_gui4.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index 47f129b4..b348ae42 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -1042,11 +1042,16 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { float fraction = float(total) / total_size; - char overlay_buf[32]; + char overlay_buf[64]; if (rate > 0.000001f) { const char* byte_suffix = "???"; int64_t byte_divider = sizeToHumanReadable(rate, byte_suffix); - std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s", fraction * 100 + 0.01f, rate/byte_divider, byte_suffix); + int64_t seconds_remaining = (total_size - total) / rate; + if (seconds_remaining > 0) { + std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s %lds ", fraction * 100 + 0.01f, rate/byte_divider, byte_suffix, seconds_remaining); + } else { + std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s", fraction * 100 + 0.01f, rate/byte_divider, byte_suffix); + } } else { std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%%", fraction * 100 + 0.01f); }