diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py index 22f9be09..9198ebc6 100644 --- a/onionshare_gui/file_selection.py +++ b/onionshare_gui/file_selection.py @@ -101,6 +101,25 @@ class FileList(QtWidgets.QListWidget): self.drop_here_image.hide() self.drop_here_text.hide() + def server_started(self): + """ + Update the GUI when the server starts, by hiding delete buttons. + """ + self.setAcceptDrops(False) + self.setCurrentItem(None) + self.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection) + for index in range(self.count()): + self.item(index).item_button.hide() + + def server_stopped(self): + """ + Update the GUI when the server stops, by showing delete buttons. + """ + self.file_list.setAcceptDrops(True) + self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) + for index in range(self.count()): + self.item(index).item_button.show() + def resizeEvent(self, event): """ When the widget is resized, resize the drop files image and text. @@ -267,7 +286,6 @@ class FileSelection(QtWidgets.QVBoxLayout): # Delete button should be hidden if item isn't selected current_item = self.file_list.currentItem() - common.log('FileSelection', 'current_item: {}'.format(current_item)) if not current_item: self.delete_button.hide() else: @@ -298,7 +316,7 @@ class FileSelection(QtWidgets.QVBoxLayout): self.file_list.filenames.pop(itemrow) self.file_list.takeItem(itemrow) self.file_list.files_updated.emit() - + self.file_list.setCurrentItem(None) self.update() @@ -307,7 +325,7 @@ class FileSelection(QtWidgets.QVBoxLayout): Gets called when the server starts. """ self.server_on = True - self.file_list.setAcceptDrops(False) + self.file_list.server_started() self.update() def server_stopped(self): @@ -315,7 +333,7 @@ class FileSelection(QtWidgets.QVBoxLayout): Gets called when the server stops. """ self.server_on = False - self.file_list.setAcceptDrops(True) + self.file_list.server_stopped() self.update() def get_num_files(self): diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py index 78f171d0..1aff79f4 100644 --- a/onionshare_gui/server_status.py +++ b/onionshare_gui/server_status.py @@ -182,14 +182,6 @@ class ServerStatus(QtWidgets.QWidget): self.copy_url_button.hide() self.copy_hidservauth_button.hide() - # 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() - else: - 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; }' button_working_style = 'QPushButton { background-color: #4c8211; color: #ffffff; padding: 10px; border: 0; border-radius: 5px; font-style: italic; }'