mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Disable cancel actions on enemy transfers.
Decided to leave these in the menu as intel for the player, but the player can no longer cancel them. Fixes https://github.com/Khopa/dcs_liberation/issues/995
This commit is contained in:
parent
489b4d6acf
commit
c2ebf61fd3
@ -139,6 +139,10 @@ class PendingTransfersList(QListView):
|
|||||||
|
|
||||||
def contextMenuEvent(self, event: QContextMenuEvent) -> None:
|
def contextMenuEvent(self, event: QContextMenuEvent) -> None:
|
||||||
index = self.indexAt(event.pos())
|
index = self.indexAt(event.pos())
|
||||||
|
if not index.isValid():
|
||||||
|
return
|
||||||
|
if not self.transfer_model.transfer_at_index(index).player:
|
||||||
|
return
|
||||||
|
|
||||||
menu = QMenu("Menu")
|
menu = QMenu("Menu")
|
||||||
|
|
||||||
@ -181,15 +185,23 @@ class PendingTransfersDialog(QDialog):
|
|||||||
self.cancel_button = QPushButton("Cancel Transfer")
|
self.cancel_button = QPushButton("Cancel Transfer")
|
||||||
self.cancel_button.setProperty("style", "btn-danger")
|
self.cancel_button.setProperty("style", "btn-danger")
|
||||||
self.cancel_button.clicked.connect(self.on_cancel_transfer)
|
self.cancel_button.clicked.connect(self.on_cancel_transfer)
|
||||||
self.cancel_button.setEnabled(self.transfer_model.rowCount() > 0)
|
self.cancel_button.setEnabled(
|
||||||
|
self.can_cancel(self.transfer_list.currentIndex())
|
||||||
|
)
|
||||||
button_layout.addWidget(self.cancel_button)
|
button_layout.addWidget(self.cancel_button)
|
||||||
|
|
||||||
def on_cancel_transfer(self) -> None:
|
def on_cancel_transfer(self) -> None:
|
||||||
"""Cancels the selected transfer order."""
|
"""Cancels the selected transfer order."""
|
||||||
self.transfer_model.cancel_transfer_at_index(self.transfer_list.currentIndex())
|
self.transfer_model.cancel_transfer_at_index(self.transfer_list.currentIndex())
|
||||||
|
|
||||||
|
def can_cancel(self, index: QModelIndex) -> bool:
|
||||||
|
return self.transfer_model.transfer_at_index(index).player
|
||||||
|
|
||||||
def on_selection_changed(
|
def on_selection_changed(
|
||||||
self, selected: QItemSelection, _deselected: QItemSelection
|
self, selected: QItemSelection, _deselected: QItemSelection
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Updates the state of the delete button."""
|
"""Updates the state of the delete button."""
|
||||||
self.cancel_button.setEnabled(not selected.empty())
|
if selected.empty():
|
||||||
|
self.cancel_button.setEnabled(False)
|
||||||
|
return
|
||||||
|
self.cancel_button.setEnabled(self.can_cancel(selected.indexes()[0]))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user