Alexandra Betouni 4ee21ada05 feat(desktop) Added image function in Style
Introduced Style.svg() Style.png() Style.emoji() and
Style.icon() in Style.qml. Those should be used to
set the source in Images instead of using relative
paths. Usage:
Image {
   source: Style.svg("check)
   ....

Also moved all Singletons inside a new "utils"
folder and made it a QML module, to use
import utils 1.0 instead of relative paths

Closes #3678
2021-09-28 15:28:00 -04:00

102 lines
3.2 KiB
QML

import QtQuick 2.13
import QtGraphicalEffects 1.13
import utils 1.0
import "../../../../../shared"
import "../../../../../shared/status"
import ".."
import "../../components"
Rectangle {
property string chatId: ""
property string name: "channelName"
property string identicon
property string responseTo
property string communityId
property int notificationType
property int chatType: chatsModel.channelView.chats.getChannelType(chatId)
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: visible ? 24 : 0
width: childrenRect.width + 12
color: Style.current.transparent
border.color: Style.current.borderSecondary
border.width: 1
radius: 11
Loader {
active: true
height: parent.height
anchors.left: parent.left
anchors.leftMargin: 4
sourceComponent: {
switch (model.notificationType) {
case Constants.activityCenterNotificationTypeMention: return communityOrChannelContentComponent
case Constants.activityCenterNotificationTypeReply: return replyComponent
default: return communityOrChannelContentComponent
}
}
}
Component {
id: replyComponent
Item {
property int replyMessageIndex: chatsModel.messageView.getMessageIndex(chatId, responseTo)
property string repliedMessageContent: replyMessageIndex > -1 ? chatsModel.messageView.getMessageData(chatId, replyMessageIndex, "message") : "";
onReplyMessageIndexChanged: {
wrapper.visible = replyMessageIndex > -1
}
width: childrenRect.width
height: parent.height
SVGImage {
id: replyIcon
width: 16
height: 16
source: Style.svg("reply-small-arrow")
anchors.left: parent.left
anchors.verticalCenter:parent.verticalCenter
}
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
readOnly: true
}
}
}
Component {
id: communityOrChannelContentComponent
BadgeContent {
chatId: wrapper.chatId
name: wrapper.name
identicon: wrapper.identicon
communityId: wrapper.communityId
}
}
}