diff --git a/onionshare_gui/receive_mode/uploads.py b/onionshare_gui/receive_mode/uploads.py index 09834156..1aebe902 100644 --- a/onionshare_gui/receive_mode/uploads.py +++ b/onionshare_gui/receive_mode/uploads.py @@ -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. diff --git a/onionshare_gui/share_mode/downloads.py b/onionshare_gui/share_mode/downloads.py index f5e8512e..538ddfd0 100644 --- a/onionshare_gui/share_mode/downloads.py +++ b/onionshare_gui/share_mode/downloads.py @@ -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.