moment/harmonyqml/components/Chat/RoomEventList/MessageContent.qml

63 lines
2.1 KiB
QML
Raw Normal View History

2019-04-15 02:56:30 +10:00
import QtQuick 2.7
import QtQuick.Layouts 1.3
import "../../Base"
2019-04-15 02:56:30 +10:00
Row {
id: row
spacing: standardSpacing / 2
2019-04-15 02:56:30 +10:00
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
HAvatar { id: avatar; hidden: combine; name: displayName }
2019-04-15 02:56:30 +10:00
HColumnLayout {
2019-04-15 02:56:30 +10:00
spacing: 0
HLabel {
2019-04-15 02:56:30 +10:00
visible: ! combine
id: nameLabel
text: displayName.value || dict.sender
background: Rectangle {color: HStyle.chat.message.background}
2019-04-29 01:01:38 +10:00
color: Qt.hsla(Backend.hueFromString(text),
HStyle.displayName.saturation,
HStyle.displayName.lightness,
2019-04-29 01:01:38 +10:00
1)
2019-04-15 02:56:30 +10:00
elide: Text.ElideRight
maximumLineCount: 1
Layout.preferredWidth: contentLabel.width
horizontalAlignment: isOwn ? Text.AlignRight : Text.AlignLeft
leftPadding: horizontalPadding
rightPadding: horizontalPadding
topPadding: verticalPadding
}
HRichLabel {
2019-04-15 02:56:30 +10:00
id: contentLabel
text: (dict.formatted_body ?
2019-04-18 03:44:04 +10:00
Backend.htmlFilter.filter(dict.formatted_body) :
dict.body) +
"&nbsp;&nbsp;<font size=" + HStyle.fontSize.small +
"px color=" + HStyle.chat.message.date + ">" +
Qt.formatDateTime(dateTime, "hh:mm:ss") +
"</font>" +
(isLocalEcho ?
"&nbsp;<font size=" + HStyle.fontSize.small +
2019-04-27 06:02:20 +10:00
"px>⏳</font>" : "")
2019-04-15 02:56:30 +10:00
textFormat: Text.RichText
background: Rectangle {color: HStyle.chat.message.background}
color: HStyle.chat.message.body
2019-04-15 02:56:30 +10:00
wrapMode: Text.Wrap
leftPadding: horizontalPadding
rightPadding: horizontalPadding
topPadding: nameLabel.visible ? 0 : verticalPadding
2019-04-15 02:56:30 +10:00
bottomPadding: verticalPadding
Layout.minimumWidth: nameLabel.implicitWidth
Layout.maximumWidth: Math.min(
600, roomEventListView.width - avatar.width - row.spacing
2019-04-15 02:56:30 +10:00
)
}
}
}