mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
PySide2 renamed to PySide6 for Qt 6 support. It doesn't seem like PySide2 is getting a 3.10 wheel, so upgrade to Qt 6 to prep for that.
32 lines
1019 B
Python
32 lines
1019 B
Python
"""Widgets for displaying client slots."""
|
|
from PySide6.QtWidgets import QLabel
|
|
|
|
from qt_ui.models import AtoModel
|
|
from qt_ui.widgets.QLabeledWidget import QLabeledWidget
|
|
|
|
|
|
class MaxPlayerCount(QLabeledWidget):
|
|
def __init__(self, ato_model: AtoModel) -> None:
|
|
self.ato_model = ato_model
|
|
self.slots_label = QLabel(str(self.count_client_slots))
|
|
self.ato_model.client_slots_changed.connect(self.update_count)
|
|
super().__init__(
|
|
"Max Players:",
|
|
self.slots_label,
|
|
(
|
|
"Total number of client slots. To add client slots, edit a flight "
|
|
"using the panel on the left."
|
|
),
|
|
)
|
|
|
|
@property
|
|
def count_client_slots(self) -> int:
|
|
slots = 0
|
|
for package in self.ato_model.packages:
|
|
for flight in package.flights:
|
|
slots += flight.client_count
|
|
return slots
|
|
|
|
def update_count(self) -> None:
|
|
self.slots_label.setText(str(self.count_client_slots))
|