2020-06-17 12:53:51 +00:00
|
|
|
import QtQuick 2.3
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import Qt.labs.platform 1.1
|
2020-05-27 22:59:17 +00:00
|
|
|
import "../../../../shared"
|
2020-06-17 12:53:51 +00:00
|
|
|
import "../../../../shared/xss.js" as XSS
|
2020-05-27 22:59:17 +00:00
|
|
|
import "../../../../imports"
|
2020-06-04 10:30:49 +00:00
|
|
|
import "../components"
|
2020-05-27 22:59:17 +00:00
|
|
|
|
2020-05-28 19:32:14 +00:00
|
|
|
Item {
|
2020-06-16 21:24:43 +00:00
|
|
|
property string fromAuthor: "0x0011223344556677889910"
|
2020-05-28 15:55:52 +00:00
|
|
|
property string userName: "Jotaro Kujo"
|
|
|
|
property string message: "That's right. We're friends... Of justice, that is."
|
2020-07-10 15:24:52 +00:00
|
|
|
property string plainText: "That's right. We're friends... Of justice, that is."
|
2020-05-28 15:55:52 +00:00
|
|
|
property string identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="
|
|
|
|
property bool isCurrentUser: false
|
2020-06-11 17:50:36 +00:00
|
|
|
property string timestamp: "1234567"
|
2020-05-28 21:34:04 +00:00
|
|
|
property string sticker: "Qme8vJtyrEHxABcSVGPF95PtozDgUyfr1xGjePmFdZgk9v"
|
2020-07-09 17:29:19 +00:00
|
|
|
property int contentType: 2 // constants don't work in default props
|
2020-06-08 17:29:28 +00:00
|
|
|
property string chatId: "chatId"
|
2020-07-01 18:24:13 +00:00
|
|
|
property string outgoingStatus: ""
|
2020-07-09 15:50:38 +00:00
|
|
|
property string responseTo: ""
|
2020-07-09 17:47:36 +00:00
|
|
|
property string messageId: ""
|
2020-07-12 01:03:39 +00:00
|
|
|
property int prevMessageIndex: -1
|
2020-05-28 15:55:52 +00:00
|
|
|
|
2020-06-05 22:20:45 +00:00
|
|
|
property string authorCurrentMsg: "authorCurrentMsg"
|
|
|
|
property string authorPrevMsg: "authorPrevMsg"
|
2020-05-27 22:59:17 +00:00
|
|
|
|
2020-06-24 19:58:17 +00:00
|
|
|
property bool isEmoji: contentType === Constants.emojiType
|
2020-07-10 15:37:23 +00:00
|
|
|
property bool isMessage: contentType === Constants.messageType || contentType === Constants.stickerType
|
2020-06-24 19:58:17 +00:00
|
|
|
property bool isStatusMessage: contentType === Constants.systemMessagePrivateGroupType
|
2020-07-09 17:29:19 +00:00
|
|
|
property bool isSticker: contentType === Constants.stickerType
|
2020-06-10 15:14:12 +00:00
|
|
|
|
2020-07-09 15:50:38 +00:00
|
|
|
property int replyMessageIndex: chatsModel.messageList.getMessageIndex(responseTo);
|
2020-07-12 01:03:39 +00:00
|
|
|
property string repliedMessageAuthor: replyMessageIndex > -1 ? chatsModel.messageList.getMessageData(replyMessageIndex, "userName") : "";
|
|
|
|
property string repliedMessageContent: replyMessageIndex > -1 ? chatsModel.messageList.getMessageData(replyMessageIndex, "message") : "";
|
2020-07-09 15:50:38 +00:00
|
|
|
|
2020-06-17 21:43:26 +00:00
|
|
|
property var profileClick: function () {}
|
2020-07-10 15:37:23 +00:00
|
|
|
property var scrollToBottom: function () {}
|
|
|
|
property var appSettings
|
2020-06-05 22:20:45 +00:00
|
|
|
width: parent.width
|
2020-07-10 15:37:23 +00:00
|
|
|
anchors.right: !isCurrentUser ? undefined : parent.right
|
|
|
|
id: messageWrapper
|
2020-06-08 17:29:28 +00:00
|
|
|
height: {
|
|
|
|
switch(contentType){
|
|
|
|
case Constants.chatIdentifier:
|
2020-07-10 15:37:23 +00:00
|
|
|
return channelIdentifier.height + channelIdentifier.verticalMargin
|
2020-06-08 17:29:28 +00:00
|
|
|
case Constants.stickerType:
|
2020-07-12 01:03:39 +00:00
|
|
|
return stickerId.height + 50 + (dateGroupLbl.visible ? 50 : 0)
|
2020-06-08 17:29:28 +00:00
|
|
|
default:
|
2020-07-12 01:03:39 +00:00
|
|
|
return childrenRect.height
|
2020-06-08 17:29:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-17 12:53:51 +00:00
|
|
|
function linkify(inputText) {
|
2020-07-10 15:37:23 +00:00
|
|
|
// URLs starting with http://, https://, or ftp://
|
2020-06-17 12:53:51 +00:00
|
|
|
var replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
|
2020-06-30 16:30:04 +00:00
|
|
|
var replacedText = inputText.replace(replacePattern1, "<a href='$1'>$1</a>");
|
2020-06-17 12:53:51 +00:00
|
|
|
|
2020-07-10 15:37:23 +00:00
|
|
|
// URLs starting with "www." (without // before it, or it'd re-link the ones done above).
|
2020-06-17 12:53:51 +00:00
|
|
|
var replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
|
|
|
|
replacedText = replacedText.replace(replacePattern2, "$1<a href='http://$2'>$2</a>");
|
|
|
|
|
|
|
|
replacedText = XSS.filterXSS(replacedText)
|
|
|
|
return replacedText;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfilePopup {
|
|
|
|
id: profilePopup
|
|
|
|
}
|
|
|
|
|
2020-06-08 17:29:28 +00:00
|
|
|
Item {
|
2020-07-10 15:37:23 +00:00
|
|
|
property int verticalMargin: 50
|
2020-06-08 17:29:28 +00:00
|
|
|
id: channelIdentifier
|
|
|
|
visible: authorCurrentMsg == ""
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2020-07-10 15:37:23 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: this.visible ? verticalMargin : 0
|
|
|
|
height: this.visible ? childrenRect.height + verticalMargin : 0
|
2020-06-08 22:34:41 +00:00
|
|
|
|
2020-06-08 17:29:28 +00:00
|
|
|
Rectangle {
|
|
|
|
id: circleId
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
width: 120
|
|
|
|
height: 120
|
|
|
|
radius: 120
|
|
|
|
border.width: chatsModel.activeChannel.chatType == Constants.chatTypeOneToOne ? 2 : 0
|
2020-07-02 15:14:31 +00:00
|
|
|
border.color: Style.current.grey
|
2020-06-08 17:29:28 +00:00
|
|
|
color: {
|
2020-06-09 21:20:42 +00:00
|
|
|
if (chatsModel.activeChannel.chatType == Constants.chatTypeOneToOne) {
|
2020-07-02 15:14:31 +00:00
|
|
|
return Style.current.transparent
|
2020-06-08 17:29:28 +00:00
|
|
|
}
|
2020-06-09 21:20:42 +00:00
|
|
|
return chatsModel.activeChannel.color
|
2020-06-08 17:29:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
visible: chatsModel.activeChannel.chatType == Constants.chatTypeOneToOne
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: 120
|
|
|
|
height: 120
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: chatsModel.activeChannel.identicon
|
2020-06-23 17:54:16 +00:00
|
|
|
mipmap: true
|
|
|
|
smooth: false
|
|
|
|
antialiasing: true
|
2020-06-08 17:29:28 +00:00
|
|
|
}
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-06-08 17:29:28 +00:00
|
|
|
visible: chatsModel.activeChannel.chatType != Constants.chatTypeOneToOne
|
2020-06-09 15:48:17 +00:00
|
|
|
text: (chatsModel.activeChannel.name.charAt(0) == "#" ? chatsModel.activeChannel.name.charAt(1) : chatsModel.activeChannel.name.charAt(0)).toUpperCase()
|
2020-06-08 17:29:28 +00:00
|
|
|
opacity: 0.7
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: 51
|
2020-07-15 13:58:28 +00:00
|
|
|
color: "white"
|
2020-06-08 17:29:28 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-06-10 18:23:18 +00:00
|
|
|
id: channelName
|
2020-06-08 17:29:28 +00:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
text: {
|
2020-06-09 15:48:17 +00:00
|
|
|
if (chatsModel.activeChannel.chatType != Constants.chatTypePublic) {
|
2020-06-08 17:29:28 +00:00
|
|
|
return chatsModel.activeChannel.name;
|
|
|
|
} else {
|
2020-06-09 15:48:17 +00:00
|
|
|
return "#" + chatsModel.activeChannel.name;
|
2020-06-08 17:29:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: 22
|
2020-07-14 22:57:49 +00:00
|
|
|
color: Style.current.textColor
|
2020-06-08 17:29:28 +00:00
|
|
|
anchors.top: circleId.bottom
|
|
|
|
anchors.topMargin: 16
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
2020-06-10 18:23:18 +00:00
|
|
|
|
|
|
|
Item {
|
2020-06-15 17:41:19 +00:00
|
|
|
visible: chatsModel.activeChannel.chatType == Constants.chatTypePrivateGroupChat && !chatsModel.activeChannel.isMember(profileModel.profile.pubKey)
|
2020-06-10 18:23:18 +00:00
|
|
|
anchors.top: channelName.bottom
|
|
|
|
anchors.topMargin: 16
|
|
|
|
id: joinOrDecline
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-06-10 19:41:03 +00:00
|
|
|
id: joinChat
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Join chat"
|
|
|
|
text: qsTrId("join-chat")
|
2020-06-10 18:23:18 +00:00
|
|
|
font.pixelSize: 20
|
2020-07-02 15:14:31 +00:00
|
|
|
color: Style.current.blue
|
2020-06-10 18:23:18 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
chatsModel.joinGroup()
|
|
|
|
}
|
|
|
|
}
|
2020-06-10 19:41:03 +00:00
|
|
|
}
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Decline invitation"
|
|
|
|
text: qsTrId("group-chat-decline-invitation")
|
2020-06-10 19:41:03 +00:00
|
|
|
font.pixelSize: 20
|
2020-07-02 15:14:31 +00:00
|
|
|
color: Style.current.blue
|
2020-06-10 19:41:03 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: joinChat.bottom
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.topMargin: Style.current.padding
|
2020-06-10 19:41:03 +00:00
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
chatsModel.leaveActiveChat()
|
|
|
|
}
|
|
|
|
}
|
2020-06-10 18:23:18 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-08 17:29:28 +00:00
|
|
|
}
|
|
|
|
|
2020-06-10 15:14:12 +00:00
|
|
|
// Private group Messages
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-06-10 15:14:12 +00:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
text: message
|
|
|
|
visible: isStatusMessage
|
|
|
|
font.pixelSize: 16
|
2020-07-02 15:14:31 +00:00
|
|
|
color: Style.current.darkGrey
|
2020-06-10 15:14:12 +00:00
|
|
|
width: parent.width - 120
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2020-06-24 18:52:49 +00:00
|
|
|
textFormat: Text.RichText
|
2020-06-10 15:14:12 +00:00
|
|
|
}
|
|
|
|
|
2020-07-12 01:03:39 +00:00
|
|
|
StyledText {
|
|
|
|
id: dateGroupLbl
|
|
|
|
font.pixelSize: 13
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: {
|
|
|
|
if (prevMessageIndex == -1) return ""; // identifier
|
|
|
|
|
|
|
|
let now = new Date()
|
|
|
|
let yesterday = new Date()
|
|
|
|
yesterday.setDate(now.getDate()-1)
|
|
|
|
|
|
|
|
let prevMsgTimestamp = chatsModel.messageList.getMessageData(prevMessageIndex, "timestamp")
|
|
|
|
var currentMsgDate = new Date(parseInt(timestamp, 10));
|
|
|
|
var prevMsgDate = prevMsgTimestamp === "" ? new Date(0) : new Date(parseInt(prevMsgTimestamp, 10));
|
|
|
|
if(currentMsgDate.getDay() !== prevMsgDate.getDay()){
|
|
|
|
if (now.toDateString() === currentMsgDate.toDateString()) {
|
|
|
|
return qsTr("Today")
|
|
|
|
} else if (yesterday.toDateString() === currentMsgDate.toDateString()) {
|
|
|
|
//% "Yesterday"
|
|
|
|
return qsTrId("yesterday")
|
|
|
|
} else {
|
|
|
|
const monthNames = [
|
|
|
|
qsTr("January"),
|
|
|
|
qsTr("February"),
|
|
|
|
qsTr("March"),
|
|
|
|
qsTr("April"),
|
|
|
|
qsTr("May"),
|
|
|
|
qsTr("June"),
|
|
|
|
qsTr("July"),
|
|
|
|
qsTr("August"),
|
|
|
|
qsTr("September"),
|
|
|
|
qsTr("October"),
|
|
|
|
qsTr("November"),
|
|
|
|
qsTr("December")
|
|
|
|
];
|
|
|
|
return monthNames[currentMsgDate.getMonth()] + ", " + currentMsgDate.getDay()
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 20
|
|
|
|
visible: text !== ""
|
|
|
|
}
|
|
|
|
|
2020-06-10 15:14:12 +00:00
|
|
|
// Messages
|
2020-05-27 22:59:17 +00:00
|
|
|
Image {
|
|
|
|
id: chatImage
|
2020-05-28 19:32:14 +00:00
|
|
|
width: 36
|
|
|
|
height: 36
|
|
|
|
anchors.left: parent.left
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2020-07-12 01:03:39 +00:00
|
|
|
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
|
|
|
|
anchors.topMargin: 20
|
2020-05-27 22:59:17 +00:00
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: identicon
|
2020-06-24 19:58:17 +00:00
|
|
|
visible: (isMessage || isEmoji) && authorCurrentMsg != authorPrevMsg && !isCurrentUser
|
2020-06-23 17:54:16 +00:00
|
|
|
mipmap: true
|
|
|
|
smooth: false
|
|
|
|
antialiasing: true
|
2020-06-25 13:23:17 +00:00
|
|
|
|
2020-06-04 10:30:49 +00:00
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
2020-07-10 22:22:39 +00:00
|
|
|
SelectedMessage.set(messageId, fromAuthor);
|
|
|
|
profileClick(userName, fromAuthor, identicon);
|
2020-07-09 17:47:36 +00:00
|
|
|
messageContextMenu.popup()
|
2020-06-04 10:30:49 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 22:59:17 +00:00
|
|
|
}
|
|
|
|
|
2020-06-19 18:21:02 +00:00
|
|
|
StyledTextEdit {
|
2020-05-27 22:59:17 +00:00
|
|
|
id: chatName
|
|
|
|
text: userName
|
2020-05-28 19:32:14 +00:00
|
|
|
anchors.leftMargin: 20
|
2020-07-12 01:03:39 +00:00
|
|
|
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
|
2020-05-28 19:32:14 +00:00
|
|
|
anchors.topMargin: 0
|
|
|
|
anchors.left: chatImage.right
|
2020-05-27 22:59:17 +00:00
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 14
|
|
|
|
readOnly: true
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
selectByMouse: true
|
2020-06-24 19:58:17 +00:00
|
|
|
visible: (isMessage || isEmoji) && authorCurrentMsg != authorPrevMsg && !isCurrentUser
|
2020-06-10 18:23:18 +00:00
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
2020-07-10 22:22:39 +00:00
|
|
|
SelectedMessage.set(messageId, fromAuthor);
|
|
|
|
profileClick(userName, fromAuthor, identicon)
|
2020-07-09 17:47:36 +00:00
|
|
|
messageContextMenu.popup()
|
2020-06-10 18:23:18 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 22:59:17 +00:00
|
|
|
}
|
|
|
|
|
2020-05-28 19:32:14 +00:00
|
|
|
Rectangle {
|
|
|
|
property int chatVerticalPadding: 7
|
|
|
|
property int chatHorizontalPadding: 12
|
2020-05-27 22:59:17 +00:00
|
|
|
|
2020-05-28 19:32:14 +00:00
|
|
|
id: chatBox
|
2020-07-13 18:45:54 +00:00
|
|
|
color: isSticker ? Style.current.background : (isCurrentUser ? Style.current.blue : Style.current.secondaryBackground)
|
|
|
|
border.color: isSticker ? Style.current.border : Style.current.transparent
|
2020-07-09 17:29:19 +00:00
|
|
|
border.width: 1
|
2020-07-09 15:50:38 +00:00
|
|
|
height: (3 * chatVerticalPadding) + (contentType == Constants.stickerType ? stickerId.height : (chatText.height + chatReply.height))
|
|
|
|
width: {
|
|
|
|
switch(contentType){
|
|
|
|
case Constants.stickerType:
|
|
|
|
return stickerId.width + (2 * chatBox.chatHorizontalPadding);
|
|
|
|
default:
|
2020-07-10 15:24:52 +00:00
|
|
|
return plainText.length > 54 ? 400 : chatText.width + 2 * chatHorizontalPadding
|
2020-07-09 15:50:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-28 19:32:14 +00:00
|
|
|
radius: 16
|
|
|
|
anchors.left: !isCurrentUser ? chatImage.right : undefined
|
|
|
|
anchors.leftMargin: !isCurrentUser ? 8 : 0
|
|
|
|
anchors.right: !isCurrentUser ? undefined : parent.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.rightMargin: !isCurrentUser ? 0 : Style.current.padding
|
2020-07-12 01:03:39 +00:00
|
|
|
anchors.top: authorCurrentMsg != authorPrevMsg && !isCurrentUser ? chatImage.top : (dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top)
|
2020-05-28 19:32:14 +00:00
|
|
|
anchors.topMargin: 0
|
2020-06-24 19:58:17 +00:00
|
|
|
visible: isMessage || isEmoji
|
2020-05-28 19:32:14 +00:00
|
|
|
|
|
|
|
Rectangle {
|
2020-07-09 15:50:38 +00:00
|
|
|
id: chatReply
|
|
|
|
color: isCurrentUser ? Style.current.blue : Style.current.lightBlue
|
2020-07-09 17:47:36 +00:00
|
|
|
visible: responseTo != "" && replyMessageIndex > -1
|
2020-07-09 15:50:38 +00:00
|
|
|
height: chatReply.visible ? childrenRect.height : 0
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: chatReply.visible ? chatBox.chatVerticalPadding : 0
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: chatBox.chatHorizontalPadding
|
|
|
|
|
|
|
|
StyledTextEdit {
|
|
|
|
id: lblReplyAuthor
|
|
|
|
text: "↳" + repliedMessageAuthor
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
readOnly: true
|
|
|
|
selectByMouse: true
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledTextEdit {
|
|
|
|
id: lblReplyMessage
|
|
|
|
anchors.top: lblReplyAuthor.bottom
|
|
|
|
anchors.topMargin: 5
|
|
|
|
text: Emoji.parse(linkify(repliedMessageContent), "26x26");
|
|
|
|
textFormat: Text.RichText
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
readOnly: true
|
|
|
|
selectByMouse: true
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
}
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
anchors.top: lblReplyMessage.bottom
|
|
|
|
anchors.topMargin: 8
|
|
|
|
anchors.left: lblReplyMessage.left
|
|
|
|
anchors.right: lblReplyMessage.right
|
|
|
|
anchors.rightMargin: chatBox.chatHorizontalPadding
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
}
|
2020-05-28 19:32:14 +00:00
|
|
|
}
|
|
|
|
|
2020-06-19 18:21:02 +00:00
|
|
|
StyledTextEdit {
|
2020-05-28 19:32:14 +00:00
|
|
|
id: chatText
|
2020-07-10 15:37:23 +00:00
|
|
|
textFormat: Text.RichText
|
2020-06-26 01:23:38 +00:00
|
|
|
text: {
|
|
|
|
if(contentType === Constants.stickerType) return "";
|
2020-07-10 23:12:32 +00:00
|
|
|
let msg = linkify(message);
|
2020-06-26 01:23:38 +00:00
|
|
|
if(isEmoji){
|
2020-07-10 23:12:32 +00:00
|
|
|
return Emoji.parse(msg, "72x72");
|
2020-06-26 01:23:38 +00:00
|
|
|
} else {
|
2020-07-10 23:12:32 +00:00
|
|
|
return `<html>
|
|
|
|
<head>
|
|
|
|
<style type="text/css">
|
|
|
|
code {
|
|
|
|
background-color: #1a356b;
|
|
|
|
color: #FFFFFF;
|
|
|
|
white-space: pre;
|
|
|
|
}
|
|
|
|
|
|
|
|
p {
|
|
|
|
white-space: pre;
|
|
|
|
}
|
|
|
|
|
|
|
|
a.mention {
|
|
|
|
color: ${isCurrentUser ? Style.current.black : Style.current.white}
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
blockquote {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
${Emoji.parse(msg, "26x26")}
|
|
|
|
</body>
|
|
|
|
</html>`;
|
2020-06-26 01:23:38 +00:00
|
|
|
}
|
2020-07-10 22:22:39 +00:00
|
|
|
|
2020-06-26 01:23:38 +00:00
|
|
|
}
|
2020-05-28 19:32:14 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: parent.chatHorizontalPadding
|
2020-07-10 15:24:52 +00:00
|
|
|
anchors.right: plainText.length > 52 ? parent.right : undefined
|
|
|
|
anchors.rightMargin: plainText.length > 52 ? parent.chatHorizontalPadding : 0
|
2020-05-28 19:32:14 +00:00
|
|
|
horizontalAlignment: !isCurrentUser ? Text.AlignLeft : Text.AlignRight
|
2020-06-25 20:17:42 +00:00
|
|
|
wrapMode: Text.Wrap
|
2020-07-09 15:50:38 +00:00
|
|
|
anchors.top: chatReply.bottom
|
2020-05-28 19:32:14 +00:00
|
|
|
anchors.topMargin: chatBox.chatVerticalPadding
|
2020-06-26 01:23:38 +00:00
|
|
|
font.pixelSize: 15
|
2020-05-28 19:32:14 +00:00
|
|
|
readOnly: true
|
|
|
|
selectByMouse: true
|
2020-07-13 18:45:54 +00:00
|
|
|
color: !isCurrentUser ? Style.current.textColor : Style.current.currentUserTextColor
|
2020-06-24 19:58:17 +00:00
|
|
|
visible: contentType == Constants.messageType || isEmoji
|
2020-05-28 21:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: stickerId
|
|
|
|
horizontalAlignment: !isCurrentUser ? Text.AlignLeft : Text.AlignRight
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: parent.chatHorizontalPadding
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: chatBox.chatVerticalPadding
|
|
|
|
width: 140
|
|
|
|
height: 140
|
2020-06-24 19:58:17 +00:00
|
|
|
source: contentType === Constants.stickerType ? ("https://ipfs.infura.io/ipfs/" + sticker) : ""
|
|
|
|
visible: contentType === Constants.stickerType
|
2020-05-28 19:32:14 +00:00
|
|
|
}
|
2020-07-09 17:47:36 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: chatText.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
|
2020-07-10 22:22:39 +00:00
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
2020-07-09 17:47:36 +00:00
|
|
|
onClicked: {
|
2020-07-10 22:22:39 +00:00
|
|
|
if(mouse.button & Qt.RightButton) {
|
|
|
|
SelectedMessage.set(messageId, fromAuthor);
|
|
|
|
profileClick(userName, fromAuthor, identicon);
|
|
|
|
messageContextMenu.popup()
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-09 17:47:36 +00:00
|
|
|
let link = chatText.hoveredLink;
|
|
|
|
if(link.startsWith("#")){
|
|
|
|
chatsModel.joinChat(link.substring(1), Constants.chatTypePublic);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (link.startsWith('//')) {
|
|
|
|
let pk = link.replace("//", "");
|
2020-07-10 22:22:39 +00:00
|
|
|
profileClick(chatsModel.userNameOrAlias(pk), pk, chatsModel.generateIdenticon(pk))
|
2020-07-09 17:47:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt.openUrlExternally(link)
|
|
|
|
}
|
|
|
|
}
|
2020-07-09 15:50:38 +00:00
|
|
|
}
|
2020-05-28 19:32:14 +00:00
|
|
|
|
2020-07-09 15:50:38 +00:00
|
|
|
StyledTextEdit {
|
|
|
|
id: chatTime
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
text: {
|
|
|
|
let messageDate = new Date(Math.floor(timestamp))
|
|
|
|
let minutes = messageDate.getMinutes();
|
|
|
|
let hours = messageDate.getHours();
|
|
|
|
return (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes)
|
2020-05-28 19:32:14 +00:00
|
|
|
}
|
2020-07-10 15:37:23 +00:00
|
|
|
anchors.top: messageWrapper.appSettings.displayChatImages && imageUrls != "" ? imageChatBox.bottom : chatBox.bottom
|
2020-07-09 15:50:38 +00:00
|
|
|
anchors.topMargin: 4
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
2020-07-10 15:37:23 +00:00
|
|
|
anchors.right: messageWrapper.appSettings.displayChatImages && imageUrls != "" ? imageChatBox.right : chatBox.right
|
2020-07-09 15:50:38 +00:00
|
|
|
anchors.rightMargin: isCurrentUser ? 5 : Style.current.padding
|
|
|
|
font.pixelSize: 10
|
|
|
|
readOnly: true
|
|
|
|
selectByMouse: true
|
2020-07-12 01:03:39 +00:00
|
|
|
visible: (isEmoji || isMessage || isSticker)
|
2020-07-09 15:50:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StyledTextEdit {
|
|
|
|
id: sentMessage
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
text: outgoingStatus == "sent" ?
|
|
|
|
//% "Sent"
|
|
|
|
qsTrId("status-sent") :
|
|
|
|
//% "Sending..."
|
|
|
|
qsTrId("sending")
|
|
|
|
anchors.top: chatTime.top
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
anchors.right: chatTime.left
|
|
|
|
anchors.rightMargin: 5
|
|
|
|
font.pixelSize: 10
|
|
|
|
readOnly: true
|
2020-07-12 01:03:39 +00:00
|
|
|
visible: isCurrentUser && (isEmoji || isMessage || isSticker)
|
2020-07-09 15:50:38 +00:00
|
|
|
}
|
2020-07-10 15:37:23 +00:00
|
|
|
|
2020-07-09 15:50:38 +00:00
|
|
|
Rectangle {
|
2020-07-10 15:37:23 +00:00
|
|
|
property int chatVerticalPadding: 12
|
|
|
|
property int chatHorizontalPadding: 12
|
|
|
|
property int imageWidth: 350
|
|
|
|
|
|
|
|
id: imageChatBox
|
|
|
|
visible: messageWrapper.appSettings.displayChatImages && imageUrls != ""
|
|
|
|
height: {
|
|
|
|
if (!imageChatBox.visible) {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
let h = chatVerticalPadding
|
|
|
|
for (let i = 0; i < imageRepeater.count; i++) {
|
|
|
|
h += imageRepeater.itemAt(i).height
|
|
|
|
}
|
|
|
|
return h + chatVerticalPadding * imageRepeater.count
|
|
|
|
}
|
|
|
|
color: isCurrentUser ? Style.current.blue : Style.current.lightBlue
|
|
|
|
border.color: "transparent"
|
|
|
|
width: imageWidth+ 2 * chatHorizontalPadding
|
|
|
|
radius: 16
|
|
|
|
anchors.left: !isCurrentUser ? chatImage.right : undefined
|
|
|
|
anchors.leftMargin: !isCurrentUser ? 8 : 0
|
|
|
|
anchors.right: !isCurrentUser ? undefined : parent.right
|
|
|
|
anchors.rightMargin: !isCurrentUser ? 0 : Style.current.padding
|
|
|
|
anchors.top: messageWrapper.appSettings.displayChatImages && imageUrls != "" ? chatBox.bottom : chatTime.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: imageRepeater
|
|
|
|
model: messageWrapper.appSettings.displayChatImages && imageUrls != "" ? imageUrls.split(" ") : []
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: imageMessage
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: (index == 0) ? parent.top: parent.children[index-1].bottom
|
|
|
|
anchors.topMargin: imageChatBox.chatVerticalPadding
|
|
|
|
sourceSize.width: imageChatBox.imageWidth
|
|
|
|
source: modelData
|
|
|
|
onStatusChanged: {
|
|
|
|
if (imageMessage.status == Image.Error) {
|
|
|
|
imageMessage.height = 0
|
|
|
|
imageMessage.visible = false
|
|
|
|
imageChatBox.height = 0
|
|
|
|
imageChatBox.visible = false
|
|
|
|
} else if (imageMessage.status == Image.Ready) {
|
|
|
|
messageWrapper.scrollToBottom(true, messageWrapper)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This rectangle's only job is to mask the corner to make it less rounded... yep
|
|
|
|
Rectangle {
|
|
|
|
color: parent.color
|
|
|
|
width: 18
|
|
|
|
height: 18
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 0
|
|
|
|
anchors.left: !isCurrentUser ? parent.left : undefined
|
|
|
|
anchors.leftMargin: 0
|
|
|
|
anchors.right: !isCurrentUser ? undefined : parent.right
|
|
|
|
anchors.rightMargin: 0
|
|
|
|
radius: 4
|
|
|
|
z: -1
|
|
|
|
}
|
2020-05-27 22:59:17 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-28 15:55:52 +00:00
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
2020-07-09 17:29:19 +00:00
|
|
|
D{i:0;formeditorColor:"#ffffff";formeditorZoom:1.75;height:80;width:800}
|
2020-05-28 15:55:52 +00:00
|
|
|
}
|
|
|
|
##^##*/
|