From 7be8bd07b2d02c93ad9428abe32960c571f35e06 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 2 May 2023 17:02:26 +0200 Subject: [PATCH] Core: Don't change height of FancyToolButton for target chooser A freshly started Qt Creator showed a smaller target chooser button until a project was loaded. When loading a new project, the button changed its height which caused a noticeable jumping of the layout in the FancyActionBar. After closing the project the higher height remained. This change has the effect that the button has the final height right from the start of Qt Creator and that the jumping disappears. Change-Id: I6c9ac57c661398ba03d0b31269f62db28672ec91 Reviewed-by: Marcus Tillmanns Reviewed-by: Christian Stenger --- src/plugins/coreplugin/fancyactionbar.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp index 55904bf149b..a07dd718976 100644 --- a/src/plugins/coreplugin/fancyactionbar.cpp +++ b/src/plugins/coreplugin/fancyactionbar.cpp @@ -192,10 +192,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event) const int textFlags = Qt::AlignVCenter | Qt::AlignHCenter; const QString projectName = defaultAction()->property("heading").toString(); - if (!projectName.isNull()) - centerRect.adjust(0, lineHeight + 4, 0, 0); - - centerRect.adjust(0, 0, 0, -lineHeight * 2 - 4); + centerRect.adjust(0, lineHeight + 4, 0, -lineHeight * 2 - 4); iconRect.moveCenter(centerRect.center()); StyleHelper::drawIconWithShadow(icon(), iconRect, &painter, iconMode); @@ -294,12 +291,12 @@ QSize FancyToolButton::sizeHint() const boldFont.setBold(true); const QFontMetrics fm(boldFont); const qreal lineHeight = fm.height(); - const QString projectName = defaultAction()->property("heading").toString(); - buttonSize += QSizeF(0, 10); - if (!projectName.isEmpty()) - buttonSize += QSizeF(0, lineHeight + 2); - - buttonSize += QSizeF(0, lineHeight * 2 + 2); + const int extraHeight = 10 // Spacing between top and projectName + + lineHeight // projectName height + + 2 // Spacing between projectName and icon + + lineHeight * 2 // configurationName height (2 lines) + + 2; // Spacing between configurationName and bottom + buttonSize.rheight() += extraHeight; } return buttonSize.toSize(); }