Double progress bar no longer occurs

This commit is contained in:
Jaime van Kessel 2016-07-27 15:36:08 +02:00
parent fd36f09b29
commit 050e81053f

View file

@ -506,9 +506,10 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
elif "materials" in reply.url().toString(): elif "materials" in reply.url().toString():
# Remove cached post request items. # Remove cached post request items.
del self._material_post_objects[id(reply)] del self._material_post_objects[id(reply)]
else: elif "print_job" in reply.url().toString():
reply.uploadProgress.disconnect(self._onUploadProgress) reply.uploadProgress.disconnect(self._onUploadProgress)
self._progress_message.hide() self._progress_message.hide()
elif reply.operation() == QNetworkAccessManager.PutOperation: elif reply.operation() == QNetworkAccessManager.PutOperation:
if status_code == 204: if status_code == 204:
pass # Request was successful! pass # Request was successful!
@ -519,6 +520,8 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
def _onUploadProgress(self, bytes_sent, bytes_total): def _onUploadProgress(self, bytes_sent, bytes_total):
if bytes_total > 0: if bytes_total > 0:
new_progress = bytes_sent / bytes_total * 100
if new_progress > self._progress_message.getProgress():
self._progress_message.setProgress(bytes_sent / bytes_total * 100) self._progress_message.setProgress(bytes_sent / bytes_total * 100)
else: else:
self._progress_message.setProgress(0) self._progress_message.setProgress(0)