Fix odd whitespace in finance menu.

Moves the stretch to the bottom of the page to avoid awkward whitespace
in the middle. Presumably the totals used to be at the bottom (since
that's a normal place for a total), but it was moved to the top,
probably since that was the most interesting data and we didn't want to
scroll though all the details to find that one point.

This also removes the unused code path where the total would be shown at
the bottom.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1288.
This commit is contained in:
zhexu14 2023-10-04 15:55:59 +11:00 committed by GitHub
parent 256c9ce73d
commit 2686a1ea77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 9 deletions

View File

@ -26,15 +26,14 @@ class QHorizontalSeparationLine(QFrame):
class FinancesLayout(QGridLayout):
def __init__(self, game: Game, player: bool, total_at_top: bool = False) -> None:
def __init__(self, game: Game, player: bool) -> None:
super().__init__()
self.row = itertools.count(0)
income = Income(game, player)
if total_at_top:
self.add_total(game, income, player)
self.add_line()
self.add_total(game, income, player)
self.add_line()
control_points = reversed(
sorted(income.control_points, key=lambda c: c.income_per_turn)
@ -48,9 +47,7 @@ class FinancesLayout(QGridLayout):
for building in buildings:
self.add_building(building)
if not total_at_top:
self.add_line()
self.add_total(game, income, player)
self.setRowStretch(next(self.row), 1)
def add_total(self, game, income, player):
self.add_row(
@ -59,7 +56,6 @@ class FinancesLayout(QGridLayout):
)
budget = game.coalition_for(player).budget
self.add_row(middle="Balance", right=f"<b>{budget:.1f}M</b>")
self.setRowStretch(next(self.row), 1)
def add_row(
self,

View File

@ -46,7 +46,7 @@ class ScrollingFrame(QFrame):
class EconomyIntelTab(ScrollingFrame):
def __init__(self, game: Game, player: bool) -> None:
super().__init__()
self.addLayout(FinancesLayout(game, player=player, total_at_top=True))
self.addLayout(FinancesLayout(game, player=player))
class IntelTableLayout(QGridLayout):