2019-07-08 13:52:41 +10:00
|
|
|
// Copyright 2019 miruka
|
|
|
|
// This file is part of harmonyqml, licensed under LGPLv3.
|
|
|
|
|
2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-04-29 05:18:36 +10:00
|
|
|
import "../../Base"
|
2019-07-04 12:31:29 +10:00
|
|
|
import "../../utils.js" as Utils
|
2019-04-15 02:56:30 +10:00
|
|
|
|
|
|
|
Row {
|
2019-05-09 01:18:22 +10:00
|
|
|
id: messageContent
|
2019-07-16 19:29:47 +10:00
|
|
|
spacing: theme.spacing / 2
|
2019-04-15 02:56:30 +10:00
|
|
|
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
|
|
|
|
|
2019-07-07 14:24:23 +10:00
|
|
|
HUserAvatar {
|
2019-05-09 01:18:22 +10:00
|
|
|
id: avatar
|
2019-07-07 14:24:23 +10:00
|
|
|
userId: model.senderId
|
2019-07-14 10:15:20 +10:00
|
|
|
width: model.showNameLine ? 48 : 28
|
|
|
|
height: combine ? 1 : model.showNameLine ? 48 : 28
|
|
|
|
opacity: combine ? 0 : 1
|
2019-07-06 11:26:22 +10:00
|
|
|
visible: ! isOwn
|
2019-05-09 01:18:22 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2019-07-06 11:26:22 +10:00
|
|
|
color: isOwn?
|
2019-07-07 07:50:55 +10:00
|
|
|
theme.chat.message.ownBackground :
|
|
|
|
theme.chat.message.background
|
2019-04-15 02:56:30 +10:00
|
|
|
|
2019-05-09 01:18:22 +10:00
|
|
|
//width: nameLabel.implicitWidth
|
|
|
|
width: Math.min(
|
2019-07-14 10:15:20 +10:00
|
|
|
eventList.width - avatar.width - messageContent.spacing,
|
2019-07-07 07:50:55 +10:00
|
|
|
theme.fontSize.normal * 0.5 * 75, // 600 with 16px font
|
2019-05-09 01:18:22 +10:00
|
|
|
Math.max(
|
|
|
|
nameLabel.visible ? nameLabel.implicitWidth : 0,
|
|
|
|
contentLabel.implicitWidth
|
2019-04-15 02:56:30 +10:00
|
|
|
)
|
2019-05-09 01:18:22 +10:00
|
|
|
)
|
|
|
|
height: nameLabel.height + contentLabel.implicitHeight
|
|
|
|
|
|
|
|
Column {
|
|
|
|
spacing: 0
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
width: parent.width
|
2019-07-06 11:26:22 +10:00
|
|
|
height: model.showNameLine && ! isOwn && ! combine ?
|
|
|
|
implicitHeight : 0
|
2019-05-09 01:18:22 +10:00
|
|
|
visible: height > 0
|
|
|
|
|
|
|
|
id: nameLabel
|
2019-07-03 03:59:52 +10:00
|
|
|
text: senderInfo.displayName || model.senderId
|
2019-07-05 06:56:34 +10:00
|
|
|
color: Utils.nameColor(avatar.name)
|
2019-05-09 01:18:22 +10:00
|
|
|
elide: Text.ElideRight
|
|
|
|
horizontalAlignment: isOwn ? Text.AlignRight : Text.AlignLeft
|
|
|
|
|
|
|
|
leftPadding: horizontalPadding
|
|
|
|
rightPadding: horizontalPadding
|
|
|
|
topPadding: verticalPadding
|
|
|
|
}
|
|
|
|
|
|
|
|
HRichLabel {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
id: contentLabel
|
2019-07-04 12:31:29 +10:00
|
|
|
text: Utils.translatedEventContent(model) +
|
|
|
|
// time
|
2019-07-07 07:50:55 +10:00
|
|
|
" <font size=" + theme.fontSize.small +
|
|
|
|
"px color=" + theme.chat.message.date + ">" +
|
2019-07-03 03:59:52 +10:00
|
|
|
Qt.formatDateTime(model.date, "hh:mm:ss") +
|
2019-05-09 01:18:22 +10:00
|
|
|
"</font>" +
|
2019-07-04 12:31:29 +10:00
|
|
|
// local echo icon
|
2019-07-03 03:59:52 +10:00
|
|
|
(model.isLocalEcho ?
|
2019-07-07 07:50:55 +10:00
|
|
|
" <font size=" + theme.fontSize.small +
|
2019-05-09 01:18:22 +10:00
|
|
|
"px>⏳</font>" : "")
|
2019-07-04 12:31:29 +10:00
|
|
|
|
2019-07-07 07:50:55 +10:00
|
|
|
color: theme.chat.message.body
|
2019-05-09 01:18:22 +10:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
|
|
|
leftPadding: horizontalPadding
|
|
|
|
rightPadding: horizontalPadding
|
|
|
|
topPadding: nameLabel.visible ? 0 : verticalPadding
|
|
|
|
bottomPadding: verticalPadding
|
|
|
|
}
|
2019-04-15 02:56:30 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|