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-04-30 13:58:17 +10:00
|
|
|
spacing: standardSpacing / 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
|
|
|
|
hidden: combine
|
2019-07-07 14:24:23 +10:00
|
|
|
userId: model.senderId
|
2019-07-03 12:22:29 +10:00
|
|
|
dimension: model.showNameLine ? 48 : 28
|
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(
|
|
|
|
roomEventListView.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
|
|
|
|
maximumLineCount: 1
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|