diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7064c6885..19ce948c5 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -243,6 +243,7 @@ Lee Doughty <32392044+leedoughty@users.noreply.github.com> memchr Max Romanowski Aldlss +Matbe766 INT32_MAX) + if self._use_kb: + scaled_max = (max + 1023) // 1024 # ceil(bytes/1024) -> kB + # scaled_max will be ~2M for a 2 GiB upload; well under INT32 + self._win.form.progressBar.setRange(0, int(scaled_max)) + else: + self._win.form.progressBar.setMinimum(min) + self._win.form.progressBar.setMaximum(max) + self._win.form.progressBar.setTextVisible(False) self._win.form.label.setText(label) self._win.setWindowTitle(title) @@ -222,9 +236,31 @@ class ProgressManager: self._win.form.label.setText(label) self._max = max or 0 - self._win.form.progressBar.setMaximum(self._max) - if self._max: + # Unknown/zero max -> indeterminate (Qt "busy" mode) + if not self._max or self._max <= 0: + self._win.form.progressBar.setRange(0, 0) + return + + # If max is larger than int32, normalize both value and max to kilobytes + if self._max > INT32_MAX: + self._use_kb = True + # update our internal counter as before (value or auto-increment) self._counter = value if value is not None else (self._counter + 1) + + scaled_max = (self._max + 1023) // 1024 # ceil bytes->kB + scaled_val = (self._counter + 1023) // 1024 + + scaled_val = min(scaled_val, scaled_max) + + # kB are safely within 32-bit limits for realistic uploads + self._win.form.progressBar.setRange(0, int(scaled_max)) + self._win.form.progressBar.setValue(int(scaled_val)) + else: + # Small totals: keep exact byte counts (legacy behavior) + self._win.form.progressBar.setRange(0, int(self._max)) + self._counter = value if value is not None else (self._counter + 1) + self._counter = min(self._counter, self._max) + self._win.form.progressBar.setValue(self._counter) def finish(self) -> None: