mirror of
https://github.com/onionshare/onionshare.git
synced 2025-02-04 17:05:31 -05:00
Refactor what happens to FileList when the server starts or stops, and also prevent selections when the server starts
This commit is contained in:
parent
acf5c1bb88
commit
4639420dfc
@ -101,6 +101,25 @@ class FileList(QtWidgets.QListWidget):
|
|||||||
self.drop_here_image.hide()
|
self.drop_here_image.hide()
|
||||||
self.drop_here_text.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):
|
def resizeEvent(self, event):
|
||||||
"""
|
"""
|
||||||
When the widget is resized, resize the drop files image and text.
|
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
|
# Delete button should be hidden if item isn't selected
|
||||||
current_item = self.file_list.currentItem()
|
current_item = self.file_list.currentItem()
|
||||||
common.log('FileSelection', 'current_item: {}'.format(current_item))
|
|
||||||
if not current_item:
|
if not current_item:
|
||||||
self.delete_button.hide()
|
self.delete_button.hide()
|
||||||
else:
|
else:
|
||||||
@ -298,7 +316,7 @@ class FileSelection(QtWidgets.QVBoxLayout):
|
|||||||
self.file_list.filenames.pop(itemrow)
|
self.file_list.filenames.pop(itemrow)
|
||||||
self.file_list.takeItem(itemrow)
|
self.file_list.takeItem(itemrow)
|
||||||
self.file_list.files_updated.emit()
|
self.file_list.files_updated.emit()
|
||||||
|
|
||||||
self.file_list.setCurrentItem(None)
|
self.file_list.setCurrentItem(None)
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
@ -307,7 +325,7 @@ class FileSelection(QtWidgets.QVBoxLayout):
|
|||||||
Gets called when the server starts.
|
Gets called when the server starts.
|
||||||
"""
|
"""
|
||||||
self.server_on = True
|
self.server_on = True
|
||||||
self.file_list.setAcceptDrops(False)
|
self.file_list.server_started()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def server_stopped(self):
|
def server_stopped(self):
|
||||||
@ -315,7 +333,7 @@ class FileSelection(QtWidgets.QVBoxLayout):
|
|||||||
Gets called when the server stops.
|
Gets called when the server stops.
|
||||||
"""
|
"""
|
||||||
self.server_on = False
|
self.server_on = False
|
||||||
self.file_list.setAcceptDrops(True)
|
self.file_list.server_stopped()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def get_num_files(self):
|
def get_num_files(self):
|
||||||
|
@ -182,14 +182,6 @@ class ServerStatus(QtWidgets.QWidget):
|
|||||||
self.copy_url_button.hide()
|
self.copy_url_button.hide()
|
||||||
self.copy_hidservauth_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
|
||||||
button_stopped_style = 'QPushButton { background-color: #5fa416; color: #ffffff; padding: 10px; border: 0; border-radius: 5px; }'
|
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; }'
|
button_working_style = 'QPushButton { background-color: #4c8211; color: #ffffff; padding: 10px; border: 0; border-radius: 5px; font-style: italic; }'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user