From a901351e7ed360d6c8ccb3e318a64650c8964400 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 10 Dec 2020 16:59:00 -0400 Subject: [PATCH] fix: chat reply width when content is smaller than author --- .../Chat/ChatColumn/MessageComponents/ChatReply.qml | 11 ++++++++++- .../ChatColumn/MessageComponents/NormalMessage.qml | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatReply.qml b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatReply.qml index 331efb4d77..50ad909dcf 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatReply.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatReply.qml @@ -1,9 +1,11 @@ -import QtQuick 2.3 +import QtQuick 2.14 import "../../../../../shared" import "../../../../../imports" Loader { property int textFieldWidth: item ? item.textField.width : 0 + property int authorWidth: item ? item.authorMetrics.width : 0 + property bool longReply: false property color elementsColor: isCurrentUser ? Style.current.chatReplyCurrentUser : Style.current.secondaryText @@ -13,6 +15,7 @@ Loader { sourceComponent: Component { Rectangle { property alias textField: lblReplyMessage + property alias authorMetrics: txtAuthorMetrics id: chatReply visible: responseTo != "" && replyMessageIndex > -1 @@ -20,6 +23,12 @@ Loader { height: this.visible ? lblReplyAuthor.height + ((repliedMessageType === Constants.imageType ? imgReplyImage.height : lblReplyMessage.height) + 5 + 8) : 0 color: Style.current.transparent + TextMetrics { + id: txtAuthorMetrics + font: lblReplyAuthor.font + text: lblReplyAuthor.text + } + StyledTextEdit { id: lblReplyAuthor text: "↳" + repliedMessageAuthor diff --git a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/NormalMessage.qml b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/NormalMessage.qml index 343ae8d116..008a9c80a0 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/NormalMessage.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/NormalMessage.qml @@ -96,6 +96,13 @@ Item { if (chatReply.visible && chatText.width < chatReply.textFieldWidth) { baseWidth = chatReply.textFieldWidth } + + if (chatReply.visible && chatText.width < chatReply.authorWidth) { + if(chatReply.authorWidth > baseWidth){ + baseWidth = chatReply.authorWidth + 20 + } + } + return baseWidth + 2 * chatHorizontalPadding } }