[PATCH] controls: Remove redundant states from InlineMessage
authorArjen Hiemstra <ahiemstra@heimr.nl>
Tue, 8 Apr 2025 09:12:26 +0000 (11:12 +0200)
committerAurélien COUDERC <coucouf@debian.org>
Tue, 20 May 2025 06:38:42 +0000 (08:38 +0200)
States describe changes from a base state. The base state can just be
declared normally, there is no need to declare it as a separate state.
This fixes centering the close button in single-line inline messages,
because the "centered" state was never activated.

Gbp-Pq: Name upstream_bae0957d_controls-Remove-redundant-states-from-InlineMessage.patch

src/controls/templates/InlineMessage.qml

index f8a86889130ab0d479f1d939ed7b615b90aa6ed8..f293c4b1e983d20c33728b9e7e989ac5e9a5240c 100644 (file)
@@ -300,6 +300,7 @@ T.Control {
                 left: icon.right
                 leftMargin: Kirigami.Units.largeSpacing
                 top: parent.top
+                bottom: parent.bottom
             }
 
             width: Math.min(parent.width - parent.fixedContentWidth, implicitWidth)
@@ -326,16 +327,6 @@ T.Control {
                         target: label
                         height: label.implicitHeight
                     }
-                },
-                // States are evaluated in the order they are declared.
-                // This is a fallback state.
-                State {
-                    name: "single-line"
-                    when: true
-                    AnchorChanges {
-                        target: label
-                        anchors.bottom: label.parent.bottom
-                    }
                 }
             ]
 
@@ -368,31 +359,22 @@ T.Control {
 
             visible: root.showCloseButton
 
-            anchors.right: parent.right
+            anchors {
+                verticalCenter: parent.verticalCenter
+                right: parent.right
+            }
 
             // Incompatible anchors need to be evaluated in a given order,
             // which simple declarative bindings cannot assure
-            states: [
-                State {
-                    name: "onTop"
-                    when: contentLayout.atBottom
-                    AnchorChanges {
-                        target: closeButton
-                        anchors.top: parent.top
-                        anchors.verticalCenter: undefined
-                    }
-                } ,
-                State {
-                    name: "centered"
-                    AnchorChanges {
-                        target: closeButton
-                        anchors.top: undefined
-                        anchors.verticalCenter: parent.verticalCenter
-                    }
+            states: State {
+                name: "onTop"
+                when: contentLayout.atBottom
+                AnchorChanges {
+                    target: closeButton
+                    anchors.top: parent.top
+                    anchors.verticalCenter: undefined
                 }
-            ]
-
-            height: contentLayout.atBottom ? implicitHeight : implicitHeight
+            }
 
             text: qsTr("Close")
             display: QQC2.ToolButton.IconOnly