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

64 lines
2.2 KiB
QML
Raw Normal View History

2019-04-15 02:56:30 +10:00
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.4
import "../../Base" as Base
2019-04-15 02:56:30 +10:00
Row {
id: row
spacing: standardSpacing
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
2019-04-29 01:32:02 +10:00
Base.HAvatar { id: avatar; hidden: combine; name: displayName }
2019-04-15 02:56:30 +10:00
Base.HColumnLayout {
2019-04-15 02:56:30 +10:00
spacing: 0
Base.HLabel {
visible: ! combine
id: nameLabel
text: displayName.value || dict.sender
2019-04-29 01:01:38 +10:00
background: Rectangle {color: Base.HStyle.chat.message.background}
color: Qt.hsla(Backend.hueFromString(text),
Base.HStyle.displayName.saturation,
Base.HStyle.displayName.lightness,
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
}
Base.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) +
2019-04-27 06:02:20 +10:00
"&nbsp;&nbsp;<font size=" + Base.HStyle.fontSize.small +
2019-04-29 01:01:38 +10:00
"px color=" + Base.HStyle.chat.message.date + ">" +
Qt.formatDateTime(dateTime, "hh:mm:ss") +
"</font>" +
(isLocalEcho ?
2019-04-27 06:02:20 +10:00
"&nbsp;<font size=" + Base.HStyle.fontSize.small +
"px>⏳</font>" : "")
2019-04-15 02:56:30 +10:00
textFormat: Text.RichText
2019-04-29 01:01:38 +10:00
background: Rectangle {color: Base.HStyle.chat.message.background}
color: Base.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.totalSpacing
2019-04-15 02:56:30 +10:00
)
}
}
}