diff --git a/onionshare_gui/tab/mode/history.py b/onionshare_gui/tab/mode/history.py index 0797320e..1497813d 100644 --- a/onionshare_gui/tab/mode/history.py +++ b/onionshare_gui/tab/mode/history.py @@ -119,7 +119,7 @@ class ShareHistoryItem(HistoryItem): self.progress_bar.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.progress_bar.setAlignment(QtCore.Qt.AlignHCenter) self.progress_bar.setMinimum(0) - self.progress_bar.setMaximum(total_bytes) + self.progress_bar.setMaximum(total_bytes / 1024) self.progress_bar.setValue(0) self.progress_bar.setStyleSheet( self.common.gui.css["downloads_uploads_progress_bar"] @@ -138,8 +138,8 @@ class ShareHistoryItem(HistoryItem): def update(self, downloaded_bytes): self.downloaded_bytes = downloaded_bytes - self.progress_bar.setValue(downloaded_bytes) - if downloaded_bytes == self.progress_bar.total_bytes: + self.progress_bar.setValue(downloaded_bytes / 1024) + if (downloaded_bytes / 1024) == (self.progress_bar.total_bytes / 1024): pb_fmt = strings._("gui_all_modes_progress_complete").format( self.common.format_seconds(time.time() - self.started) ) @@ -322,8 +322,8 @@ class ReceiveHistoryItem(HistoryItem): total_uploaded_bytes += data["progress"][filename]["uploaded_bytes"] # Update the progress bar - self.progress_bar.setMaximum(self.content_length) - self.progress_bar.setValue(total_uploaded_bytes) + self.progress_bar.setMaximum(self.content_length / 1024) + self.progress_bar.setValue(total_uploaded_bytes / 1024) elapsed = datetime.now() - self.started if elapsed.seconds < 10: @@ -339,6 +339,8 @@ class ReceiveHistoryItem(HistoryItem): estimated_time_remaining, ) + self.progress_bar.setFormat(pb_fmt) + # Using list(progress) to avoid "RuntimeError: dictionary changed size during iteration" for filename in list(data["progress"]): # Add a new file if needed @@ -461,7 +463,7 @@ class IndividualFileHistoryItem(HistoryItem): self.downloaded_bytes = downloaded_bytes self.progress_bar.setValue(downloaded_bytes) - if downloaded_bytes == self.progress_bar.total_bytes: + if (downloaded_bytes / 1024 ) == (self.progress_bar.total_bytes / 1024): self.status_code_label.setText("200") self.status_code_label.setStyleSheet( self.common.gui.css["history_individual_file_status_code_label_2xx"]