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-07-04 12:31:29 +10:00
|
|
|
import "../../utils.js" as Utils
|
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-07-04 12:31:29 +10:00
|
|
|
name: senderInfo.displayName || Utils.stripUserId(model.senderId)
|
2019-07-03 12:22:29 +10:00
|
|
|
dimension: model.showNameLine ? 48 : 28
|
2019-05-09 01:18:22 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2019-07-04 14:24:21 +10:00
|
|
|
color: Utils.eventIsMessage(model) ?
|
2019-07-03 13:48:36 +10:00
|
|
|
HStyle.chat.message.background : HStyle.chat.event.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 {
|
|
|
|
width: parent.width
|
2019-07-03 12:22:29 +10:00
|
|
|
height: model.showNameLine && ! combine ? implicitHeight : 0
|
2019-05-09 01:18:22 +10:00
|
|
|
visible: height > 0
|
|
|
|
|
|
|
|
id: nameLabel
|
2019-07-03 03:59:52 +10:00
|
|
|
text: senderInfo.displayName || model.senderId
|
2019-07-05 06:56:34 +10:00
|
|
|
color: Utils.nameColor(avatar.name)
|
2019-05-09 01:18:22 +10:00
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 1
|
|
|
|
horizontalAlignment: isOwn ? Text.AlignRight : Text.AlignLeft
|
|
|
|
|
|
|
|
leftPadding: horizontalPadding
|
|
|
|
rightPadding: horizontalPadding
|
|
|
|
topPadding: verticalPadding
|
|
|
|
}
|
|
|
|
|
|
|
|
HRichLabel {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
id: contentLabel
|
2019-07-04 12:31:29 +10:00
|
|
|
text: Utils.translatedEventContent(model) +
|
|
|
|
// time
|
2019-05-09 01:18:22 +10:00
|
|
|
" <font size=" + HStyle.fontSize.small +
|
|
|
|
"px color=" + HStyle.chat.message.date + ">" +
|
2019-07-03 03:59:52 +10:00
|
|
|
Qt.formatDateTime(model.date, "hh:mm:ss") +
|
2019-05-09 01:18:22 +10:00
|
|
|
"</font>" +
|
2019-07-04 12:31:29 +10:00
|
|
|
// local echo icon
|
2019-07-03 03:59:52 +10:00
|
|
|
(model.isLocalEcho ?
|
2019-05-09 01:18:22 +10:00
|
|
|
" <font size=" + HStyle.fontSize.small +
|
|
|
|
"px>⏳</font>" : "")
|
2019-07-04 12:31:29 +10:00
|
|
|
|
2019-05-09 01:18:22 +10:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|