moment/harmonyqml/components/chat/EventContent.qml

55 lines
1.6 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
import "utils.js" as ChatJS
2019-04-15 02:56:30 +10:00
RowLayout {
2019-04-15 02:56:30 +10:00
id: row
spacing: standardSpacing / 2
2019-04-15 02:56:30 +10:00
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
anchors.right: isOwn ? parent.right : undefined
readonly property string contentText:
isMessage ? "" : ChatJS.getEventText(type, dict)
2019-04-15 02:56:30 +10:00
Base.HAvatar {
2019-04-15 02:56:30 +10:00
id: avatar
name: displayName
2019-04-29 01:32:02 +10:00
hidden: combine
dimension: 28
2019-04-15 02:56:30 +10:00
}
Base.HLabel {
id: contentLabel
text: "<font color='" +
2019-04-29 01:01:38 +10:00
Qt.hsla(Backend.hueFromString(displayName.value || dict.sender),
Base.HStyle.chat.event.saturation,
Base.HStyle.chat.event.lightness,
1) +
"'>" +
(displayName.value || dict.sender) + " " +
contentText +
2019-04-29 01:01:38 +10:00
"&nbsp;&nbsp;" +
"<font size=" + Base.HStyle.fontSize.small + "px " +
"color=" + Base.HStyle.chat.event.date + ">" +
Qt.formatDateTime(dateTime, "hh:mm:ss") +
2019-04-29 01:01:38 +10:00
"</font> " +
"</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.event.background}
2019-04-15 02:56:30 +10:00
wrapMode: Text.Wrap
leftPadding: horizontalPadding
rightPadding: horizontalPadding
topPadding: verticalPadding
bottomPadding: verticalPadding
Layout.maximumWidth: Math.min(
600, messageListView.width - avatar.width - row.spacing
)
}
}