Merge pull request #1122 from mig5/fix_progress_bar_2GB_file_and_receive_mode_eta_progress

#1095 Fix crash for shares larger than 2GB. #1089 add ETA/bytes uploaded in progress bar of ReceiveMode items
This commit is contained in:
Micah Lee 2020-07-05 11:48:48 -07:00 committed by GitHub
commit 4a4811afb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,7 +119,7 @@ class ShareHistoryItem(HistoryItem):
self.progress_bar.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.progress_bar.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.progress_bar.setAlignment(QtCore.Qt.AlignHCenter) self.progress_bar.setAlignment(QtCore.Qt.AlignHCenter)
self.progress_bar.setMinimum(0) 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.setValue(0)
self.progress_bar.setStyleSheet( self.progress_bar.setStyleSheet(
self.common.gui.css["downloads_uploads_progress_bar"] self.common.gui.css["downloads_uploads_progress_bar"]
@ -138,8 +138,8 @@ class ShareHistoryItem(HistoryItem):
def update(self, downloaded_bytes): def update(self, downloaded_bytes):
self.downloaded_bytes = downloaded_bytes self.downloaded_bytes = downloaded_bytes
self.progress_bar.setValue(downloaded_bytes) self.progress_bar.setValue(downloaded_bytes / 1024)
if downloaded_bytes == self.progress_bar.total_bytes: if (downloaded_bytes / 1024) == (self.progress_bar.total_bytes / 1024):
pb_fmt = strings._("gui_all_modes_progress_complete").format( pb_fmt = strings._("gui_all_modes_progress_complete").format(
self.common.format_seconds(time.time() - self.started) self.common.format_seconds(time.time() - self.started)
) )
@ -322,8 +322,8 @@ class ReceiveHistoryItem(HistoryItem):
total_uploaded_bytes += data["progress"][filename]["uploaded_bytes"] total_uploaded_bytes += data["progress"][filename]["uploaded_bytes"]
# Update the progress bar # Update the progress bar
self.progress_bar.setMaximum(self.content_length) self.progress_bar.setMaximum(self.content_length / 1024)
self.progress_bar.setValue(total_uploaded_bytes) self.progress_bar.setValue(total_uploaded_bytes / 1024)
elapsed = datetime.now() - self.started elapsed = datetime.now() - self.started
if elapsed.seconds < 10: if elapsed.seconds < 10:
@ -339,6 +339,8 @@ class ReceiveHistoryItem(HistoryItem):
estimated_time_remaining, estimated_time_remaining,
) )
self.progress_bar.setFormat(pb_fmt)
# Using list(progress) to avoid "RuntimeError: dictionary changed size during iteration" # Using list(progress) to avoid "RuntimeError: dictionary changed size during iteration"
for filename in list(data["progress"]): for filename in list(data["progress"]):
# Add a new file if needed # Add a new file if needed
@ -451,7 +453,7 @@ class IndividualFileHistoryItem(HistoryItem):
else: else:
self.total_bytes = data["filesize"] self.total_bytes = data["filesize"]
self.progress_bar.setMinimum(0) self.progress_bar.setMinimum(0)
self.progress_bar.setMaximum(data["filesize"]) self.progress_bar.setMaximum(data["filesize"] / 1024)
self.progress_bar.total_bytes = data["filesize"] self.progress_bar.total_bytes = data["filesize"]
# Start at 0 # Start at 0
@ -460,8 +462,8 @@ class IndividualFileHistoryItem(HistoryItem):
def update(self, downloaded_bytes): def update(self, downloaded_bytes):
self.downloaded_bytes = downloaded_bytes self.downloaded_bytes = downloaded_bytes
self.progress_bar.setValue(downloaded_bytes) self.progress_bar.setValue(downloaded_bytes / 1024)
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.setText("200")
self.status_code_label.setStyleSheet( self.status_code_label.setStyleSheet(
self.common.gui.css["history_individual_file_status_code_label_2xx"] self.common.gui.css["history_individual_file_status_code_label_2xx"]