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 <marcus.tillmanns@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Alessandro Portale
2023-05-02 17:02:26 +02:00
parent 874b1133d9
commit 7be8bd07b2

View File

@@ -192,10 +192,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
const int textFlags = Qt::AlignVCenter | Qt::AlignHCenter; const int textFlags = Qt::AlignVCenter | Qt::AlignHCenter;
const QString projectName = defaultAction()->property("heading").toString(); const QString projectName = defaultAction()->property("heading").toString();
if (!projectName.isNull()) centerRect.adjust(0, lineHeight + 4, 0, -lineHeight * 2 - 4);
centerRect.adjust(0, lineHeight + 4, 0, 0);
centerRect.adjust(0, 0, 0, -lineHeight * 2 - 4);
iconRect.moveCenter(centerRect.center()); iconRect.moveCenter(centerRect.center());
StyleHelper::drawIconWithShadow(icon(), iconRect, &painter, iconMode); StyleHelper::drawIconWithShadow(icon(), iconRect, &painter, iconMode);
@@ -294,12 +291,12 @@ QSize FancyToolButton::sizeHint() const
boldFont.setBold(true); boldFont.setBold(true);
const QFontMetrics fm(boldFont); const QFontMetrics fm(boldFont);
const qreal lineHeight = fm.height(); const qreal lineHeight = fm.height();
const QString projectName = defaultAction()->property("heading").toString(); const int extraHeight = 10 // Spacing between top and projectName
buttonSize += QSizeF(0, 10); + lineHeight // projectName height
if (!projectName.isEmpty()) + 2 // Spacing between projectName and icon
buttonSize += QSizeF(0, lineHeight + 2); + lineHeight * 2 // configurationName height (2 lines)
+ 2; // Spacing between configurationName and bottom
buttonSize += QSizeF(0, lineHeight * 2 + 2); buttonSize.rheight() += extraHeight;
} }
return buttonSize.toSize(); return buttonSize.toSize();
} }