very poor auto scrolling

This commit is contained in:
choltz95 2016-08-02 23:46:13 -04:00
parent d0f085f756
commit 6379ca5e48

View file

@ -105,6 +105,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
self.downloads_layout_container.setWidgetResizable(True) self.downloads_layout_container.setWidgetResizable(True)
self.downloads_layout_container.setFixedHeight(80) self.downloads_layout_container.setFixedHeight(80)
self.vbar = self.downloads_layout_container.verticalScrollBar() self.vbar = self.downloads_layout_container.verticalScrollBar()
self.new_download = False
# options # options
self.options = Options(web, self.app) self.options = Options(web, self.app)
@ -202,8 +203,13 @@ class OnionShareGui(QtWidgets.QMainWindow):
def check_for_requests(self): def check_for_requests(self):
""" """
Check for messages communicated from the web app, and update the GUI accordingly. Check for messages communicated from the web app, and update the GUI accordingly.
""" """
self.update() 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 # only check for requests if the server is running
if self.server_status.status != self.server_status.STATUS_STARTED: if self.server_status.status != self.server_status.STATUS_STARTED:
return return
@ -218,15 +224,13 @@ class OnionShareGui(QtWidgets.QMainWindow):
except web.queue.Empty: except web.queue.Empty:
done = True done = True
# scroll to the bottom of the dl progress bar log pane
self.vbar.setValue(self.vbar.maximum())
for event in events: for event in events:
if event["type"] == web.REQUEST_LOAD: if event["type"] == web.REQUEST_LOAD:
self.status_bar.showMessage(strings._('download_page_loaded', True)) self.status_bar.showMessage(strings._('download_page_loaded', True))
elif event["type"] == web.REQUEST_DOWNLOAD: elif event["type"] == web.REQUEST_DOWNLOAD:
self.downloads.add_download(event["data"]["id"], web.zip_filesize) self.downloads.add_download(event["data"]["id"], web.zip_filesize)
self.new_download = True
elif event["type"] == web.REQUEST_RATE_LIMIT: elif event["type"] == web.REQUEST_RATE_LIMIT:
self.stop_server() self.stop_server()
@ -234,7 +238,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
elif event["type"] == web.REQUEST_PROGRESS: elif event["type"] == web.REQUEST_PROGRESS:
self.downloads.update_download(event["data"]["id"], event["data"]["bytes"]) self.downloads.update_download(event["data"]["id"], event["data"]["bytes"])
# is the download complete? # is the download complete?
if event["data"]["bytes"] == web.zip_filesize: if event["data"]["bytes"] == web.zip_filesize:
# close on finish? # close on finish?