Merge pull request #757 from mig5/auto_scroll_download_upload_window

Fix the auto-scrolling to bottom of Download and Upload windows
This commit is contained in:
Micah Lee 2018-09-18 16:35:17 -07:00 committed by GitHub
commit 50b69e4316
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -227,6 +227,7 @@ class Uploads(QtWidgets.QScrollArea):
self.setWindowIcon(QtGui.QIcon(common.get_resource_path('images/logo.png')))
self.setWindowFlags(QtCore.Qt.Sheet | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.CustomizeWindowHint)
self.vbar = self.verticalScrollBar()
self.vbar.rangeChanged.connect(self.resizeScroll)
uploads_label = QtWidgets.QLabel(strings._('gui_uploads', True))
uploads_label.setStyleSheet(self.common.css['downloads_uploads_label'])
@ -243,6 +244,12 @@ class Uploads(QtWidgets.QScrollArea):
widget.setLayout(layout)
self.setWidget(widget)
def resizeScroll(self, minimum, maximum):
"""
Scroll to the bottom of the window when the range changes.
"""
self.vbar.setValue(maximum)
def add(self, upload_id, content_length):
"""
Add a new upload.
@ -256,9 +263,6 @@ class Uploads(QtWidgets.QScrollArea):
self.uploads[upload_id] = upload
self.uploads_layout.addWidget(upload)
# Scroll to the bottom
self.vbar.setValue(self.vbar.maximum())
def update(self, upload_id, progress):
"""
Update the progress of an upload.

View File

@ -97,6 +97,7 @@ class Downloads(QtWidgets.QScrollArea):
self.setWindowIcon(QtGui.QIcon(common.get_resource_path('images/logo.png')))
self.setWindowFlags(QtCore.Qt.Sheet | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.CustomizeWindowHint)
self.vbar = self.verticalScrollBar()
self.vbar.rangeChanged.connect(self.resizeScroll)
downloads_label = QtWidgets.QLabel(strings._('gui_downloads', True))
downloads_label.setStyleSheet(self.common.css['downloads_uploads_label'])
@ -113,6 +114,12 @@ class Downloads(QtWidgets.QScrollArea):
widget.setLayout(layout)
self.setWidget(widget)
def resizeScroll(self, minimum, maximum):
"""
Scroll to the bottom of the window when the range changes.
"""
self.vbar.setValue(maximum)
def add(self, download_id, total_bytes):
"""
Add a new download progress bar.
@ -125,9 +132,6 @@ class Downloads(QtWidgets.QScrollArea):
self.downloads[download_id] = download
self.downloads_layout.addWidget(download.progress_bar)
# Scroll to the bottom
self.vbar.setValue(self.vbar.maximum())
def update(self, download_id, downloaded_bytes):
"""
Update the progress of a download progress bar.