From 0b18129947478312909822e29029189ec5ed3fb7 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 7 Feb 2018 16:40:41 +1100 Subject: [PATCH 1/3] Set the File List widget to readonly while running, so items can't be deleted mid-share --- onionshare_gui/server_status.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py index 3f7e390c..32b1aa32 100644 --- a/onionshare_gui/server_status.py +++ b/onionshare_gui/server_status.py @@ -178,6 +178,12 @@ class ServerStatus(QtWidgets.QWidget): self.copy_url_button.hide() self.copy_hidservauth_button.hide() + # Set the File List widget to readonly while running, so items can't be deleted mid-share + if self.status == self.STATUS_STARTED or self.status == self.STATUS_WORKING: + self.file_selection.file_list.setEnabled(False) + else: + self.file_selection.file_list.setEnabled(True) + # Button button_stopped_style = 'QPushButton { background-color: #5fa416; color: #ffffff; padding: 10px; border: 0; border-radius: 5px; }' button_working_style = 'QPushButton { background-color: #4c8211; color: #ffffff; padding: 10px; border: 0; border-radius: 5px; font-style: italic; }' From 2b15020e7dd71ebd30a0df709cd1f4b83250c9b6 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 7 Feb 2018 17:34:36 +1100 Subject: [PATCH 2/3] Leave the FileList enabled, but hide the item buttons when the server is working or started --- onionshare_gui/file_selection.py | 12 ++++++------ onionshare_gui/server_status.py | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py index 0ba94b51..22f9be09 100644 --- a/onionshare_gui/file_selection.py +++ b/onionshare_gui/file_selection.py @@ -205,16 +205,16 @@ class FileList(QtWidgets.QListWidget): self.takeItem(itemrow) self.files_updated.emit() - item_button = QtWidgets.QPushButton() - item_button.setDefault(False) - item_button.setFlat(True) - item_button.setIcon( QtGui.QIcon(common.get_resource_path('images/file_delete.png')) ) - item_button.clicked.connect(delete_item) + item.item_button = QtWidgets.QPushButton() + item.item_button.setDefault(False) + item.item_button.setFlat(True) + item.item_button.setIcon( QtGui.QIcon(common.get_resource_path('images/file_delete.png')) ) + item.item_button.clicked.connect(delete_item) # Create an item widget to display on the item item_widget_layout = QtWidgets.QHBoxLayout() item_widget_layout.addStretch() - item_widget_layout.addWidget(item_button) + item_widget_layout.addWidget(item.item_button) item_widget = QtWidgets.QWidget() item_widget.setLayout(item_widget_layout) diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py index 32b1aa32..1ebe4a2a 100644 --- a/onionshare_gui/server_status.py +++ b/onionshare_gui/server_status.py @@ -180,9 +180,11 @@ class ServerStatus(QtWidgets.QWidget): # Set the File List widget to readonly while running, so items can't be deleted mid-share if self.status == self.STATUS_STARTED or self.status == self.STATUS_WORKING: - self.file_selection.file_list.setEnabled(False) + for index in range(self.file_selection.file_list.count()): + self.file_selection.file_list.item(index).item_button.hide() else: - self.file_selection.file_list.setEnabled(True) + for index in range(self.file_selection.file_list.count()): + self.file_selection.file_list.item(index).item_button.show() # Button button_stopped_style = 'QPushButton { background-color: #5fa416; color: #ffffff; padding: 10px; border: 0; border-radius: 5px; }' From cdf14e2600823b36fcec50ef7cb3dc4af4b98e44 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 7 Feb 2018 19:18:20 +1100 Subject: [PATCH 3/3] Fix comment to reflect what we're doing with the file list buttons --- onionshare_gui/server_status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py index 1ebe4a2a..036eba35 100644 --- a/onionshare_gui/server_status.py +++ b/onionshare_gui/server_status.py @@ -178,7 +178,7 @@ class ServerStatus(QtWidgets.QWidget): self.copy_url_button.hide() self.copy_hidservauth_button.hide() - # Set the File List widget to readonly while running, so items can't be deleted mid-share + # Hide the FileList delete buttons when a share is running if self.status == self.STATUS_STARTED or self.status == self.STATUS_WORKING: for index in range(self.file_selection.file_list.count()): self.file_selection.file_list.item(index).item_button.hide()