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
|
|
|
|
|
|
|
|
Row {
|
|
|
|
id: row
|
|
|
|
spacing: standardSpacing
|
|
|
|
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
|
|
|
|
anchors.right: isOwn ? parent.right : undefined
|
|
|
|
|
2019-04-29 01:32:02 +10:00
|
|
|
Base.HAvatar { id: avatar; hidden: combine; name: displayName }
|
2019-04-15 02:56:30 +10:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Base.HLabel {
|
|
|
|
visible: ! combine
|
|
|
|
id: nameLabel
|
2019-04-19 16:07:01 +10:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-04-29 01:21:19 +10:00
|
|
|
Base.HRichLabel {
|
2019-04-15 02:56:30 +10:00
|
|
|
id: contentLabel
|
2019-04-18 00:49:54 +10:00
|
|
|
text: (dict.formatted_body ?
|
2019-04-18 03:44:04 +10:00
|
|
|
Backend.htmlFilter.filter(dict.formatted_body) :
|
2019-04-18 00:49:54 +10:00
|
|
|
dict.body) +
|
2019-04-27 06:02:20 +10:00
|
|
|
" <font size=" + Base.HStyle.fontSize.small +
|
2019-04-29 01:01:38 +10:00
|
|
|
"px color=" + Base.HStyle.chat.message.date + ">" +
|
2019-04-21 07:36:21 +10:00
|
|
|
Qt.formatDateTime(dateTime, "hh:mm:ss") +
|
2019-04-19 03:46:39 +10:00
|
|
|
"</font>" +
|
2019-04-21 07:36:21 +10:00
|
|
|
(isLocalEcho ?
|
2019-04-27 06:02:20 +10:00
|
|
|
" <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
|
2019-04-18 06:43:18 +10:00
|
|
|
topPadding: nameLabel.visible ? 0 : verticalPadding
|
2019-04-15 02:56:30 +10:00
|
|
|
bottomPadding: verticalPadding
|
|
|
|
|
|
|
|
Layout.minimumWidth: nameLabel.implicitWidth
|
|
|
|
Layout.maximumWidth: Math.min(
|
|
|
|
600, messageListView.width - avatar.width - row.spacing
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|