[PATCH] controls: Fix link activation for text of InlineMessage
authorArjen Hiemstra <ahiemstra@heimr.nl>
Mon, 7 Apr 2025 15:26:11 +0000 (17:26 +0200)
committerAurélien COUDERC <coucouf@debian.org>
Tue, 20 May 2025 06:38:42 +0000 (08:38 +0200)
Rather than stretching both the label and toolbar across the entire
inline message, use implicit width for both, unless either would become
larger than the InlineMessage width. Most importantly, since the toolbar
only takes space that is not used by the text, this avoids links in the
text not working correctly.

BUG: 500578

Gbp-Pq: Name upstream_82abc769_controls-Fix-link-activation-for-text-of-InlineMessage.patch

src/controls/templates/InlineMessage.qml

index 6781c437e384165a81213118cb7f4915fd1cc5a4..ecf3b665562a9d69072a8047226da586329a1e20 100644 (file)
@@ -216,13 +216,9 @@ T.Control {
 
         Accessible.ignored: true
 
-        readonly property real remainingWidth: width - (
-            icon.width
-            + label.anchors.leftMargin + label.implicitWidth + label.anchors.rightMargin
-            + (root.showCloseButton ? closeButton.width : 0)
-        )
+        readonly property real fixedContentWidth: icon.width + Kirigami.Units.smallSpacing * 3 + (root.showCloseButton ? closeButton.width + Kirigami.Units.smallSpacing : 0)
+        readonly property real remainingWidth: width - fixedContentWidth - label.implicitWidth
         readonly property bool multiline: remainingWidth <= 0 || atBottom
-
         readonly property bool atBottom: (root.actions.length > 0) && (label.lineCount > 1 || actionsLayout.implicitWidth > remainingWidth)
 
         Kirigami.Icon {
@@ -302,11 +298,11 @@ T.Control {
             anchors {
                 left: icon.right
                 leftMargin: Kirigami.Units.largeSpacing
-                right: root.showCloseButton ? closeButton.left : parent.right
-                rightMargin: root.showCloseButton ? Kirigami.Units.smallSpacing : 0
                 top: parent.top
             }
 
+            width: Math.min(parent.width - parent.fixedContentWidth, implicitWidth)
+
             color: Kirigami.Theme.textColor
             wrapMode: Text.WordWrap
 
@@ -358,12 +354,13 @@ T.Control {
             alignment: Qt.AlignRight
 
             anchors {
-                left: parent.left
                 top: contentLayout.atBottom ? label.bottom : parent.top
                 topMargin: contentLayout.atBottom ? Kirigami.Units.largeSpacing : 0
                 right: (!contentLayout.atBottom && root.showCloseButton) ? closeButton.left : parent.right
                 rightMargin: !contentLayout.atBottom && root.showCloseButton ? Kirigami.Units.smallSpacing : 0
             }
+
+            width: Math.min(implicitWidth, parent.width)
         }
 
         QQC2.ToolButton {