Leave the FileList enabled, but hide the item buttons when the server is working or started

This commit is contained in:
Miguel Jacq 2018-02-07 17:34:36 +11:00
parent 0b18129947
commit 2b15020e7d
No known key found for this signature in database
GPG Key ID: EEA4341C6D97A0B6
2 changed files with 10 additions and 8 deletions

View File

@ -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)

View File

@ -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; }'