[PATCH] layout: Set implicit width of ToolBarLayout before using its width
authorArjen Hiemstra <ahiemstra@heimr.nl>
Mon, 7 Apr 2025 15:21:41 +0000 (17:21 +0200)
committerAurélien COUDERC <coucouf@debian.org>
Tue, 20 May 2025 06:38:42 +0000 (08:38 +0200)
Split setting implicit size into setting width and height separately, so
that we if we use width() it will use the implicit width if no width was
set yet. This avoids us hiding all actions because width is 0, only to
then show them again because implicit width (and thus width) is now a
valid value.

Gbp-Pq: Name upstream_81352c22_layout-Set-implicit-width-of-ToolBarLayout-before-using-its-width.patch

src/layouts/toolbarlayout.cpp

index dce591be3ac91e713dd185ee40cce2ada0f3bf2b..2e214c2befc81078ccb8888db62fb59296e1369f 100644 (file)
@@ -441,6 +441,8 @@ void ToolBarLayoutPrivate::calculateImplicitSize()
 
     visibleActionsWidth = 0.0;
 
+    q->setImplicitWidth(maxWidth);
+
     if (maxWidth > q->width() - (hiddenActions.isEmpty() ? 0.0 : moreButtonInstance->width() + spacing)) {
         // We have more items than fit into the view, so start hiding some.
 
@@ -473,7 +475,8 @@ void ToolBarLayoutPrivate::calculateImplicitSize()
         maxHeight = std::max(maxHeight, moreButtonInstance->implicitHeight());
     };
 
-    q->setImplicitSize(maxWidth, maxHeight);
+    q->setImplicitHeight(maxHeight);
+
     Q_EMIT q->hiddenActionsChanged();
 
     implicitSizeValid = true;