Make the casualty report scrollable.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2567.
This commit is contained in:
Dan Albert 2022-11-25 12:53:05 -08:00
parent 627ed45065
commit b0bc46f539

View File

@ -8,12 +8,13 @@ from PySide2.QtWidgets import (
QGroupBox,
QLabel,
QPushButton,
QScrollArea,
QVBoxLayout,
QWidget,
)
from game.debriefing import Debriefing
T = TypeVar("T")
@ -52,6 +53,19 @@ class LossGrid(QGridLayout):
self.addWidget(QLabel(str(count)), row, 1)
class ScrollingCasualtyReportContainer(QGroupBox):
def __init__(self, debriefing: Debriefing, player: bool) -> None:
country = debriefing.player_country if player else debriefing.enemy_country
super().__init__(f"{country}'s lost units:")
scroll_content = QWidget()
scroll_content.setLayout(LossGrid(debriefing, player))
scroll_area = QScrollArea()
scroll_area.setWidget(scroll_content)
layout = QVBoxLayout()
layout.addWidget(scroll_area)
self.setLayout(layout)
class QDebriefingWindow(QDialog):
def __init__(self, debriefing: Debriefing):
super(QDebriefingWindow, self).__init__()
@ -75,12 +89,10 @@ class QDebriefingWindow(QDialog):
title = QLabel("<b>Casualty report</b>")
layout.addWidget(title)
player_lost_units = QGroupBox(f"{self.debriefing.player_country}'s lost units:")
player_lost_units.setLayout(LossGrid(debriefing, player=True))
player_lost_units = ScrollingCasualtyReportContainer(debriefing, player=True)
layout.addWidget(player_lost_units)
enemy_lost_units = QGroupBox(f"{self.debriefing.enemy_country}'s lost units:")
enemy_lost_units.setLayout(LossGrid(debriefing, player=False))
enemy_lost_units = ScrollingCasualtyReportContainer(debriefing, player=False)
layout.addWidget(enemy_lost_units)
okay = QPushButton("Okay")