From 2686a1ea77713742b4bffb8a810eb8dcd4ca2988 Mon Sep 17 00:00:00 2001 From: zhexu14 <64713351+zhexu14@users.noreply.github.com> Date: Wed, 4 Oct 2023 15:55:59 +1100 Subject: [PATCH] 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. --- qt_ui/windows/finances/QFinancesMenu.py | 12 ++++-------- qt_ui/windows/intel.py | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/qt_ui/windows/finances/QFinancesMenu.py b/qt_ui/windows/finances/QFinancesMenu.py index 77adcf48..a09b8eed 100644 --- a/qt_ui/windows/finances/QFinancesMenu.py +++ b/qt_ui/windows/finances/QFinancesMenu.py @@ -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"{budget:.1f}M") - self.setRowStretch(next(self.row), 1) def add_row( self, diff --git a/qt_ui/windows/intel.py b/qt_ui/windows/intel.py index 0a410704..bb169152 100644 --- a/qt_ui/windows/intel.py +++ b/qt_ui/windows/intel.py @@ -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):