moment/src/qml/Chat/Timeline/EventContent.qml

92 lines
2.9 KiB
QML
Raw Normal View History

2019-07-08 13:52:41 +10:00
// Copyright 2019 miruka
// This file is part of harmonyqml, licensed under LGPLv3.
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../Base"
import "../../utils.js" as Utils
2019-04-15 02:56:30 +10:00
Row {
2019-07-18 21:22:41 +10:00
id: eventContent
2019-07-16 19:29:47 +10:00
spacing: theme.spacing / 2
2019-07-18 21:22:41 +10:00
// layoutDirection: onRight ? Qt.RightToLeft : Qt.LeftToRight
2019-04-15 02:56:30 +10:00
Item {
width: hideAvatar ? 0 : 48
height: hideAvatar ? 0 : collapseAvatar ? 1 : smallAvatar ? 28 : 48
opacity: hideAvatar || collapseAvatar ? 0 : 1
2019-07-18 21:22:41 +10:00
visible: width > 0
HUserAvatar {
id: avatar
userId: model.senderId
width: hideAvatar ? 0 : 48
height: hideAvatar ? 0 : collapseAvatar ? 1 : 48
}
}
Rectangle {
color: isOwn?
theme.chat.message.ownBackground :
theme.chat.message.background
2019-04-15 02:56:30 +10:00
//width: nameLabel.implicitWidth
width: Math.min(
2019-07-18 21:22:41 +10:00
eventList.width - avatar.width - eventContent.spacing,
theme.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-07-20 15:35:25 +10:00
height: (nameLabel.visible ? nameLabel.height : 0) +
contentLabel.implicitHeight
y: parent.height / 2 - height / 2
Column {
spacing: 0
anchors.fill: parent
HLabel {
id: nameLabel
width: parent.width
2019-07-20 15:35:25 +10:00
visible: ! hideNameLine
text: senderInfo.displayName || model.senderId
color: Utils.nameColor(avatar.name)
elide: Text.ElideRight
horizontalAlignment: onRight ? Text.AlignRight : Text.AlignLeft
leftPadding: theme.spacing
rightPadding: leftPadding
topPadding: theme.spacing / 2
}
HRichLabel {
id: contentLabel
width: parent.width
2019-07-22 07:41:43 +10:00
text: theme.chat.message.styleInclude +
Utils.processedEventText(model) +
// time
"&nbsp;&nbsp;<font size=" + theme.fontSize.small +
"px color=" + theme.chat.message.date + ">" +
Qt.formatDateTime(model.date, "hh:mm:ss") +
"</font>" +
// local echo icon
(model.isLocalEcho ?
"&nbsp;<font size=" + theme.fontSize.small +
"px>⏳</font>" : "")
color: theme.chat.message.body
wrapMode: Text.Wrap
leftPadding: theme.spacing
rightPadding: leftPadding
topPadding: nameLabel.visible ? 0 : bottomPadding
bottomPadding: theme.spacing / 2
}
2019-04-15 02:56:30 +10:00
}
}
}