From 95ff85a79a606b2c36dc3c1ebad48a8cb61183e7 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 25 Sep 2017 23:53:56 +0200 Subject: [PATCH] Make sure transport data text is centered --- resources/ui/carla_host.ui | 4 ++-- source/carla_host.py | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/resources/ui/carla_host.ui b/resources/ui/carla_host.ui index 40e00f816..e3fae9f0b 100644 --- a/resources/ui/carla_host.ui +++ b/resources/ui/carla_host.ui @@ -559,7 +559,7 @@ - 00000000 + 000'000'000 @@ -611,7 +611,7 @@ - 000|0|000 + 000|00|000 diff --git a/source/carla_host.py b/source/carla_host.py index 008728923..cbecd605d 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -272,9 +272,25 @@ class HostWindow(QMainWindow): # ---------------------------------------------------------------------------------------------------- # Set up GUI (transport) - self.ui.l_transport_bbt.setMinimumWidth(QFontMetrics(self.ui.l_transport_bbt.font()).width("000|00|0000") + 3) - self.ui.l_transport_frame.setMinimumWidth(QFontMetrics(self.ui.l_transport_frame.font()).width("000'000'000") + 3) - self.ui.l_transport_time.setMinimumWidth(QFontMetrics(self.ui.l_transport_time.font()).width("00:00:00") + 3) + fontMetrics = QFontMetrics(self.ui.l_transport_bbt.font()) + minValueWidth = fontMetrics.width("000|00|0000") + minLabelWidth = fontMetrics.width(self.ui.label_transport_frame.text()) + + labelTimeWidth = fontMetrics.width(self.ui.label_transport_time.text()) + labelBBTWidth = fontMetrics.width(self.ui.label_transport_bbt.text()) + + if minLabelWidth < labelTimeWidth: + minLabelWidth = labelTimeWidth + if minLabelWidth < labelBBTWidth: + minLabelWidth = labelBBTWidth + + self.ui.label_transport_frame.setMinimumWidth(minLabelWidth + 3) + self.ui.label_transport_time.setMinimumWidth(minLabelWidth + 3) + self.ui.label_transport_bbt.setMinimumWidth(minLabelWidth + 3) + + self.ui.l_transport_bbt.setMinimumWidth(minValueWidth + 3) + self.ui.l_transport_frame.setMinimumWidth(minValueWidth + 3) + self.ui.l_transport_time.setMinimumWidth(minValueWidth + 3) if host.isPlugin: self.ui.b_transport_play.setEnabled(False)