[PATCH] controls: Improve calculation of InlineMessage implicit height
authorArjen Hiemstra <ahiemstra@heimr.nl>
Tue, 8 Apr 2025 09:10:47 +0000 (11:10 +0200)
committerAurélien COUDERC <coucouf@debian.org>
Tue, 20 May 2025 06:38:42 +0000 (08:38 +0200)
If the text isn't long enough to wrap into mulitple lines, but we have
many or large actions such that the actions are still put below the
text, the actions and close button would overlap because the close
button is not accounted for. To fix that, always anchor the actions at
the bottom and calculate a more proper implicit height for the entire
inline message that accounts for close button height if it is visible.

Gbp-Pq: Name upstream_2c6cd90f_controls-Improve-calculation-of-InlineMessage-implicit-height.patch

src/controls/templates/InlineMessage.qml

index ecf3b665562a9d69072a8047226da586329a1e20..f8a86889130ab0d479f1d939ed7b615b90aa6ed8 100644 (file)
@@ -207,10 +207,11 @@ T.Control {
         }
 
         implicitHeight: {
+            let maximumTopHeight = Math.max(label.implicitHeight, icon.implicitHeight, (root.showCloseButton ? closeButton.implicitHeight : 0))
             if (atBottom) {
-                return label.implicitHeight + actionsLayout.implicitHeight + actionsLayout.anchors.topMargin
+                return maximumTopHeight + actionsLayout.implicitHeight + Kirigami.Units.smallSpacing
             } else {
-                return Math.max(icon.implicitHeight, label.implicitHeight, closeButton.implicitHeight, actionsLayout.implicitHeight)
+                return Math.max(maximumTopHeight, actionsLayout.implicitHeight)
             }
         }
 
@@ -354,8 +355,7 @@ T.Control {
             alignment: Qt.AlignRight
 
             anchors {
-                top: contentLayout.atBottom ? label.bottom : parent.top
-                topMargin: contentLayout.atBottom ? Kirigami.Units.largeSpacing : 0
+                bottom: parent.bottom
                 right: (!contentLayout.atBottom && root.showCloseButton) ? closeButton.left : parent.right
                 rightMargin: !contentLayout.atBottom && root.showCloseButton ? Kirigami.Units.smallSpacing : 0
             }