2020-12-10 20:59:00 +00:00
|
|
|
import QtQuick 2.14
|
2021-04-23 15:49:05 +00:00
|
|
|
import QtQuick.Shapes 1.13
|
|
|
|
import QtGraphicalEffects 1.13
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2021-10-28 20:23:30 +00:00
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.status 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.controls.chat 1.0
|
2020-07-15 21:04:14 +00:00
|
|
|
|
2022-03-07 14:56:05 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
|
|
|
|
2020-09-30 20:40:54 +00:00
|
|
|
Loader {
|
2021-10-01 15:58:36 +00:00
|
|
|
id: root
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
property bool amISenderOfTheRepliedMessage
|
|
|
|
property int repliedMessageContentType
|
|
|
|
property string repliedMessageSenderIcon
|
|
|
|
property bool repliedMessageSenderIconIsIdenticon
|
|
|
|
property bool repliedMessageIsEdited
|
|
|
|
property string repliedMessageSender
|
2022-03-09 10:27:32 +00:00
|
|
|
property string repliedMessageSenderPubkey
|
|
|
|
property bool repliedMessageSenderIsAdded
|
2021-12-09 12:53:40 +00:00
|
|
|
property string repliedMessageContent
|
|
|
|
property string repliedMessageImage
|
2021-12-08 21:20:43 +00:00
|
|
|
property bool isCurrentUser: false
|
2021-10-01 15:58:36 +00:00
|
|
|
property int nameMargin: 6
|
2020-09-30 20:40:54 +00:00
|
|
|
property int textFieldWidth: item ? item.textField.width : 0
|
2021-02-08 18:46:20 +00:00
|
|
|
property int textFieldImplicitWidth: 0
|
2020-12-10 20:59:00 +00:00
|
|
|
property int authorWidth: item ? item.authorMetrics.width : 0
|
2021-10-21 00:41:54 +00:00
|
|
|
property bool longReply: false
|
2021-12-09 12:53:40 +00:00
|
|
|
property color elementsColor: amISenderOfTheRepliedMessage ? Style.current.chatReplyCurrentUser : Style.current.secondaryText
|
2021-10-21 00:41:54 +00:00
|
|
|
property var container
|
|
|
|
property int chatHorizontalPadding
|
|
|
|
property var stickerData
|
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool emojiOnly, bool hideEmojiPicker, bool isReply)
|
|
|
|
signal scrollToBottom(bool isit, var container)
|
2020-07-15 21:04:14 +00:00
|
|
|
|
2020-09-30 20:40:54 +00:00
|
|
|
sourceComponent: Component {
|
2021-02-08 18:46:20 +00:00
|
|
|
Item {
|
2020-09-30 20:40:54 +00:00
|
|
|
property alias textField: lblReplyMessage
|
2020-12-10 20:59:00 +00:00
|
|
|
property alias authorMetrics: txtAuthorMetrics
|
2020-07-17 19:44:25 +00:00
|
|
|
|
2020-09-30 20:40:54 +00:00
|
|
|
id: chatReply
|
2021-02-08 18:46:20 +00:00
|
|
|
// childrenRect.height shows a binding loop for some reason, so we use heights instead
|
2021-04-23 15:49:05 +00:00
|
|
|
height: {
|
2021-07-02 16:13:53 +00:00
|
|
|
const h = userImage.height + 4
|
2021-12-09 12:53:40 +00:00
|
|
|
if (repliedMessageContentType === Constants.messageContentType.imageType) {
|
2021-04-23 15:49:05 +00:00
|
|
|
return h + imgReplyImage.height
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
if (repliedMessageContentType === Constants.messageContentType.stickerType) {
|
2021-04-23 15:49:05 +00:00
|
|
|
return h + stickerLoader.height
|
|
|
|
}
|
|
|
|
return h + lblReplyMessage.height
|
|
|
|
}
|
|
|
|
width: parent.width
|
|
|
|
clip: true
|
2020-09-30 20:40:54 +00:00
|
|
|
|
2020-12-10 20:59:00 +00:00
|
|
|
TextMetrics {
|
|
|
|
id: txtAuthorMetrics
|
|
|
|
font: lblReplyAuthor.font
|
|
|
|
text: lblReplyAuthor.text
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:49:05 +00:00
|
|
|
Shape {
|
|
|
|
id: replyCorner
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 20 - 1
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
width: 20
|
|
|
|
height: parent.height - anchors.topMargin
|
|
|
|
asynchronous: true
|
|
|
|
antialiasing: true
|
|
|
|
|
|
|
|
ShapePath {
|
|
|
|
id: capTest
|
|
|
|
|
|
|
|
strokeColor: Utils.setColorAlpha(root.elementsColor, 0.4)
|
|
|
|
strokeWidth: 3
|
|
|
|
fillColor: "transparent"
|
|
|
|
|
|
|
|
capStyle: ShapePath.RoundCap
|
|
|
|
joinStyle: ShapePath.RoundJoin
|
|
|
|
|
|
|
|
startX: 20
|
|
|
|
startY: 0
|
|
|
|
PathLine { x: 10; y: 0 }
|
|
|
|
PathArc {
|
|
|
|
x: 0; y: 10
|
|
|
|
radiusX: 13
|
|
|
|
radiusY: 13
|
|
|
|
direction: PathArc.Counterclockwise
|
|
|
|
}
|
|
|
|
PathLine { x: 0; y: chatReply.height - replyCorner.anchors.topMargin }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UserImage {
|
|
|
|
id: userImage
|
2022-03-09 10:27:32 +00:00
|
|
|
anchors.left: replyCorner.right
|
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
|
|
|
|
2021-04-23 15:49:05 +00:00
|
|
|
imageHeight: 20
|
|
|
|
imageWidth: 20
|
|
|
|
active: true
|
2022-03-09 10:27:32 +00:00
|
|
|
|
|
|
|
name: repliedMessageSender
|
|
|
|
pubkey: repliedMessageSenderPubkey
|
2021-12-09 12:53:40 +00:00
|
|
|
icon: repliedMessageSenderIcon
|
|
|
|
isIdenticon: repliedMessageSenderIconIsIdenticon
|
2022-03-09 10:27:32 +00:00
|
|
|
showRing: !(amISenderOfTheRepliedMessage || repliedMessageSenderIsAdded)
|
|
|
|
|
|
|
|
onClicked: root.clickMessage(true, false, false, null, false, false, true)
|
2021-06-29 14:49:32 +00:00
|
|
|
}
|
|
|
|
|
2020-09-30 20:40:54 +00:00
|
|
|
StyledTextEdit {
|
|
|
|
id: lblReplyAuthor
|
2021-12-09 12:53:40 +00:00
|
|
|
text: repliedMessageSender
|
2020-09-30 20:40:54 +00:00
|
|
|
color: root.elementsColor
|
|
|
|
readOnly: true
|
2021-04-23 15:49:05 +00:00
|
|
|
font.pixelSize: Style.current.secondaryTextFontSize
|
2020-09-30 20:40:54 +00:00
|
|
|
selectByMouse: true
|
2021-04-23 15:49:05 +00:00
|
|
|
font.weight: Font.Medium
|
|
|
|
anchors.verticalCenter: userImage.verticalCenter
|
|
|
|
anchors.left: userImage.right
|
|
|
|
anchors.leftMargin: 5
|
2020-09-30 20:40:54 +00:00
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
|
2021-08-30 12:42:11 +00:00
|
|
|
StatusChatImage {
|
2020-09-30 20:40:54 +00:00
|
|
|
id: imgReplyImage
|
2021-12-09 12:53:40 +00:00
|
|
|
visible: repliedMessageContentType === Constants.messageContentType.imageType
|
2020-09-30 20:40:54 +00:00
|
|
|
imageWidth: 50
|
|
|
|
imageSource: repliedMessageImage
|
|
|
|
anchors.top: lblReplyAuthor.bottom
|
2021-04-23 15:49:05 +00:00
|
|
|
anchors.topMargin: nameMargin
|
|
|
|
anchors.left: userImage.left
|
2020-09-30 20:40:54 +00:00
|
|
|
chatHorizontalPadding: 0
|
2020-12-16 20:50:54 +00:00
|
|
|
container: root.container
|
2021-04-23 15:49:05 +00:00
|
|
|
allCornersRounded: true
|
2022-02-22 20:48:57 +00:00
|
|
|
playing: false
|
2021-04-23 15:49:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: stickerLoader
|
2021-12-09 12:53:40 +00:00
|
|
|
active: repliedMessageContentType === Constants.messageContentType.stickerType
|
2021-04-23 15:49:05 +00:00
|
|
|
anchors.top: lblReplyAuthor.bottom
|
|
|
|
anchors.topMargin: nameMargin
|
|
|
|
anchors.left: userImage.left
|
|
|
|
sourceComponent: Component {
|
2021-08-30 12:42:11 +00:00
|
|
|
StatusSticker {
|
2021-04-23 15:49:05 +00:00
|
|
|
id: stickerId
|
|
|
|
imageHeight: 56
|
|
|
|
imageWidth: 56
|
2021-10-01 15:58:36 +00:00
|
|
|
stickerData: root.stickerData
|
2021-12-09 12:53:40 +00:00
|
|
|
contentType: repliedMessageContentType
|
2021-08-30 12:42:11 +00:00
|
|
|
onLoaded: {
|
|
|
|
scrollToBottom(true, root.container)
|
|
|
|
}
|
2021-04-23 15:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-30 20:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StyledTextEdit {
|
|
|
|
id: lblReplyMessage
|
2021-12-09 12:53:40 +00:00
|
|
|
visible: repliedMessageContentType !== Constants.messageContentType.imageType && repliedMessageContentType !== Constants.messageContentType.stickerType
|
2021-02-08 18:46:20 +00:00
|
|
|
Component.onCompleted: textFieldImplicitWidth = implicitWidth
|
2020-09-30 20:40:54 +00:00
|
|
|
anchors.top: lblReplyAuthor.bottom
|
2021-04-23 15:49:05 +00:00
|
|
|
anchors.topMargin: nameMargin
|
2021-06-29 14:49:32 +00:00
|
|
|
text: {
|
|
|
|
if (repliedMessageIsEdited){
|
|
|
|
let index = repliedMessageContent.length - 4
|
2022-03-07 14:56:05 +00:00
|
|
|
return Utils.getReplyMessageStyle(StatusQUtils.Emoji.parse(Utils.linkifyAndXSS(repliedMessageContent.slice(0, index) + Constants.editLabel + repliedMessageContent.slice(index)), StatusQUtils.Emoji.size.small), amISenderOfTheRepliedMessage)
|
2021-06-29 14:49:32 +00:00
|
|
|
} else {
|
2022-03-07 14:56:05 +00:00
|
|
|
return Utils.getReplyMessageStyle(StatusQUtils.Emoji.parse(Utils.linkifyAndXSS(repliedMessageContent), StatusQUtils.Emoji.size.small), amISenderOfTheRepliedMessage)
|
2021-06-29 14:49:32 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-30 20:40:54 +00:00
|
|
|
textFormat: Text.RichText
|
|
|
|
color: root.elementsColor
|
|
|
|
readOnly: true
|
|
|
|
selectByMouse: true
|
2021-08-06 12:21:51 +00:00
|
|
|
font.pixelSize: Style.current.additionalTextSize
|
|
|
|
font.weight: Font.Medium
|
2021-04-23 15:49:05 +00:00
|
|
|
anchors.left: userImage.left
|
2021-02-08 18:46:20 +00:00
|
|
|
width: root.longReply ? parent.width : implicitWidth
|
2021-07-02 16:13:53 +00:00
|
|
|
height: 20
|
2021-04-23 15:49:05 +00:00
|
|
|
clip: true
|
2020-09-30 20:40:54 +00:00
|
|
|
z: 51
|
|
|
|
}
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-30 20:40:54 +00:00
|
|
|
|