mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-27 00:09:50 -05:00
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:
commit
55e95d527b
@ -208,6 +208,11 @@ class GuiCommon:
|
||||
color: #cc0000;
|
||||
}""",
|
||||
# Share mode and child widget styles
|
||||
"share_delete_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()
|
||||
|
||||
# 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
|
||||
|
@ -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
|
||||
|
@ -12,6 +12,7 @@
|
||||
"gui_add_files": "Add Files",
|
||||
"gui_add_folder": "Add Folder",
|
||||
"gui_delete": "Delete",
|
||||
"gui_file_selection_delete_all": "Delete All",
|
||||
"gui_choose_items": "Choose",
|
||||
"gui_share_start_server": "Start sharing",
|
||||
"gui_share_stop_server": "Stop sharing",
|
||||
|
@ -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_delete_all_widget(self, tab):
|
||||
"""Test that we can also delete all files by clicking on the Delete 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().delete_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_delete_all_file_selection_button_tests(self, tab):
|
||||
"""Test the Delete All File Selection button"""
|
||||
self.run_all_share_mode_setup_tests(tab)
|
||||
self.add_a_file_and_delete_using_delete_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,15 +388,27 @@ 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_delete_all_file_selection_button(self):
|
||||
"""
|
||||
Test delete all file items at once
|
||||
"""
|
||||
tab = self.new_share_tab()
|
||||
|
||||
self.run_all_common_setup_tests()
|
||||
self.run_all_delete_all_file_selection_button_tests(tab)
|
||||
|
||||
self.close_all_tabs()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user