2020-09-22 14:50:14 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2021-01-15 18:36:42 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2020-09-22 14:50:14 +00:00
|
|
|
import "../../imports"
|
|
|
|
import "../../shared"
|
|
|
|
import "../../shared/status"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
2020-10-02 19:25:33 +00:00
|
|
|
property string chatId
|
2020-09-22 14:50:14 +00:00
|
|
|
property string chatName
|
|
|
|
property int chatType
|
2021-03-03 17:36:18 +00:00
|
|
|
property int realChatType: {
|
|
|
|
if (chatType === Constants.chatTypeCommunity) {
|
|
|
|
// TODO add a check for private community chats once it is created
|
|
|
|
return Constants.chatTypePublic
|
|
|
|
}
|
|
|
|
return chatType
|
|
|
|
}
|
2020-09-22 14:50:14 +00:00
|
|
|
property string identicon
|
|
|
|
property int identiconSize: 40
|
|
|
|
property bool isCompact: false
|
2021-01-15 18:36:42 +00:00
|
|
|
property bool muted: false
|
2020-09-22 14:50:14 +00:00
|
|
|
|
2021-03-03 17:36:18 +00:00
|
|
|
property string profileImage: realChatType === Constants.chatTypeOneToOne ? appMain.getProfileImage(chatId) || "" : ""
|
2020-11-30 17:03:52 +00:00
|
|
|
|
2020-09-22 14:50:14 +00:00
|
|
|
height: 48
|
|
|
|
|
2020-11-30 17:03:52 +00:00
|
|
|
Connections {
|
2021-03-03 17:36:18 +00:00
|
|
|
enabled: realChatType === Constants.chatTypeOneToOne
|
2020-11-30 17:03:52 +00:00
|
|
|
target: profileModel.contacts.list
|
|
|
|
onContactChanged: {
|
|
|
|
if (pubkey === root.chatId) {
|
2021-04-28 15:30:41 +00:00
|
|
|
root.profileImage = appMain.getProfileImage(root.chatId) || ""
|
2020-11-30 17:03:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-22 14:50:14 +00:00
|
|
|
StatusIdenticon {
|
|
|
|
id: chatIdenticon
|
2021-03-03 17:36:18 +00:00
|
|
|
chatType: root.realChatType
|
2021-03-02 20:43:32 +00:00
|
|
|
chatId: root.chatId
|
2020-09-22 14:50:14 +00:00
|
|
|
chatName: root.chatName
|
2020-11-30 17:03:52 +00:00
|
|
|
identicon: root.profileImage || root.identicon
|
2020-09-22 14:50:14 +00:00
|
|
|
width: root.isCompact ? 20 : root.identiconSize
|
|
|
|
height: root.isCompact ? 20 : root.identiconSize
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: nameAndInfo
|
|
|
|
height: chatName.height + chatInfo.height
|
2021-05-28 02:55:50 +00:00
|
|
|
width: parent.width
|
2020-09-22 14:50:14 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: chatIdenticon.right
|
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: chatName
|
|
|
|
text: {
|
2021-03-03 17:36:18 +00:00
|
|
|
switch(root.realChatType) {
|
2020-09-22 14:50:14 +00:00
|
|
|
case Constants.chatTypePublic: return "#" + root.chatName;
|
|
|
|
case Constants.chatTypeOneToOne: return Utils.removeStatusEns(root.chatName)
|
|
|
|
default: return root.chatName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
|
|
|
|
2021-01-15 18:36:42 +00:00
|
|
|
SVGImage {
|
|
|
|
property bool hovered: false
|
|
|
|
|
|
|
|
id: bellImg
|
|
|
|
visible: root.muted
|
|
|
|
source: "../../app/img/bell-disabled.svg"
|
|
|
|
anchors.verticalCenter: chatName.verticalCenter
|
|
|
|
anchors.left: chatName.right
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
width: 12.5
|
|
|
|
height: 12.5
|
|
|
|
|
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: parent
|
|
|
|
source: parent
|
|
|
|
color: bellImg.hovered ? Style.current.textColor : Style.current.darkGrey
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: bellImg.hovered = true
|
|
|
|
onExited: bellImg.hovered = false
|
|
|
|
onClicked: {
|
2021-06-17 22:09:00 +00:00
|
|
|
chatsModel.channelView.unmuteCurrentChannel()
|
2021-01-15 18:36:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-02 19:25:33 +00:00
|
|
|
|
|
|
|
Connections {
|
2020-12-06 22:15:51 +00:00
|
|
|
target: profileModel.contacts
|
2020-10-02 19:25:33 +00:00
|
|
|
onContactChanged: {
|
|
|
|
if(root.chatId === publicKey){
|
|
|
|
// Hack warning: Triggering reload to avoid changing the current text binding
|
|
|
|
var tmp = chatId;
|
|
|
|
chatId = "";
|
|
|
|
chatId = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-22 14:50:14 +00:00
|
|
|
StyledText {
|
|
|
|
id: chatInfo
|
2021-02-18 19:07:23 +00:00
|
|
|
color: Style.current.secondaryText
|
2021-05-28 02:55:50 +00:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
width: parent.width
|
|
|
|
elide: Text.ElideRight
|
2020-09-22 14:50:14 +00:00
|
|
|
text: {
|
2021-05-28 02:55:50 +00:00
|
|
|
if (root.chatType === Constants.chatTypeCommunity) {
|
2021-06-17 22:09:00 +00:00
|
|
|
return chatsModel.channelView.activeChannel.description
|
2021-05-28 02:55:50 +00:00
|
|
|
}
|
2021-03-03 17:36:18 +00:00
|
|
|
switch(root.realChatType){
|
2020-09-22 14:50:14 +00:00
|
|
|
//% "Public chat"
|
2021-05-26 17:36:24 +00:00
|
|
|
case Constants.chatTypePublic: return qsTrId("public-chat")
|
|
|
|
case Constants.chatTypeOneToOne: return (profileModel.contacts.isAdded(root.chatId) ?
|
|
|
|
profileModel.contacts.contactRequestReceived(root.chatId) ?
|
|
|
|
//% "Contact"
|
|
|
|
qsTrId("chat-is-a-contact") :
|
|
|
|
qsTr("Contact request pending") :
|
|
|
|
|
|
|
|
//% "Not a contact"
|
|
|
|
qsTrId("chat-is-not-a-contact"))
|
|
|
|
case Constants.chatTypePrivateGroupChat:
|
2021-06-17 22:09:00 +00:00
|
|
|
let cnt = chatsModel.channelView.activeChannel.members.rowCount();
|
2021-05-26 17:36:24 +00:00
|
|
|
//% "%1 members"
|
|
|
|
if(cnt > 1) return qsTrId("%1-members").arg(cnt);
|
|
|
|
//% "1 member"
|
|
|
|
return qsTrId("1-member");
|
|
|
|
default: return "...";
|
2020-09-22 14:50:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
font.pixelSize: 12
|
|
|
|
anchors.top: chatName.bottom
|
2021-05-28 02:55:50 +00:00
|
|
|
anchors.topMargin: 2
|
2020-09-22 14:50:14 +00:00
|
|
|
}
|
2021-05-25 19:34:46 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
property bool hovered: false
|
|
|
|
|
|
|
|
id: pinnedMessagesGroup
|
2021-06-21 19:35:32 +00:00
|
|
|
visible: chatType !== Constants.chatTypePublic && chatsModel.messageView.pinnedMessagesList.count > 0
|
2021-05-25 19:34:46 +00:00
|
|
|
width: childrenRect.width
|
|
|
|
height: vertiSep.height
|
|
|
|
anchors.left: chatInfo.right
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.verticalCenter: chatInfo.verticalCenter
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: vertiSep
|
|
|
|
height: 12
|
|
|
|
width: 1
|
|
|
|
color: Style.current.border
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: pinImg
|
|
|
|
source: "../../app/img/pin.svg"
|
|
|
|
height: 14
|
|
|
|
width: 14
|
|
|
|
anchors.left: vertiSep.right
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.verticalCenter: vertiSep.verticalCenter
|
|
|
|
|
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: parent
|
|
|
|
source: parent
|
|
|
|
color: pinnedMessagesGroup.hovered ? Style.current.textColor : Style.current.secondaryText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: nbPinnedMessagesText
|
|
|
|
color: pinnedMessagesGroup.hovered ? Style.current.textColor : Style.current.secondaryText
|
2021-06-21 19:35:32 +00:00
|
|
|
text: chatsModel.messageView.pinnedMessagesList.count
|
2021-05-25 19:34:46 +00:00
|
|
|
font.pixelSize: 12
|
|
|
|
font.underline: pinnedMessagesGroup.hovered
|
|
|
|
anchors.left: pinImg.right
|
|
|
|
anchors.verticalCenter: vertiSep.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: pinnedMessagesGroup.hovered = true
|
|
|
|
onExited: pinnedMessagesGroup.hovered = false
|
2021-05-25 19:38:18 +00:00
|
|
|
onClicked: openPopup(pinnedMessagesPopupComponent)
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-22 14:50:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|