2020-06-17 08:53:51 -04:00
|
|
|
import QtQuick 2.3
|
2020-05-27 18:59:17 -04:00
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../imports"
|
2020-07-15 17:04:14 -04:00
|
|
|
import "./MessageComponents"
|
2020-06-04 12:30:49 +02:00
|
|
|
import "../components"
|
2020-05-27 18:59:17 -04:00
|
|
|
|
2020-05-28 15:32:14 -04:00
|
|
|
Item {
|
2020-06-16 17:24:43 -04:00
|
|
|
property string fromAuthor: "0x0011223344556677889910"
|
2020-05-28 11:55:52 -04:00
|
|
|
property string userName: "Jotaro Kujo"
|
|
|
|
property string message: "That's right. We're friends... Of justice, that is."
|
2020-07-10 11:24:52 -04:00
|
|
|
property string plainText: "That's right. We're friends... Of justice, that is."
|
2020-07-20 13:04:33 -04:00
|
|
|
property string identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQAQMAAAC6caSPAAAABlBMVEXMzMz////TjRV2AAAAAWJLR0QB/wIt3gAAACpJREFUGBntwYEAAAAAw6D7Uw/gCtUAAAAAAAAAAAAAAAAAAAAAAAAAgBNPsAABAjKCqQAAAABJRU5ErkJggg=="
|
2020-05-28 11:55:52 -04:00
|
|
|
property bool isCurrentUser: false
|
2020-06-11 13:50:36 -04:00
|
|
|
property string timestamp: "1234567"
|
2020-05-28 17:34:04 -04:00
|
|
|
property string sticker: "Qme8vJtyrEHxABcSVGPF95PtozDgUyfr1xGjePmFdZgk9v"
|
2020-07-09 13:29:19 -04:00
|
|
|
property int contentType: 2 // constants don't work in default props
|
2020-06-08 13:29:28 -04:00
|
|
|
property string chatId: "chatId"
|
2020-07-01 14:24:13 -04:00
|
|
|
property string outgoingStatus: ""
|
2020-07-09 11:50:38 -04:00
|
|
|
property string responseTo: ""
|
2020-07-09 13:47:36 -04:00
|
|
|
property string messageId: ""
|
2020-07-11 21:03:39 -04:00
|
|
|
property int prevMessageIndex: -1
|
2020-07-14 11:35:21 -04:00
|
|
|
property bool timeout: false
|
2020-05-28 11:55:52 -04:00
|
|
|
|
2020-06-05 18:20:45 -04:00
|
|
|
property string authorCurrentMsg: "authorCurrentMsg"
|
|
|
|
property string authorPrevMsg: "authorPrevMsg"
|
2020-05-27 18:59:17 -04:00
|
|
|
|
2020-06-24 15:58:17 -04:00
|
|
|
property bool isEmoji: contentType === Constants.emojiType
|
2020-07-17 15:44:25 -04:00
|
|
|
property bool isImage: contentType === Constants.imageType
|
2020-07-30 12:07:41 -04:00
|
|
|
property bool isAudio: contentType === Constants.audioType
|
2020-06-24 15:58:17 -04:00
|
|
|
property bool isStatusMessage: contentType === Constants.systemMessagePrivateGroupType
|
2020-07-09 13:29:19 -04:00
|
|
|
property bool isSticker: contentType === Constants.stickerType
|
2020-07-20 13:34:20 -04:00
|
|
|
property bool isText: contentType === Constants.messageType
|
2020-07-30 12:07:41 -04:00
|
|
|
property bool isMessage: isEmoji || isImage || isSticker || isText || isAudio
|
2020-06-10 11:14:12 -04:00
|
|
|
|
2020-07-16 13:27:09 -04:00
|
|
|
property bool isExpired: (outgoingStatus == "sending" && (Math.floor(timestamp) + 180000) < Date.now())
|
|
|
|
|
2020-07-09 11:50:38 -04:00
|
|
|
property int replyMessageIndex: chatsModel.messageList.getMessageIndex(responseTo);
|
2020-07-11 21:03:39 -04:00
|
|
|
property string repliedMessageAuthor: replyMessageIndex > -1 ? chatsModel.messageList.getMessageData(replyMessageIndex, "userName") : "";
|
|
|
|
property string repliedMessageContent: replyMessageIndex > -1 ? chatsModel.messageList.getMessageData(replyMessageIndex, "message") : "";
|
2020-07-17 15:44:25 -04:00
|
|
|
property int repliedMessageType: replyMessageIndex > -1 ? parseInt(chatsModel.messageList.getMessageData(replyMessageIndex, "contentType")) : 0;
|
|
|
|
property string repliedMessageImage: replyMessageIndex > -1 ? chatsModel.messageList.getMessageData(replyMessageIndex, "image") : "";
|
2020-07-09 11:50:38 -04:00
|
|
|
|
2020-06-17 17:43:26 -04:00
|
|
|
property var profileClick: function () {}
|
2020-07-10 11:37:23 -04:00
|
|
|
property var scrollToBottom: function () {}
|
|
|
|
property var appSettings
|
2020-07-15 17:04:14 -04:00
|
|
|
|
|
|
|
id: messageItem
|
2020-06-05 18:20:45 -04:00
|
|
|
width: parent.width
|
2020-07-10 11:37:23 -04:00
|
|
|
anchors.right: !isCurrentUser ? undefined : parent.right
|
2020-06-08 13:29:28 -04:00
|
|
|
height: {
|
2020-07-15 17:04:14 -04:00
|
|
|
switch(contentType) {
|
2020-06-08 13:29:28 -04:00
|
|
|
case Constants.chatIdentifier:
|
2020-07-15 17:04:14 -04:00
|
|
|
return childrenRect.height + 50
|
|
|
|
default: return childrenRect.height
|
2020-06-08 13:29:28 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-15 17:04:14 -04:00
|
|
|
function clickMessage() {
|
|
|
|
SelectedMessage.set(messageId, fromAuthor);
|
|
|
|
profileClick(userName, fromAuthor, identicon);
|
|
|
|
messageContextMenu.popup()
|
2020-07-20 14:46:15 -04:00
|
|
|
// Position the center of the menu where the mouse is
|
|
|
|
messageContextMenu.x = messageContextMenu.x - messageContextMenu.width / 2
|
2020-06-17 08:53:51 -04:00
|
|
|
}
|
|
|
|
|
2020-07-15 17:04:14 -04:00
|
|
|
Loader {
|
|
|
|
active :true
|
|
|
|
width: parent.width
|
|
|
|
sourceComponent: {
|
|
|
|
switch(contentType) {
|
|
|
|
case Constants.chatIdentifier:
|
|
|
|
return channelIdentifierComponent
|
|
|
|
case Constants.systemMessagePrivateGroupType:
|
2020-07-22 08:23:15 -04:00
|
|
|
return privateGroupHeaderComponent
|
2020-07-15 17:04:14 -04:00
|
|
|
default:
|
2020-07-15 12:09:20 -04:00
|
|
|
return appSettings.compactMode ? compactMessageComponent : messageComponent
|
2020-06-04 12:30:49 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 18:59:17 -04:00
|
|
|
}
|
|
|
|
|
2020-07-15 17:04:14 -04:00
|
|
|
Component {
|
|
|
|
id: channelIdentifierComponent
|
|
|
|
ChannelIdentifier {
|
|
|
|
authorCurrentMsg: messageItem.authorCurrentMsg
|
2020-06-10 14:23:18 -04:00
|
|
|
}
|
2020-05-27 18:59:17 -04:00
|
|
|
}
|
|
|
|
|
2020-07-15 17:04:14 -04:00
|
|
|
// Private group Messages
|
|
|
|
Component {
|
|
|
|
id: privateGroupHeaderComponent
|
|
|
|
StyledText {
|
2020-06-25 16:17:42 -04:00
|
|
|
wrapMode: Text.Wrap
|
2020-07-15 17:04:14 -04:00
|
|
|
text: message
|
|
|
|
visible: isStatusMessage
|
|
|
|
font.pixelSize: 16
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
width: parent.width - 120
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
textFormat: Text.RichText
|
2020-07-09 13:47:36 -04:00
|
|
|
}
|
2020-07-09 11:50:38 -04:00
|
|
|
}
|
2020-05-28 15:32:14 -04:00
|
|
|
|
2020-07-15 17:04:14 -04:00
|
|
|
// Normal message
|
|
|
|
Component {
|
|
|
|
id: messageComponent
|
|
|
|
NormalMessage {
|
|
|
|
clickMessage: messageItem.clickMessage
|
2020-05-28 15:32:14 -04:00
|
|
|
}
|
2020-07-09 11:50:38 -04:00
|
|
|
}
|
2020-07-10 11:37:23 -04:00
|
|
|
|
2020-07-15 17:04:14 -04:00
|
|
|
// Compact Messages
|
|
|
|
Component {
|
|
|
|
id: compactMessageComponent
|
|
|
|
CompactMessage {
|
|
|
|
clickMessage: messageItem.clickMessage
|
2020-07-10 11:37:23 -04:00
|
|
|
}
|
2020-05-27 18:59:17 -04:00
|
|
|
}
|
|
|
|
}
|
2020-05-28 11:55:52 -04:00
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
2020-07-09 13:29:19 -04:00
|
|
|
D{i:0;formeditorColor:"#ffffff";formeditorZoom:1.75;height:80;width:800}
|
2020-05-28 11:55:52 -04:00
|
|
|
}
|
|
|
|
##^##*/
|