From b1dd45a94b466bb017b1cab1f2e12abed5b820e3 Mon Sep 17 00:00:00 2001 From: choltz95 Date: Tue, 2 Aug 2016 01:43:17 -0400 Subject: [PATCH 1/4] wrap progress bar --- onionshare_gui/downloads.py | 2 +- onionshare_gui/onionshare_gui.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/onionshare_gui/downloads.py b/onionshare_gui/downloads.py index 265b9bf7..7b6016c0 100644 --- a/onionshare_gui/downloads.py +++ b/onionshare_gui/downloads.py @@ -103,7 +103,7 @@ class Downloads(QtWidgets.QVBoxLayout): # add it to the list download = Download(download_id, total_bytes) self.downloads[download_id] = download - self.addWidget(download.progress_bar) + self.insertWidget(-1, download.progress_bar) def update_download(self, download_id, downloaded_bytes): """ diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 1eb508bc..bad561ac 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -112,10 +112,19 @@ class OnionShareGui(QtWidgets.QMainWindow): # main layout self.layout = QtWidgets.QVBoxLayout() + + self.downloads_layout = QtWidgets.QGroupBox() + self.downloads_layout.setLayout(self.downloads) + self.downloads_layout_container = QtWidgets.QScrollArea() + self.downloads_layout_container.setWidget(self.downloads_layout) + self.downloads_layout_container.setWidgetResizable(True) + self.downloads_layout_container.setFixedHeight(80) + self.vbar = self.downloads_layout_container.verticalScrollBar() + self.layout.addLayout(self.file_selection) self.layout.addLayout(self.server_status) self.layout.addWidget(self.filesize_warning) - self.layout.addLayout(self.downloads) + self.layout.addWidget(self.downloads_layout_container) self.layout.addLayout(self.options) central_widget = QtWidgets.QWidget() central_widget.setLayout(self.layout) @@ -210,7 +219,7 @@ class OnionShareGui(QtWidgets.QMainWindow): events.append(r) except web.queue.Empty: done = True - + self.vbar.setValue(self.vbar.maximum()) for event in events: if event["type"] == web.REQUEST_LOAD: self.status_bar.showMessage(strings._('download_page_loaded', True)) From d0f085f7560c2c8f70b65b2e41745b410f462f2d Mon Sep 17 00:00:00 2001 From: choltz95 Date: Tue, 2 Aug 2016 16:43:40 +0000 Subject: [PATCH 2/4] reorganize, add comment --- onionshare_gui/downloads.py | 2 +- onionshare_gui/onionshare_gui.py | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/onionshare_gui/downloads.py b/onionshare_gui/downloads.py index 7b6016c0..7729f8c7 100644 --- a/onionshare_gui/downloads.py +++ b/onionshare_gui/downloads.py @@ -56,7 +56,7 @@ class Download(object): elapsed = time.time() - self.started if elapsed < 10: # Wait a couple of seconds for the download rate to stabilize. - # This prevents an "Windows copy dialog"-esque experience at + # This prevents a "Windows copy dialog"-esque experience at # the beginning of the download. pb_fmt = strings._('gui_download_progress_starting').format( helpers.human_readable_filesize(downloaded_bytes)) diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index bad561ac..146856e3 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -98,6 +98,13 @@ class OnionShareGui(QtWidgets.QMainWindow): # downloads self.downloads = Downloads() + self.downloads_layout = QtWidgets.QGroupBox() + self.downloads_layout.setLayout(self.downloads) + self.downloads_layout_container = QtWidgets.QScrollArea() + self.downloads_layout_container.setWidget(self.downloads_layout) + self.downloads_layout_container.setWidgetResizable(True) + self.downloads_layout_container.setFixedHeight(80) + self.vbar = self.downloads_layout_container.verticalScrollBar() # options self.options = Options(web, self.app) @@ -108,19 +115,10 @@ class OnionShareGui(QtWidgets.QMainWindow): version_label = QtWidgets.QLabel('v{0:s}'.format(helpers.get_version())) version_label.setStyleSheet('color: #666666; padding: 0 10px;') self.status_bar.addPermanentWidget(version_label) - self.setStatusBar(self.status_bar) + self.setStatusBar(self.status_bar) # main layout self.layout = QtWidgets.QVBoxLayout() - - self.downloads_layout = QtWidgets.QGroupBox() - self.downloads_layout.setLayout(self.downloads) - self.downloads_layout_container = QtWidgets.QScrollArea() - self.downloads_layout_container.setWidget(self.downloads_layout) - self.downloads_layout_container.setWidgetResizable(True) - self.downloads_layout_container.setFixedHeight(80) - self.vbar = self.downloads_layout_container.verticalScrollBar() - self.layout.addLayout(self.file_selection) self.layout.addLayout(self.server_status) self.layout.addWidget(self.filesize_warning) @@ -219,7 +217,10 @@ class OnionShareGui(QtWidgets.QMainWindow): events.append(r) except web.queue.Empty: done = True + + # scroll to the bottom of the dl progress bar log pane self.vbar.setValue(self.vbar.maximum()) + for event in events: if event["type"] == web.REQUEST_LOAD: self.status_bar.showMessage(strings._('download_page_loaded', True)) From 6379ca5e4846d988b6d34b383bb3d5c9468bf650 Mon Sep 17 00:00:00 2001 From: choltz95 Date: Tue, 2 Aug 2016 23:46:13 -0400 Subject: [PATCH 3/4] very poor auto scrolling --- onionshare_gui/onionshare_gui.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 146856e3..f4019de8 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -105,6 +105,7 @@ class OnionShareGui(QtWidgets.QMainWindow): self.downloads_layout_container.setWidgetResizable(True) self.downloads_layout_container.setFixedHeight(80) self.vbar = self.downloads_layout_container.verticalScrollBar() + self.new_download = False # options self.options = Options(web, self.app) @@ -202,8 +203,13 @@ class OnionShareGui(QtWidgets.QMainWindow): def check_for_requests(self): """ Check for messages communicated from the web app, and update the GUI accordingly. - """ + """ self.update() + # scroll to the bottom of the dl progress bar log pane + # if a new download has been added + if self.new_download: + self.vbar.setValue(self.vbar.maximum()) + self.new_download = False # only check for requests if the server is running if self.server_status.status != self.server_status.STATUS_STARTED: return @@ -218,15 +224,13 @@ class OnionShareGui(QtWidgets.QMainWindow): except web.queue.Empty: done = True - # scroll to the bottom of the dl progress bar log pane - self.vbar.setValue(self.vbar.maximum()) - for event in events: if event["type"] == web.REQUEST_LOAD: self.status_bar.showMessage(strings._('download_page_loaded', True)) elif event["type"] == web.REQUEST_DOWNLOAD: self.downloads.add_download(event["data"]["id"], web.zip_filesize) + self.new_download = True elif event["type"] == web.REQUEST_RATE_LIMIT: self.stop_server() @@ -234,7 +238,7 @@ class OnionShareGui(QtWidgets.QMainWindow): elif event["type"] == web.REQUEST_PROGRESS: self.downloads.update_download(event["data"]["id"], event["data"]["bytes"]) - + # is the download complete? if event["data"]["bytes"] == web.zip_filesize: # close on finish? From 4bafd1eb2a799103f0be9c535e714141b060358b Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 22 Dec 2016 15:15:37 -0800 Subject: [PATCH 4/4] Hide downloads progress bars until download starts, and improve the look of progress bar display --- onionshare_gui/downloads.py | 16 +++++----------- onionshare_gui/onionshare_gui.py | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/onionshare_gui/downloads.py b/onionshare_gui/downloads.py index 7729f8c7..1c54ab50 100644 --- a/onionshare_gui/downloads.py +++ b/onionshare_gui/downloads.py @@ -77,33 +77,27 @@ class Download(object): self.started) -class Downloads(QtWidgets.QVBoxLayout): +class Downloads(QtWidgets.QWidget): """ The downloads chunk of the GUI. This lists all of the active download progress bars. """ def __init__(self): super(Downloads, self).__init__() - self.downloads = {} - - # downloads label - self.downloads_label = QtWidgets.QLabel(strings._('gui_downloads', True)) - self.downloads_label.hide() - - # add the widgets - self.addWidget(self.downloads_label) + self.layout = QtWidgets.QVBoxLayout() + self.setLayout(self.layout) def add_download(self, download_id, total_bytes): """ Add a new download progress bar. """ - self.downloads_label.show() + self.parent().show() # add it to the list download = Download(download_id, total_bytes) self.downloads[download_id] = download - self.insertWidget(-1, download.progress_bar) + self.layout.insertWidget(-1, download.progress_bar) def update_download(self, download_id, downloaded_bytes): """ diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 2f86632d..8a738d26 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -102,13 +102,12 @@ class OnionShareGui(QtWidgets.QMainWindow): # downloads self.downloads = Downloads() - self.downloads_layout = QtWidgets.QGroupBox() - self.downloads_layout.setLayout(self.downloads) - self.downloads_layout_container = QtWidgets.QScrollArea() - self.downloads_layout_container.setWidget(self.downloads_layout) - self.downloads_layout_container.setWidgetResizable(True) - self.downloads_layout_container.setFixedHeight(80) - self.vbar = self.downloads_layout_container.verticalScrollBar() + self.downloads_container = QtWidgets.QScrollArea() + self.downloads_container.setWidget(self.downloads) + self.downloads_container.setWidgetResizable(True) + self.downloads_container.setMaximumHeight(200) + self.vbar = self.downloads_container.verticalScrollBar() + self.downloads_container.hide() # downloads start out hidden self.new_download = False # options @@ -120,14 +119,14 @@ class OnionShareGui(QtWidgets.QMainWindow): version_label = QtWidgets.QLabel('v{0:s}'.format(helpers.get_version())) version_label.setStyleSheet('color: #666666; padding: 0 10px;') self.status_bar.addPermanentWidget(version_label) - self.setStatusBar(self.status_bar) + self.setStatusBar(self.status_bar) # main layout self.layout = QtWidgets.QVBoxLayout() self.layout.addLayout(self.file_selection) self.layout.addLayout(self.server_status) self.layout.addWidget(self.filesize_warning) - self.layout.addWidget(self.downloads_layout_container) + self.layout.addWidget(self.downloads_container) self.layout.addLayout(self.options) central_widget = QtWidgets.QWidget() central_widget.setLayout(self.layout) @@ -229,7 +228,7 @@ class OnionShareGui(QtWidgets.QMainWindow): def check_for_requests(self): """ Check for messages communicated from the web app, and update the GUI accordingly. - """ + """ self.update() # scroll to the bottom of the dl progress bar log pane # if a new download has been added @@ -255,6 +254,7 @@ class OnionShareGui(QtWidgets.QMainWindow): self.status_bar.showMessage(strings._('download_page_loaded', True)) elif event["type"] == web.REQUEST_DOWNLOAD: + self.downloads_container.show() # show the downloads layout self.downloads.add_download(event["data"]["id"], web.zip_filesize) self.new_download = True @@ -264,7 +264,7 @@ class OnionShareGui(QtWidgets.QMainWindow): elif event["type"] == web.REQUEST_PROGRESS: self.downloads.update_download(event["data"]["id"], event["data"]["bytes"]) - + # is the download complete? if event["data"]["bytes"] == web.zip_filesize: # close on finish?