2021-05-28 17:35:21 +00:00
|
|
|
import QtQuick 2.13
|
2021-06-21 15:03:40 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2021-05-28 17:35:21 +00:00
|
|
|
import "../../../../../imports"
|
|
|
|
import "../../../../../shared"
|
|
|
|
import "../../../../../shared/status"
|
|
|
|
import ".."
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
property string chatId: ""
|
|
|
|
property string name: "channelName"
|
|
|
|
property string identicon
|
2021-06-11 19:50:52 +00:00
|
|
|
property string responseTo
|
2021-06-21 15:03:40 +00:00
|
|
|
property string communityId
|
2021-06-11 19:50:52 +00:00
|
|
|
property int notificationType
|
2021-06-17 22:09:00 +00:00
|
|
|
property int chatType: chatsModel.channelView.chats.getChannelType(chatId)
|
2021-05-28 17:35:21 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
property string profileImage: realChatType === Constants.chatTypeOneToOne ? appMain.getProfileImage(chatId) || "" : ""
|
|
|
|
|
|
|
|
id: wrapper
|
|
|
|
height: 24
|
2021-06-11 19:50:52 +00:00
|
|
|
width: childrenRect.width + 12
|
2021-05-28 17:35:21 +00:00
|
|
|
color: Style.current.transparent
|
|
|
|
border.color: Style.current.borderSecondary
|
|
|
|
border.width: 1
|
|
|
|
radius: 11
|
|
|
|
|
2021-06-11 19:50:52 +00:00
|
|
|
Loader {
|
|
|
|
active: true
|
|
|
|
height: parent.height
|
|
|
|
sourceComponent: {
|
|
|
|
switch (model.notificationType) {
|
2021-06-21 15:03:40 +00:00
|
|
|
case Constants.activityCenterNotificationTypeMention: return wrapper.communityId ? communityComponent : channelComponent
|
2021-06-11 20:34:25 +00:00
|
|
|
case Constants.activityCenterNotificationTypeReply: return replyComponent
|
2021-06-11 19:50:52 +00:00
|
|
|
default: return channelComponent
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 19:50:52 +00:00
|
|
|
Component {
|
|
|
|
id: replyComponent
|
2021-05-28 17:35:21 +00:00
|
|
|
|
2021-06-11 19:50:52 +00:00
|
|
|
Item {
|
|
|
|
property int replyMessageIndex: chatsModel.getMessageIndex(chatId, responseTo)
|
|
|
|
property string repliedMessageContent: replyMessageIndex > -1 ? chatsModel.getMessageData(chatId, replyMessageIndex, "message") : "";
|
|
|
|
|
|
|
|
|
2021-06-10 19:13:46 +00:00
|
|
|
onReplyMessageIndexChanged: {
|
|
|
|
wrapper.visible = replyMessageIndex > -1
|
|
|
|
}
|
|
|
|
|
2021-06-11 19:50:52 +00:00
|
|
|
width: childrenRect.width
|
|
|
|
height: parent.height
|
|
|
|
SVGImage {
|
|
|
|
id: replyIcon
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
source: "../../../../img/reply-small-arrow.svg"
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.verticalCenter:parent.verticalCenter
|
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
|
2021-06-11 19:50:52 +00:00
|
|
|
StyledTextEdit {
|
|
|
|
text: Utils.getReplyMessageStyle(Emoji.parse(Utils.linkifyAndXSS(repliedMessageContent), Emoji.size.small), false, appSettings.useCompactMode)
|
|
|
|
textFormat: Text.RichText
|
|
|
|
height: 18
|
|
|
|
width: implicitWidth > 300 ? 300 : implicitWidth
|
|
|
|
clip: true
|
|
|
|
anchors.left: replyIcon.right
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: 13
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
selectByMouse: true
|
2021-06-21 15:03:40 +00:00
|
|
|
readOnly: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communityComponent
|
|
|
|
|
|
|
|
Item {
|
|
|
|
property int communityIndex: chatsModel.communities.joinedCommunities.getCommunityIndex(wrapper.communityId)
|
|
|
|
|
|
|
|
property string image: communityIndex > -1 ? chatsModel.communities.joinedCommunities.rowData(communityIndex, "thumbnailImage") : ""
|
|
|
|
property string iconColor: !image && communityIndex > -1 ? chatsModel.communities.joinedCommunities.rowData(communityIndex, "communityColor"): ""
|
|
|
|
property bool useLetterIdenticon: !image
|
|
|
|
property string communityName: communityIndex > -1 ? chatsModel.communities.joinedCommunities.rowData(communityIndex, "name") : ""
|
|
|
|
property string channelName: chatsModel.getChannelNameById(wrapper.chatId)
|
|
|
|
|
|
|
|
id: communityBadge
|
|
|
|
width: childrenRect.width
|
|
|
|
height: parent.height
|
|
|
|
SVGImage {
|
|
|
|
id: communityIcon
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
source: "../../../../img/communities.svg"
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.verticalCenter:parent.verticalCenter
|
|
|
|
|
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: parent
|
|
|
|
source: parent
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: communityImageLoader
|
|
|
|
active: true
|
|
|
|
anchors.left: communityIcon.right
|
|
|
|
anchors.leftMargin: 2
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
sourceComponent: communityBadge.useLetterIdenticon ? letterIdenticon :imageIcon
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: imageIcon
|
|
|
|
RoundedImage {
|
|
|
|
source: communityBadge.image
|
|
|
|
noMouseArea: true
|
|
|
|
noHover: true
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: letterIdenticon
|
|
|
|
StatusLetterIdenticon {
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
letterSize: 12
|
|
|
|
chatName: communityBadge.communityName
|
|
|
|
color: communityBadge.iconColor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getLinkStyle(link, hoveredLink) {
|
|
|
|
return `<style type="text/css">` +
|
|
|
|
`a {` +
|
|
|
|
`color: ${Style.current.secondaryText};` +
|
|
|
|
`text-decoration: none;` +
|
|
|
|
`}` +
|
|
|
|
(hoveredLink !== "" ? `a[href="${hoveredLink}"] { text-decoration: underline; }` : "") +
|
|
|
|
`</style>` +
|
|
|
|
`<a href="${link}">${link}</a>`
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledTextEdit {
|
|
|
|
id: communityName
|
|
|
|
text: communityBadge.getLinkStyle(communityBadge.communityName, hoveredLink)
|
|
|
|
height: 18
|
|
|
|
readOnly: true
|
|
|
|
textFormat: Text.RichText
|
|
|
|
width: implicitWidth > 300 ? 300 : implicitWidth
|
|
|
|
clip: true
|
|
|
|
anchors.left: communityImageLoader.right
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
font.pixelSize: 13
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
onLinkActivated: function () {
|
|
|
|
chatsModel.communities.setActiveCommunity(wrapper.communityId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: caretImage
|
|
|
|
source: "../../../../img/show-category.svg"
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
anchors.left: communityName.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: parent
|
|
|
|
source: parent
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledTextEdit {
|
|
|
|
id: channelName
|
|
|
|
text: communityBadge.getLinkStyle(communityBadge.channelName || wrapper.name, hoveredLink)
|
|
|
|
height: 18
|
|
|
|
readOnly: true
|
|
|
|
textFormat: Text.RichText
|
|
|
|
width: implicitWidth > 300 ? 300 : implicitWidth
|
|
|
|
clip: true
|
|
|
|
anchors.left: caretImage.right
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
font.pixelSize: 13
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
onLinkActivated: function () {
|
|
|
|
chatsModel.communities.setActiveCommunity(wrapper.communityId)
|
|
|
|
chatsModel.setActiveChannel(model.message.chatId)
|
|
|
|
}
|
2021-06-11 19:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 19:50:52 +00:00
|
|
|
Component {
|
|
|
|
id: channelComponent
|
|
|
|
|
|
|
|
Item {
|
|
|
|
width: childrenRect.width
|
|
|
|
height: parent.height
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
enabled: realChatType === Constants.chatTypeOneToOne
|
|
|
|
target: profileModel.contacts.list
|
|
|
|
onContactChanged: {
|
|
|
|
if (pubkey === wrapper.chatId) {
|
|
|
|
wrapper.profileImage = appMain.getProfileImage(wrapper.chatId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: channelIcon
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: "../../../../img/channel-icon-" + (wrapper.realChatType === Constants.chatTypePublic ? "public-chat.svg" : "group.svg")
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.verticalCenter:parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusIdenticon {
|
|
|
|
id: contactImage
|
|
|
|
height: 16
|
|
|
|
width: 16
|
|
|
|
chatId: wrapper.chatId
|
|
|
|
chatName: wrapper.name
|
|
|
|
chatType: wrapper.realChatType
|
|
|
|
identicon: wrapper.profileImage || wrapper.identicon
|
|
|
|
anchors.left: channelIcon.right
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
letterSize: 11
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: contactInfo
|
|
|
|
text: wrapper.realChatType !== Constants.chatTypePublic ?
|
|
|
|
Emoji.parse(Utils.removeStatusEns(Utils.filterXSS(wrapper.name))) :
|
|
|
|
"#" + Utils.filterXSS(wrapper.name)
|
|
|
|
anchors.left: contactImage.right
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: 13
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-28 17:35:21 +00:00
|
|
|
}
|