From 11f1bc747a36141da1d8a0ce71d633e732643a19 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 9 Jul 2023 20:11:25 +0200 Subject: [PATCH] Fix Qt5 builds Fix the Qt5 builds which do not know horizontalAdvance as a member of FontMetrics. Also refactor LedCheckBox::onTextUpdated to make it more compact. --- src/gui/widgets/LedCheckBox.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/gui/widgets/LedCheckBox.cpp b/src/gui/widgets/LedCheckBox.cpp index f607171f4..1d4f6468b 100644 --- a/src/gui/widgets/LedCheckBox.cpp +++ b/src/gui/widgets/LedCheckBox.cpp @@ -121,21 +121,12 @@ void LedCheckBox::initUi( LedColors _color ) void LedCheckBox::onTextUpdated() { - if (m_legacyMode) - { - setFixedSize(m_ledOffPixmap->width() + 5 + horizontalAdvance(QFontMetrics(font()), - text()), - m_ledOffPixmap->height()); - } - else - { - QFontMetrics fm(font()); + QFontMetrics const fm = fontMetrics(); - int const width = m_ledOffPixmap->width() + 5 + fm.horizontalAdvance(text()); - int const height = qMax(m_ledOffPixmap->height(), fm.height()); + int const width = m_ledOffPixmap->width() + 5 + horizontalAdvance(fm, text()); + int const height = m_legacyMode ? m_ledOffPixmap->height() : qMax(m_ledOffPixmap->height(), fm.height()); - setFixedSize(width, height); - } + setFixedSize(width, height); } void LedCheckBox::paintLegacy(QPaintEvent * pe)