From 3b359aec621bd93c01b9f2629eaf3ecd3787d059 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 31 May 2017 17:35:16 +1000 Subject: [PATCH 1/2] On a fresh share, delete any download progress bars of previous shares, and re-hide the downloads container --- onionshare_gui/downloads.py | 10 ++++++++++ onionshare_gui/onionshare_gui.py | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/onionshare_gui/downloads.py b/onionshare_gui/downloads.py index a9d7fb12..1361f512 100644 --- a/onionshare_gui/downloads.py +++ b/onionshare_gui/downloads.py @@ -45,6 +45,7 @@ class Download(object): }""" self.progress_bar = QtWidgets.QProgressBar() self.progress_bar.setTextVisible(True) + 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) @@ -120,3 +121,12 @@ class Downloads(QtWidgets.QWidget): Update a download progress bar to show that it has been canceled. """ self.downloads[download_id].cancel() + + def reset_downloads(self): + """ + Reset the downloads back to zero + """ + for download in self.downloads.values(): + self.layout.removeWidget(download.progress_bar) + download.progress_bar.close() # = None + self.downloads = {} diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index e6b02dc1..1b1505d7 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -94,6 +94,7 @@ class OnionShareGui(QtWidgets.QMainWindow): self.downloads_container.setWidget(self.downloads) self.downloads_container.setWidgetResizable(True) self.downloads_container.setMaximumHeight(200) + self.downloads_container.setMinimumHeight(75) self.vbar = self.downloads_container.verticalScrollBar() self.downloads_container.hide() # downloads start out hidden self.new_download = False @@ -233,6 +234,10 @@ class OnionShareGui(QtWidgets.QMainWindow): self.app.set_stealth(self.settings.get('use_stealth')) + # Hide and reset the downloads if we have previously shared + self.downloads_container.hide() + self.downloads.reset_downloads() + # Reset web counters web.download_count = 0 web.error404_count = 0 From 7e2d4d788807170aad880613a561f4eb5d063532 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 31 May 2017 19:44:53 +1000 Subject: [PATCH 2/2] Remove debug data --- onionshare_gui/downloads.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onionshare_gui/downloads.py b/onionshare_gui/downloads.py index 1361f512..60bd59ac 100644 --- a/onionshare_gui/downloads.py +++ b/onionshare_gui/downloads.py @@ -128,5 +128,5 @@ class Downloads(QtWidgets.QWidget): """ for download in self.downloads.values(): self.layout.removeWidget(download.progress_bar) - download.progress_bar.close() # = None + download.progress_bar.close() self.downloads = {}