Merge branch 'clear_all_file_selection_widget' of https://github.com/mig5/onionshare into mig5-clear_all_file_selection_widget

This commit is contained in:
Micah Lee 2020-06-28 12:36:13 -07:00
commit 55e95d527b
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
5 changed files with 84 additions and 5 deletions

View file

@ -111,6 +111,13 @@ class ShareMode(Mode):
self.info_label = QtWidgets.QLabel()
self.info_label.hide()
# Delete all files button
self.delete_all_button = QtWidgets.QPushButton(strings._("gui_file_selection_delete_all"))
self.delete_all_button.setFlat(True)
self.delete_all_button.setStyleSheet(self.common.gui.css["share_delete_all_files_button"])
self.delete_all_button.clicked.connect(self.delete_all)
self.delete_all_button.hide()
# Toggle history
self.toggle_history = ToggleHistory(
self.common,
@ -126,6 +133,7 @@ class ShareMode(Mode):
top_bar_layout = QtWidgets.QHBoxLayout()
top_bar_layout.addWidget(self.info_label)
top_bar_layout.addStretch()
top_bar_layout.addWidget(self.delete_all_button)
top_bar_layout.addWidget(self.toggle_history)
# Primary action layout
@ -198,6 +206,8 @@ class ShareMode(Mode):
# Hide and reset the downloads if we have previously shared
self.reset_info_counters()
self.delete_all_button.hide()
def start_server_step2_custom(self):
"""
Step 2 in starting the server. Zipping up files.
@ -257,6 +267,8 @@ class ShareMode(Mode):
self.history.update_in_progress()
self.file_selection.file_list.adjustSize()
self.delete_all_button.show()
def cancel_server_custom(self):
"""
Stop the compression thread on cancel
@ -343,6 +355,7 @@ class ShareMode(Mode):
if self.server_status.file_selection.get_num_files() > 0:
self.primary_action.show()
self.info_label.show()
self.delete_all_button.show()
def update_primary_action(self):
self.common.log("ShareMode", "update_primary_action")
@ -352,6 +365,7 @@ class ShareMode(Mode):
if file_count > 0:
self.primary_action.show()
self.info_label.show()
self.delete_all_button.show()
# Update the file count in the info label
total_size_bytes = 0
@ -374,6 +388,7 @@ class ShareMode(Mode):
else:
self.primary_action.hide()
self.info_label.hide()
self.delete_all_button.hide()
def reset_info_counters(self):
"""
@ -383,6 +398,15 @@ class ShareMode(Mode):
self.toggle_history.indicator_count = 0
self.toggle_history.update_indicator()
def delete_all(self):
"""
Delete All button clicked
"""
self.file_selection.file_list.clear()
self.file_selection.file_list.files_updated.emit()
self.file_selection.file_list.setCurrentItem(None)
@staticmethod
def _compute_total_size(filenames):
total_size = 0

View file

@ -114,6 +114,13 @@ class WebsiteMode(Mode):
self.info_label = QtWidgets.QLabel()
self.info_label.hide()
# Delete all files button
self.delete_all_button = QtWidgets.QPushButton(strings._("gui_file_selection_delete_all"))
self.delete_all_button.setFlat(True)
self.delete_all_button.setStyleSheet(self.common.gui.css["share_delete_all_files_button"])
self.delete_all_button.clicked.connect(self.delete_all)
self.delete_all_button.hide()
# Toggle history
self.toggle_history = ToggleHistory(
self.common,
@ -129,6 +136,7 @@ class WebsiteMode(Mode):
top_bar_layout = QtWidgets.QHBoxLayout()
top_bar_layout.addWidget(self.info_label)
top_bar_layout.addStretch()
top_bar_layout.addWidget(self.delete_all_button)
top_bar_layout.addWidget(self.toggle_history)
# Primary action layout
@ -191,6 +199,8 @@ class WebsiteMode(Mode):
# Hide and reset the downloads if we have previously shared
self.reset_info_counters()
self.delete_all_button.hide()
def start_server_step2_custom(self):
"""
Step 2 in starting the server. Zipping up files.
@ -228,6 +238,8 @@ class WebsiteMode(Mode):
self.history.completed_count = 0
self.file_selection.file_list.adjustSize()
self.delete_all_button.show()
def cancel_server_custom(self):
"""
Log that the server has been cancelled
@ -248,6 +260,7 @@ class WebsiteMode(Mode):
if self.server_status.file_selection.get_num_files() > 0:
self.primary_action.show()
self.info_label.show()
self.delete_all_button.show()
def update_primary_action(self):
self.common.log("WebsiteMode", "update_primary_action")
@ -257,6 +270,7 @@ class WebsiteMode(Mode):
if file_count > 0:
self.primary_action.show()
self.info_label.show()
self.delete_all_button.show()
# Update the file count in the info label
total_size_bytes = 0
@ -279,6 +293,7 @@ class WebsiteMode(Mode):
else:
self.primary_action.hide()
self.info_label.hide()
self.delete_all_button.hide()
def reset_info_counters(self):
"""
@ -288,6 +303,15 @@ class WebsiteMode(Mode):
self.toggle_history.indicator_count = 0
self.toggle_history.update_indicator()
def delete_all(self):
"""
Delete All button clicked
"""
self.file_selection.file_list.clear()
self.file_selection.file_list.files_updated.emit()
self.file_selection.file_list.setCurrentItem(None)
@staticmethod
def _compute_total_size(filenames):
total_size = 0