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-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
|
|
|
|
2019-07-20 13:07:26 +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
|
2019-07-20 13:07:26 +10:00
|
|
|
|
|
|
|
HUserAvatar {
|
|
|
|
id: avatar
|
|
|
|
userId: model.senderId
|
|
|
|
width: hideAvatar ? 0 : 48
|
|
|
|
height: hideAvatar ? 0 : collapseAvatar ? 1 : 48
|
|
|
|
}
|
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-18 21:22:41 +10:00
|
|
|
eventList.width - avatar.width - eventContent.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
|
|
|
)
|
2019-07-20 15:35:25 +10:00
|
|
|
height: (nameLabel.visible ? nameLabel.height : 0) +
|
|
|
|
contentLabel.implicitHeight
|
2019-07-20 13:07:26 +10:00
|
|
|
y: parent.height / 2 - height / 2
|
2019-05-09 01:18:22 +10:00
|
|
|
|
|
|
|
Column {
|
|
|
|
spacing: 0
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
HLabel {
|
2019-07-20 13:07:26 +10:00
|
|
|
id: nameLabel
|
2019-05-09 01:18:22 +10:00
|
|
|
width: parent.width
|
2019-07-20 15:35:25 +10:00
|
|
|
visible: ! hideNameLine
|
2019-05-09 01:18:22 +10:00
|
|
|
|
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
|
2019-07-18 20:23:31 +10:00
|
|
|
horizontalAlignment: onRight ? Text.AlignRight : Text.AlignLeft
|
2019-05-09 01:18:22 +10:00
|
|
|
|
2019-07-20 13:07:26 +10:00
|
|
|
leftPadding: theme.spacing
|
|
|
|
rightPadding: leftPadding
|
|
|
|
topPadding: theme.spacing / 2
|
2019-05-09 01:18:22 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
HRichLabel {
|
2019-07-20 13:07:26 +10:00
|
|
|
id: contentLabel
|
2019-05-09 01:18:22 +10:00
|
|
|
width: parent.width
|
|
|
|
|
2019-07-22 07:41:43 +10:00
|
|
|
text: theme.chat.message.styleInclude +
|
2019-07-22 06:53:34 +10:00
|
|
|
Utils.processedEventText(model) +
|
2019-07-04 12:31:29 +10:00
|
|
|
// 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
|
|
|
|
|
2019-07-20 13:07:26 +10:00
|
|
|
leftPadding: theme.spacing
|
|
|
|
rightPadding: leftPadding
|
|
|
|
topPadding: nameLabel.visible ? 0 : bottomPadding
|
|
|
|
bottomPadding: theme.spacing / 2
|
2019-05-09 01:18:22 +10:00
|
|
|
}
|
2019-04-15 02:56:30 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|