status-desktop/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml

183 lines
6.7 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
2020-05-28 11:10:12 +00:00
import "../../../../shared"
import "../../../../shared/status"
2020-05-28 11:10:12 +00:00
import "../../../../imports"
import "../components"
2020-05-28 11:10:12 +00:00
Rectangle {
property string chatId: ""
property string name: "channelName"
property string lastMessage: "My latest message\n with a return"
2020-12-11 20:29:46 +00:00
property string timestamp: "1605212622434"
property string unviewedMessagesCount: "2"
2020-12-11 20:38:10 +00:00
property string identicon
property bool hasMentions: false
property int chatType: Constants.chatTypePublic
property string searchStr: ""
property bool isCompact: appSettings.compactMode
property int contentType: 1
property bool muted: false
property bool hovered: false
2020-12-15 16:04:19 +00:00
property bool enableMouseArea: true
property string profileImage: chatType === Constants.chatTypeOneToOne ? appMain.getProfileImage(chatId) || "" : ""
2020-11-30 17:03:52 +00:00
Connections {
enabled: chatType === Constants.chatTypeOneToOne
target: profileModel.contacts.list
onContactChanged: {
if (pubkey === wrapper.chatId) {
wrapper.profileImage = appMain.getProfileImage(wrapper.chatId)
2020-11-30 17:03:52 +00:00
}
}
}
2020-05-28 11:10:12 +00:00
id: wrapper
color: {
if (ListView.isCurrentItem || wrapper.hovered) {
return Style.current.secondaryBackground
}
return Style.current.transparent
}
2020-05-28 11:10:12 +00:00
anchors.right: parent.right
anchors.top: applicationWindow.top
anchors.left: parent.left
radius: 8
// Hide the box if it is filtered out
property bool isVisible: searchStr === "" || name.includes(searchStr)
2020-05-28 11:10:12 +00:00
visible: isVisible ? true : false
height: isVisible ? (!isCompact ? 64 : contactImage.height + Style.current.smallPadding * 2) : 0
2020-05-28 11:10:12 +00:00
StatusIdenticon {
id: contactImage
height: !isCompact ? 40 : 20
width: !isCompact ? 40 : 20
chatName: wrapper.name
chatType: wrapper.chatType
2020-11-30 17:03:52 +00:00
identicon: wrapper.profileImage || wrapper.identicon
anchors.left: parent.left
anchors.leftMargin: !isCompact ? Style.current.padding : Style.current.smallPadding
anchors.verticalCenter: parent.verticalCenter
2020-05-28 11:10:12 +00:00
}
SVGImage {
id: channelIcon
width: 16
height: 16
fillMode: Image.PreserveAspectFit
source: "../../../img/channel-icon-" + (wrapper.chatType === Constants.chatTypePublic ? "public-chat.svg" : "group.svg")
anchors.left: contactImage.right
anchors.leftMargin: Style.current.padding
anchors.top: !isCompact ? parent.top : undefined
anchors.topMargin: !isCompact ? Style.current.smallPadding : 0
anchors.verticalCenter: !isCompact ? undefined : parent.verticalCenter
visible: wrapper.chatType !== Constants.chatTypeOneToOne
}
StyledText {
2020-05-28 11:10:12 +00:00
id: contactInfo
text: wrapper.chatType !== Constants.chatTypePublic ?
Emoji.parse(Utils.removeStatusEns(Utils.filterXSS(wrapper.name))) :
"#" + Utils.filterXSS(wrapper.name)
2020-05-28 11:10:12 +00:00
anchors.right: contactTime.left
anchors.rightMargin: Style.current.smallPadding
2020-05-28 11:10:12 +00:00
elide: Text.ElideRight
font.weight: Font.Medium
font.pixelSize: 15
anchors.left: channelIcon.visible ? channelIcon.right : contactImage.right
anchors.leftMargin: channelIcon.visible ? 2 : Style.current.padding
anchors.top: !isCompact ? parent.top : undefined
anchors.topMargin: !isCompact ? Style.current.smallPadding : 0
anchors.verticalCenter: !isCompact ? undefined : parent.verticalCenter
2020-05-28 11:10:12 +00:00
}
StyledText {
2020-05-28 11:10:12 +00:00
id: lastChatMessage
visible: !isCompact
text: {
switch(contentType){
2020-08-26 15:52:26 +00:00
//% "Image"
case Constants.imageType: return qsTrId("image");
//% "Sticker"
case Constants.stickerType: return qsTrId("sticker");
2020-09-22 07:53:03 +00:00
//% "No messages"
default: return lastMessage ? Emoji.parse(Utils.filterXSS(lastMessage)).replace(/\n|\r/g, ' ') : qsTrId("no-messages")
}
}
textFormat: Text.RichText
clip: true // This is needed because emojis don't ellide correctly
2020-05-28 11:10:12 +00:00
anchors.right: contactNumberChatsCircle.left
anchors.rightMargin: Style.current.smallPadding
2020-05-28 11:10:12 +00:00
elide: Text.ElideRight
anchors.bottom: parent.bottom
anchors.bottomMargin: Style.current.smallPadding
2020-05-28 11:10:12 +00:00
font.pixelSize: 15
anchors.left: contactImage.right
anchors.leftMargin: Style.current.padding
color: Style.current.darkGrey
2020-05-28 11:10:12 +00:00
}
StyledText {
2020-05-28 11:10:12 +00:00
id: contactTime
2021-01-04 14:47:25 +00:00
text: Utils.formatDateTime(wrapper.timestamp, appSettings.locale)
anchors.right: parent.right
anchors.rightMargin: !isCompact ? Style.current.padding : Style.current.smallPadding
anchors.top: !isCompact ? parent.top : undefined
anchors.topMargin: !isCompact ? Style.current.smallPadding : 0
anchors.verticalCenter: !isCompact ? undefined : parent.verticalCenter
font.pixelSize: 11
color: Style.current.darkGrey
2020-05-28 11:10:12 +00:00
}
Rectangle {
id: contactNumberChatsCircle
width: 22
height: 22
radius: 50
anchors.right: !isCompact ? parent.right : contactTime.left
anchors.rightMargin: !isCompact ? Style.current.padding : Style.current.smallPadding
anchors.bottom: !isCompact ? parent.bottom : undefined
anchors.bottomMargin: !isCompact ? Style.current.smallPadding : 0
anchors.verticalCenter: !isCompact ? undefined : parent.verticalCenter
color: Style.current.blue
visible: (unviewedMessagesCount > 0) || wrapper.hasMentions
StyledText {
2020-05-28 11:10:12 +00:00
id: contactNumberChats
2020-12-02 19:28:13 +00:00
text: wrapper.hasMentions ? '@' : (wrapper.unviewedMessagesCount < 100 ? wrapper.unviewedMessagesCount : "99+")
font.pixelSize: 12
2020-05-28 11:10:12 +00:00
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
color: Style.current.white
2020-05-28 11:10:12 +00:00
}
}
MouseArea {
2020-12-15 16:04:19 +00:00
enabled: enableMouseArea
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
anchors.fill: parent
hoverEnabled: true
onEntered: {
wrapper.hovered = true
}
onExited: {
wrapper.hovered = false
}
onClicked: {
if (mouse.button & Qt.RightButton) {
channelContextMenu.openMenu(index, muted, chatType, name, chatId, identicon)
return;
}
chatsModel.setActiveChannelByIndex(index)
chatGroupsListView.currentIndex = index
}
}
2020-05-28 11:10:12 +00:00
}
2020-06-17 19:18:31 +00:00
/*##^##
Designer {
D{i:0;formeditorColor:"#ffffff";height:64;width:640}
2020-06-17 19:18:31 +00:00
}
##^##*/