fix(DAppSignRequestModal): correctly compute text painted height (#15864)

- fixes text overflowing the box height

Fixes #15650
This commit is contained in:
Lukáš Tinkl 2024-07-29 20:40:32 +02:00 committed by GitHub
parent 77addc0b5b
commit 41b37def71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 87 additions and 79 deletions

View File

@ -86,6 +86,11 @@ SplitView {
} }
} }
}', }',
"
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce nibh. Etiam quis quam. In dapibus augue non sapien. Praesent id justo in neque elementum ultrices. Morbi scelerisque luctus velit. Vivamus ac leo pretium faucibus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. Nullam eget nisl. Aliquam erat volutpat.
Proin pede metus, vulputate nec, fermentum fringilla, vehicula vitae, justo. Fusce nibh. Etiam quis quam. In dapibus augue non sapien. Praesent id justo in neque elementum ultrices. Fusce nibh. Etiam quis quam. In dapibus augue non sapien. Praesent id justo in neque elementum ultrices. Fusce nibh. Etiam quis quam. In dapibus augue non sapien. Praesent id justo in neque elementum ultrices. Fusce nibh. Etiam quis quam. In dapibus augue non sapien. Praesent id justo in neque elementum ultrices.
",
'"tx":{"data":"0x","from":"0xE2d622C817878dA5143bBE06866ca8E35273Ba8a","gasLimit":"0x5208","gasPrice":"0x048ddbc5","nonce":"0x2a","to":"0xE2d622C817878dA5143bBE06866ca8E35273Ba8a","value":"0x00"}', '"tx":{"data":"0x","from":"0xE2d622C817878dA5143bBE06866ca8E35273Ba8a","gasLimit":"0x5208","gasPrice":"0x048ddbc5","nonce":"0x2a","to":"0xE2d622C817878dA5143bBE06866ca8E35273Ba8a","value":"0x00"}',
"" ""
] ]
@ -104,7 +109,7 @@ SplitView {
} }
ComboBox { ComboBox {
id: contentToSignComboBox id: contentToSignComboBox
model: ["Long content to sign", "Short content to sign", "Empty content to sign"] model: ["Long content to sign", "Middle content to sign", "Short content to sign", "Empty content to sign"]
currentIndex: 0 currentIndex: 0
} }
CheckBox { CheckBox {

View File

@ -127,6 +127,7 @@ SignTransactionModalBase {
ContentPanel { ContentPanel {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.bottomMargin: Style.current.bigPadding
payloadToDisplay: root.requestPayload payloadToDisplay: root.requestPayload
visible: !!root.requestPayload visible: !!root.requestPayload
} }

View File

@ -18,8 +18,8 @@ Rectangle {
color: "transparent" color: "transparent"
radius: 8 radius: 8
implicitHeight: d.expanded ? contentText.implicitHeight + (2 * contentText.anchors.margins) : implicitHeight: d.expanded ? contentText.implicitHeight + (2 * contentText.anchors.margins)
Math.min(contentText.implicitHeight + (2 * contentText.anchors.margins), 200) : Math.min(contentText.implicitHeight + (2 * contentText.anchors.margins), d.maxContentHeight)
HoverHandler { HoverHandler {
id: hoverHandler id: hoverHandler
@ -38,20 +38,7 @@ Rectangle {
lineHeightMode: Text.FixedHeight lineHeightMode: Text.FixedHeight
lineHeight: 18 lineHeight: 18
wrapMode: Text.WrapAnywhere wrapMode: Text.Wrap
StatusFlatButton {
objectName: "expandButton"
anchors.top: parent.top
anchors.right: parent.right
icon.name: d.expanded ? "collapse" : "expand"
icon.color: hovered ? Theme.palette.directColor1 : Theme.palette.baseColor1
hoverColor: "transparent"
visible: d.canExpand && hoverHandler.hovered
onClicked: {
d.expanded = !d.expanded
}
}
layer.enabled: !d.expanded && d.canExpand layer.enabled: !d.expanded && d.canExpand
layer.effect: OpacityMask { layer.effect: OpacityMask {
@ -68,10 +55,25 @@ Rectangle {
} }
} }
StatusFlatButton {
objectName: "expandButton"
anchors.top: parent.top
anchors.topMargin: 4
anchors.right: parent.right
anchors.rightMargin: 4
icon.name: d.expanded ? "collapse" : "expand"
icon.color: hovered ? Theme.palette.directColor1 : Theme.palette.baseColor1
hoverColor: "transparent"
visible: d.canExpand && hoverHandler.hovered
onClicked: {
d.expanded = !d.expanded
}
}
QtObject { QtObject {
id: d id: d
readonly property int maxContentHeight: 350 readonly property int maxContentHeight: 350
property bool expanded: false property bool expanded: false
property bool canExpand: contentText.implicitHeight > maxContentHeight readonly property bool canExpand: contentText.paintedHeight + (2 * contentText.anchors.margins) > maxContentHeight
} }
} }