Merge pull request #766 from mig5/clear_history_button

Add 'clear history' button to downloads and uploads windows
This commit is contained in:
Micah Lee 2018-09-19 18:36:50 -07:00 committed by GitHub
commit 093cf9bd85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -233,6 +233,10 @@ class Uploads(QtWidgets.QScrollArea):
uploads_label = QtWidgets.QLabel(strings._('gui_uploads', True)) uploads_label = QtWidgets.QLabel(strings._('gui_uploads', True))
uploads_label.setStyleSheet(self.common.css['downloads_uploads_label']) uploads_label.setStyleSheet(self.common.css['downloads_uploads_label'])
self.no_uploads_label = QtWidgets.QLabel(strings._('gui_no_uploads', True)) self.no_uploads_label = QtWidgets.QLabel(strings._('gui_no_uploads', True))
self.clear_history_button = QtWidgets.QPushButton(strings._('gui_clear_history', True))
self.clear_history_button.clicked.connect(self.reset)
self.clear_history_button.hide()
self.uploads_layout = QtWidgets.QVBoxLayout() self.uploads_layout = QtWidgets.QVBoxLayout()
@ -240,6 +244,7 @@ class Uploads(QtWidgets.QScrollArea):
layout = QtWidgets.QVBoxLayout() layout = QtWidgets.QVBoxLayout()
layout.addWidget(uploads_label) layout.addWidget(uploads_label)
layout.addWidget(self.no_uploads_label) layout.addWidget(self.no_uploads_label)
layout.addWidget(self.clear_history_button)
layout.addLayout(self.uploads_layout) layout.addLayout(self.uploads_layout)
layout.addStretch() layout.addStretch()
widget.setLayout(layout) widget.setLayout(layout)
@ -258,6 +263,8 @@ class Uploads(QtWidgets.QScrollArea):
self.common.log('Uploads', 'add', 'upload_id: {}, content_length: {}'.format(upload_id, content_length)) self.common.log('Uploads', 'add', 'upload_id: {}, content_length: {}'.format(upload_id, content_length))
# Hide the no_uploads_label # Hide the no_uploads_label
self.no_uploads_label.hide() self.no_uploads_label.hide()
# Show the clear_history_button
self.clear_history_button.show()
# Add it to the list # Add it to the list
upload = Upload(self.common, upload_id, content_length) upload = Upload(self.common, upload_id, content_length)
@ -300,6 +307,7 @@ class Uploads(QtWidgets.QScrollArea):
self.uploads = {} self.uploads = {}
self.no_uploads_label.show() self.no_uploads_label.show()
self.clear_history_button.hide()
self.resize(self.sizeHint()) self.resize(self.sizeHint())
def resizeEvent(self, event): def resizeEvent(self, event):

View File

@ -102,6 +102,9 @@ class Downloads(QtWidgets.QScrollArea):
downloads_label = QtWidgets.QLabel(strings._('gui_downloads', True)) downloads_label = QtWidgets.QLabel(strings._('gui_downloads', True))
downloads_label.setStyleSheet(self.common.css['downloads_uploads_label']) downloads_label.setStyleSheet(self.common.css['downloads_uploads_label'])
self.no_downloads_label = QtWidgets.QLabel(strings._('gui_no_downloads', True)) self.no_downloads_label = QtWidgets.QLabel(strings._('gui_no_downloads', True))
self.clear_history_button = QtWidgets.QPushButton(strings._('gui_clear_history', True))
self.clear_history_button.clicked.connect(self.reset)
self.clear_history_button.hide()
self.downloads_layout = QtWidgets.QVBoxLayout() self.downloads_layout = QtWidgets.QVBoxLayout()
@ -109,6 +112,7 @@ class Downloads(QtWidgets.QScrollArea):
layout = QtWidgets.QVBoxLayout() layout = QtWidgets.QVBoxLayout()
layout.addWidget(downloads_label) layout.addWidget(downloads_label)
layout.addWidget(self.no_downloads_label) layout.addWidget(self.no_downloads_label)
layout.addWidget(self.clear_history_button)
layout.addLayout(self.downloads_layout) layout.addLayout(self.downloads_layout)
layout.addStretch() layout.addStretch()
widget.setLayout(layout) widget.setLayout(layout)
@ -126,6 +130,8 @@ class Downloads(QtWidgets.QScrollArea):
""" """
# Hide the no_downloads_label # Hide the no_downloads_label
self.no_downloads_label.hide() self.no_downloads_label.hide()
# Show the clear_history_button
self.clear_history_button.show()
# Add it to the list # Add it to the list
download = Download(self.common, download_id, total_bytes) download = Download(self.common, download_id, total_bytes)
@ -154,4 +160,5 @@ class Downloads(QtWidgets.QScrollArea):
self.downloads = {} self.downloads = {}
self.no_downloads_label.show() self.no_downloads_label.show()
self.clear_history_button.hide()
self.resize(self.sizeHint()) self.resize(self.sizeHint())

View File

@ -181,6 +181,7 @@
"gui_uploads": "Upload History", "gui_uploads": "Upload History",
"gui_uploads_window_tooltip": "Show/hide uploads", "gui_uploads_window_tooltip": "Show/hide uploads",
"gui_no_uploads": "No uploads yet.", "gui_no_uploads": "No uploads yet.",
"gui_clear_history": "Clear history",
"gui_upload_in_progress": "Upload Started {}", "gui_upload_in_progress": "Upload Started {}",
"gui_upload_finished_range": "Uploaded {} to {}", "gui_upload_finished_range": "Uploaded {} to {}",
"gui_upload_finished": "Uploaded {}", "gui_upload_finished": "Uploaded {}",