summaryrefslogtreecommitdiff
path: root/onionshare_gui
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2020-05-27 12:56:33 +1000
committerMiguel Jacq <mig@mig5.net>2020-05-27 12:56:33 +1000
commit1632a00a9198b89faf45e4d32294855fdd8dd874 (patch)
tree79c6cf58a1346ce4191b599bc3559c772f7c297f /onionshare_gui
parent1c424500f0b0e1e2bb7b17ce144cce16e20e5493 (diff)
downloadonionshare-1632a00a9198b89faf45e4d32294855fdd8dd874.tar.gz
onionshare-1632a00a9198b89faf45e4d32294855fdd8dd874.zip
#1116 Add a Clear All button in the File List area for share modes
Diffstat (limited to 'onionshare_gui')
-rw-r--r--onionshare_gui/gui_common.py5
-rw-r--r--onionshare_gui/tab/mode/share_mode/__init__.py20
-rw-r--r--onionshare_gui/tab/mode/website_mode/__init__.py20
3 files changed, 45 insertions, 0 deletions
diff --git a/onionshare_gui/gui_common.py b/onionshare_gui/gui_common.py
index 4381545e..91e05b68 100644
--- a/onionshare_gui/gui_common.py
+++ b/onionshare_gui/gui_common.py
@@ -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;
diff --git a/onionshare_gui/tab/mode/share_mode/__init__.py b/onionshare_gui/tab/mode/share_mode/__init__.py
index 1423d60a..4436ba25 100644
--- a/onionshare_gui/tab/mode/share_mode/__init__.py
+++ b/onionshare_gui/tab/mode/share_mode/__init__.py
@@ -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
diff --git a/onionshare_gui/tab/mode/website_mode/__init__.py b/onionshare_gui/tab/mode/website_mode/__init__.py
index db8dbf09..11fba562 100644
--- a/onionshare_gui/tab/mode/website_mode/__init__.py
+++ b/onionshare_gui/tab/mode/website_mode/__init__.py
@@ -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