From 328e9a48e51bec5e740dfd4deefbac7f60e797a7 Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Sun, 2 Jan 2022 01:17:53 +0100 Subject: [PATCH] Prevent the UWT report from moving out of screen See #792. --- client/gui-qt/unitreport.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/gui-qt/unitreport.cpp b/client/gui-qt/unitreport.cpp index 9266ec402d..bec3347e0b 100644 --- a/client/gui-qt/unitreport.cpp +++ b/client/gui-qt/unitreport.cpp @@ -50,6 +50,7 @@ units_waiting::units_waiting(QWidget *parent) waiting_units->setEditTriggers(QAbstractItemView::NoEditTriggers); waiting_units->verticalHeader()->setVisible(false); waiting_units->horizontalHeader()->setVisible(true); + waiting_units->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); waiting_units->setSelectionMode(QAbstractItemView::SingleSelection); waiting_units->horizontalHeader()->resizeSections(QHeaderView::Stretch); waiting_units->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -133,10 +134,9 @@ void units_waiting::update_units() hide(); } - setFixedSize(waiting_units->horizontalHeader()->length() - + waiting_units->verticalHeader()->width() + 25, - waiting_units->verticalHeader()->length() - + waiting_units->horizontalHeader()->height() + 30); + auto max_height = parentWidget()->height() - y(); + auto want = sizeHint(); + setFixedSize(want.width(), std::min(want.height(), max_height)); } void units_waiting::showEvent(QShowEvent *event) { update_units(); }