mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-29 01:06:16 -05:00
Hide downloads progress bars until download starts, and improve the look of progress bar display
This commit is contained in:
parent
28df4e40c5
commit
4bafd1eb2a
@ -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):
|
||||
"""
|
||||
|
@ -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
|
||||
@ -127,7 +126,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.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)
|
||||
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user