Merge branch 'wrap-progress-bar' of https://github.com/choltz95/onionshare into choltz95-wrap-progress-bar

This commit is contained in:
Micah Lee 2016-12-22 14:43:03 -08:00
commit 28df4e40c5
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 20 additions and 6 deletions

View File

@ -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))
@ -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):
"""

View File

@ -102,6 +102,14 @@ 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.new_download = False
# options
self.options = Options(web, self.app)
@ -119,7 +127,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
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)
@ -223,6 +231,11 @@ class OnionShareGui(QtWidgets.QMainWindow):
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
@ -243,6 +256,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
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()