mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-25 22:15:57 -05:00
#1116 Add a Clear All button in the File List area for share modes
This commit is contained in:
parent
1c424500f0
commit
1632a00a91
@ -208,6 +208,11 @@ class GuiCommon:
|
||||
color: #cc0000;
|
||||
}""",
|
||||
# Share mode and child widget styles
|
||||
"share_clear_all_files_button": """
|
||||
QPushButton {
|
||||
color: #3f7fcf;
|
||||
}
|
||||
""",
|
||||
"share_zip_progess_bar": """
|
||||
QProgressBar {
|
||||
border: 1px solid #4e064f;
|
||||
|
@ -111,6 +111,13 @@ class ShareMode(Mode):
|
||||
self.info_label = QtWidgets.QLabel()
|
||||
self.info_label.hide()
|
||||
|
||||
# Clear all files button
|
||||
self.clear_all_button = QtWidgets.QPushButton(strings._("gui_file_selection_clear_all"))
|
||||
self.clear_all_button.setFlat(True)
|
||||
self.clear_all_button.setStyleSheet(self.common.gui.css["share_clear_all_files_button"])
|
||||
self.clear_all_button.clicked.connect(self.clear_all)
|
||||
self.clear_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.clear_all_button)
|
||||
top_bar_layout.addWidget(self.toggle_history)
|
||||
|
||||
# Primary action layout
|
||||
@ -343,6 +351,7 @@ class ShareMode(Mode):
|
||||
if self.server_status.file_selection.get_num_files() > 0:
|
||||
self.primary_action.show()
|
||||
self.info_label.show()
|
||||
self.clear_all_button.show()
|
||||
|
||||
def update_primary_action(self):
|
||||
self.common.log("ShareMode", "update_primary_action")
|
||||
@ -352,6 +361,7 @@ class ShareMode(Mode):
|
||||
if file_count > 0:
|
||||
self.primary_action.show()
|
||||
self.info_label.show()
|
||||
self.clear_all_button.show()
|
||||
|
||||
# Update the file count in the info label
|
||||
total_size_bytes = 0
|
||||
@ -374,6 +384,7 @@ class ShareMode(Mode):
|
||||
else:
|
||||
self.primary_action.hide()
|
||||
self.info_label.hide()
|
||||
self.clear_all_button.hide()
|
||||
|
||||
def reset_info_counters(self):
|
||||
"""
|
||||
@ -383,6 +394,15 @@ class ShareMode(Mode):
|
||||
self.toggle_history.indicator_count = 0
|
||||
self.toggle_history.update_indicator()
|
||||
|
||||
def clear_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
|
||||
|
@ -114,6 +114,13 @@ class WebsiteMode(Mode):
|
||||
self.info_label = QtWidgets.QLabel()
|
||||
self.info_label.hide()
|
||||
|
||||
# Clear all files button
|
||||
self.clear_all_button = QtWidgets.QPushButton(strings._("gui_file_selection_clear_all"))
|
||||
self.clear_all_button.setFlat(True)
|
||||
self.clear_all_button.setStyleSheet(self.common.gui.css["share_clear_all_files_button"])
|
||||
self.clear_all_button.clicked.connect(self.clear_all)
|
||||
self.clear_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.clear_all_button)
|
||||
top_bar_layout.addWidget(self.toggle_history)
|
||||
|
||||
# Primary action layout
|
||||
@ -248,6 +256,7 @@ class WebsiteMode(Mode):
|
||||
if self.server_status.file_selection.get_num_files() > 0:
|
||||
self.primary_action.show()
|
||||
self.info_label.show()
|
||||
self.clear_all_button.show()
|
||||
|
||||
def update_primary_action(self):
|
||||
self.common.log("WebsiteMode", "update_primary_action")
|
||||
@ -257,6 +266,7 @@ class WebsiteMode(Mode):
|
||||
if file_count > 0:
|
||||
self.primary_action.show()
|
||||
self.info_label.show()
|
||||
self.clear_all_button.show()
|
||||
|
||||
# Update the file count in the info label
|
||||
total_size_bytes = 0
|
||||
@ -279,6 +289,7 @@ class WebsiteMode(Mode):
|
||||
else:
|
||||
self.primary_action.hide()
|
||||
self.info_label.hide()
|
||||
self.clear_all_button.hide()
|
||||
|
||||
def reset_info_counters(self):
|
||||
"""
|
||||
@ -288,6 +299,15 @@ class WebsiteMode(Mode):
|
||||
self.toggle_history.indicator_count = 0
|
||||
self.toggle_history.update_indicator()
|
||||
|
||||
def clear_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
|
||||
|
@ -12,6 +12,7 @@
|
||||
"gui_add_files": "Add Files",
|
||||
"gui_add_folder": "Add Folder",
|
||||
"gui_delete": "Delete",
|
||||
"gui_file_selection_clear_all": "Clear All",
|
||||
"gui_choose_items": "Choose",
|
||||
"gui_share_start_server": "Start sharing",
|
||||
"gui_share_stop_server": "Stop sharing",
|
||||
@ -205,4 +206,4 @@
|
||||
"mode_settings_receive_data_dir_label": "Save files to",
|
||||
"mode_settings_receive_data_dir_browse_button": "Browse",
|
||||
"mode_settings_website_disable_csp_checkbox": "Disable Content Security Policy header (allows your website to use third-party resources)"
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,14 @@ class TestShare(GuiBaseTest):
|
||||
).item_button.click()
|
||||
self.file_selection_widget_has_files(tab, num_files)
|
||||
|
||||
def add_a_file_and_delete_using_clear_all_widget(self, tab):
|
||||
"""Test that we can also delete all files by clicking on the Clear All widget"""
|
||||
tab.get_mode().server_status.file_selection.file_list.add_file(self.tmpfiles[0])
|
||||
tab.get_mode().server_status.file_selection.file_list.add_file(self.tmpfiles[1])
|
||||
tab.get_mode().clear_all_button.click()
|
||||
# Should be no files after clearing all
|
||||
self.file_selection_widget_has_files(tab, 0)
|
||||
|
||||
def file_selection_widget_read_files(self, tab):
|
||||
"""Re-add some files to the list so we can share"""
|
||||
num_files = tab.get_mode().server_status.file_selection.get_num_files()
|
||||
@ -269,7 +277,7 @@ class TestShare(GuiBaseTest):
|
||||
self.run_all_share_mode_started_tests(tab)
|
||||
self.run_all_share_mode_download_tests(tab)
|
||||
|
||||
def run_all_clear_all_button_tests(self, tab):
|
||||
def run_all_clear_all_history_button_tests(self, tab):
|
||||
"""Test the Clear All history button"""
|
||||
self.run_all_share_mode_setup_tests(tab)
|
||||
self.run_all_share_mode_started_tests(tab)
|
||||
@ -279,6 +287,11 @@ class TestShare(GuiBaseTest):
|
||||
self.individual_file_is_viewable_or_not(tab)
|
||||
self.clear_all_history_items(tab, 2)
|
||||
|
||||
def run_all_clear_all_file_selection_button_tests(self, tab):
|
||||
"""Test the Clear All File Selection button"""
|
||||
self.run_all_share_mode_setup_tests(tab)
|
||||
self.add_a_file_and_delete_using_clear_all_widget(tab)
|
||||
|
||||
def run_all_share_mode_individual_file_tests(self, tab):
|
||||
"""Tests in share mode when viewing an individual file"""
|
||||
self.run_all_share_mode_setup_tests(tab)
|
||||
@ -375,18 +388,31 @@ class TestShare(GuiBaseTest):
|
||||
self.close_all_tabs()
|
||||
|
||||
@pytest.mark.gui
|
||||
def test_clear_all_button(self):
|
||||
def test_clear_all_history_button(self):
|
||||
"""
|
||||
Test canceling a scheduled share
|
||||
Test clearing all history items
|
||||
"""
|
||||
tab = self.new_share_tab()
|
||||
tab.get_mode().autostop_sharing_checkbox.click()
|
||||
|
||||
self.run_all_common_setup_tests()
|
||||
self.run_all_clear_all_button_tests(tab)
|
||||
self.run_all_clear_all_history_button_tests(tab)
|
||||
|
||||
self.close_all_tabs()
|
||||
|
||||
@pytest.mark.gui
|
||||
def test_clear_all_file_selection_button(self):
|
||||
"""
|
||||
Test clearing all file items at once
|
||||
"""
|
||||
tab = self.new_share_tab()
|
||||
|
||||
self.run_all_common_setup_tests()
|
||||
self.run_all_clear_all_file_selection_button_tests(tab)
|
||||
|
||||
self.close_all_tabs()
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def test_public_mode(self):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user