2019-04-15 02:56:30 +10:00
|
|
|
import QtQuick 2.7
|
2019-04-29 05:45:42 +10:00
|
|
|
import QtQuick.Layouts 1.3
|
2019-04-29 05:18:36 +10:00
|
|
|
import "../../Base"
|
2019-04-15 02:56:30 +10:00
|
|
|
|
|
|
|
Row {
|
2019-05-09 01:18:22 +10:00
|
|
|
id: messageContent
|
2019-04-30 13:58:17 +10:00
|
|
|
spacing: standardSpacing / 2
|
2019-04-15 02:56:30 +10:00
|
|
|
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
|
|
|
|
|
2019-05-09 01:18:22 +10:00
|
|
|
HAvatar {
|
|
|
|
id: avatar
|
|
|
|
hidden: combine
|
2019-05-12 05:52:56 +10:00
|
|
|
name: sender.displayName.value
|
2019-05-16 07:01:58 +10:00
|
|
|
dimension: 48
|
2019-05-09 01:18:22 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: HStyle.chat.message.background
|
2019-04-15 02:56:30 +10:00
|
|
|
|
2019-05-09 01:18:22 +10:00
|
|
|
//width: nameLabel.implicitWidth
|
|
|
|
width: Math.min(
|
|
|
|
roomEventListView.width - avatar.width - messageContent.spacing,
|
|
|
|
HStyle.fontSize.normal * 0.5 * 75, // 600 with 16px font
|
|
|
|
Math.max(
|
|
|
|
nameLabel.visible ? nameLabel.implicitWidth : 0,
|
|
|
|
contentLabel.implicitWidth
|
2019-04-15 02:56:30 +10:00
|
|
|
)
|
2019-05-09 01:18:22 +10:00
|
|
|
)
|
|
|
|
height: nameLabel.height + contentLabel.implicitHeight
|
|
|
|
|
|
|
|
Column {
|
|
|
|
spacing: 0
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
height: combine ? 0 : implicitHeight
|
|
|
|
width: parent.width
|
|
|
|
visible: height > 0
|
|
|
|
|
|
|
|
id: nameLabel
|
2019-05-12 05:52:56 +10:00
|
|
|
text: sender.displayName.value
|
2019-05-09 01:18:22 +10:00
|
|
|
color: Qt.hsla(Backend.hueFromString(text),
|
|
|
|
HStyle.displayName.saturation,
|
|
|
|
HStyle.displayName.lightness,
|
|
|
|
1)
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 1
|
|
|
|
horizontalAlignment: isOwn ? Text.AlignRight : Text.AlignLeft
|
|
|
|
|
|
|
|
leftPadding: horizontalPadding
|
|
|
|
rightPadding: horizontalPadding
|
|
|
|
topPadding: verticalPadding
|
|
|
|
}
|
|
|
|
|
|
|
|
HRichLabel {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
id: contentLabel
|
|
|
|
text: (dict.formatted_body ?
|
|
|
|
Backend.htmlFilter.filter(dict.formatted_body) :
|
|
|
|
dict.body) +
|
|
|
|
" <font size=" + HStyle.fontSize.small +
|
|
|
|
"px color=" + HStyle.chat.message.date + ">" +
|
|
|
|
Qt.formatDateTime(dateTime, "hh:mm:ss") +
|
|
|
|
"</font>" +
|
|
|
|
(isLocalEcho ?
|
|
|
|
" <font size=" + HStyle.fontSize.small +
|
|
|
|
"px>⏳</font>" : "")
|
|
|
|
textFormat: Text.RichText
|
|
|
|
color: HStyle.chat.message.body
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
|
|
|
leftPadding: horizontalPadding
|
|
|
|
rightPadding: horizontalPadding
|
|
|
|
topPadding: nameLabel.visible ? 0 : verticalPadding
|
|
|
|
bottomPadding: verticalPadding
|
|
|
|
}
|
2019-04-15 02:56:30 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|