2020-10-31 22:49:03 +03:00
|
|
|
import QtQuick 2.6
|
2020-10-19 13:20:02 +03:00
|
|
|
import Sailfish.Silica 1.0
|
2020-11-25 02:23:38 +03:00
|
|
|
import WerkWolf.Fernschreiber 1.0
|
2023-02-05 23:44:02 +03:00
|
|
|
import "../js/functions.js" as Functions
|
2020-11-25 02:23:38 +03:00
|
|
|
|
2020-10-19 13:20:02 +03:00
|
|
|
ListItem {
|
|
|
|
id: chatListViewItem
|
|
|
|
|
|
|
|
property alias primaryText: primaryText //usually chat name
|
|
|
|
property alias prologSecondaryText: prologSecondaryText //usually last sender name
|
|
|
|
property alias secondaryText: secondaryText //usually last message
|
|
|
|
property alias tertiaryText: tertiaryText //usually last message date
|
|
|
|
|
2020-11-28 21:11:51 +03:00
|
|
|
property int unreadCount: 0
|
2022-06-06 16:55:21 +03:00
|
|
|
property int unreadMentionCount: 0
|
|
|
|
property int unreadReactionCount: 0
|
2020-11-25 02:23:38 +03:00
|
|
|
property bool isSecret: false
|
2020-12-03 02:50:38 +03:00
|
|
|
property bool isVerified: false
|
2020-12-31 02:19:36 +03:00
|
|
|
property bool isMarkedAsUnread: false
|
2021-01-06 12:42:12 +03:00
|
|
|
property bool isPinned: false
|
2021-01-10 00:25:58 +03:00
|
|
|
property bool isMuted: false
|
2020-10-19 13:20:02 +03:00
|
|
|
property alias pictureThumbnail: pictureThumbnail
|
|
|
|
|
2021-01-19 00:55:15 +03:00
|
|
|
contentHeight: Theme.itemSizeExtraLarge
|
2020-10-19 13:20:02 +03:00
|
|
|
contentWidth: parent.width
|
|
|
|
|
2021-01-19 00:55:15 +03:00
|
|
|
|
|
|
|
ShaderEffectSource {
|
|
|
|
id: pictureItem
|
|
|
|
height: Theme.itemSizeLarge
|
|
|
|
width: height
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
leftMargin: Theme.horizontalPageMargin
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceItem: Item {
|
|
|
|
width: pictureItem.width
|
|
|
|
height: pictureItem.width
|
|
|
|
|
|
|
|
ProfileThumbnail {
|
|
|
|
id: pictureThumbnail
|
|
|
|
replacementStringHint: primaryText.text
|
|
|
|
width: parent.width
|
|
|
|
height: parent.width
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: chatPinnedBackground
|
|
|
|
color: Theme.rgba(Theme.overlayBackgroundColor, Theme.opacityFaint)
|
|
|
|
width: Theme.fontSizeLarge
|
|
|
|
height: Theme.fontSizeLarge
|
|
|
|
anchors.top: parent.top
|
|
|
|
radius: parent.width / 2
|
|
|
|
visible: chatListViewItem.isPinned
|
|
|
|
}
|
|
|
|
|
|
|
|
Icon {
|
|
|
|
source: "../../images/icon-s-pin.svg"
|
|
|
|
height: Theme.iconSizeExtraSmall
|
|
|
|
width: Theme.iconSizeExtraSmall
|
|
|
|
highlighted: chatListViewItem.highlighted
|
|
|
|
sourceSize: Qt.size(Theme.iconSizeExtraSmall, Theme.iconSizeExtraSmall)
|
|
|
|
anchors.centerIn: chatPinnedBackground
|
|
|
|
visible: chatListViewItem.isPinned
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: chatSecretBackground
|
|
|
|
color: Theme.rgba(Theme.overlayBackgroundColor, Theme.opacityFaint)
|
|
|
|
width: Theme.fontSizeLarge
|
|
|
|
height: Theme.fontSizeLarge
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
radius: parent.width / 2
|
|
|
|
visible: chatListViewItem.isSecret
|
|
|
|
}
|
|
|
|
|
|
|
|
Icon {
|
|
|
|
source: "image://theme/icon-s-secure"
|
|
|
|
height: Theme.iconSizeExtraSmall
|
|
|
|
width: Theme.iconSizeExtraSmall
|
|
|
|
highlighted: chatListViewItem.highlighted
|
|
|
|
anchors.centerIn: chatSecretBackground
|
|
|
|
visible: chatListViewItem.isSecret
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: chatUnreadMessagesCountBackground
|
2021-02-07 03:29:50 +03:00
|
|
|
color: isMuted ? ((Theme.colorScheme === Theme.DarkOnLight) ? "lightgray" : "dimgray") : Theme.highlightBackgroundColor
|
2023-08-03 15:02:34 +03:00
|
|
|
width: chatUnreadMessagesCount.width + Theme.fontSizeLarge / 2
|
2021-01-19 00:55:15 +03:00
|
|
|
height: Theme.fontSizeLarge
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
radius: parent.width / 2
|
|
|
|
visible: chatListViewItem.unreadCount > 0 || chatListViewItem.isMarkedAsUnread
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: chatUnreadMessagesCount
|
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
|
|
font.bold: true
|
|
|
|
color: Theme.primaryColor
|
|
|
|
anchors.centerIn: chatUnreadMessagesCountBackground
|
|
|
|
visible: chatListViewItem.unreadCount > 0
|
2021-02-07 03:29:50 +03:00
|
|
|
opacity: isMuted ? Theme.opacityHigh : 1.0
|
2023-02-05 23:44:02 +03:00
|
|
|
text: Functions.formatUnreadCount(chatListViewItem.unreadCount)
|
2021-01-19 00:55:15 +03:00
|
|
|
}
|
2022-06-06 16:55:21 +03:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: isMuted ? ((Theme.colorScheme === Theme.DarkOnLight) ? "lightgray" : "dimgray") : Theme.highlightBackgroundColor
|
|
|
|
width: Theme.fontSizeLarge
|
|
|
|
height: Theme.fontSizeLarge
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
radius: parent.width / 2
|
2023-11-21 23:34:10 +03:00
|
|
|
visible: chatListViewItem.unreadReactionCount > 0 || chatListViewItem.unreadMentionCount > 0
|
|
|
|
|
|
|
|
Icon {
|
|
|
|
source: "image://theme/icon-s-favorite"
|
|
|
|
height: Theme.iconSizeExtraSmall
|
|
|
|
width: Theme.iconSizeExtraSmall
|
|
|
|
highlighted: chatListViewItem.highlighted
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: chatListViewItem.unreadReactionCount > 0 && !chatListViewItem.unreadMentionCount
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
font {
|
|
|
|
pixelSize: Theme.iconSizeExtraSmall
|
|
|
|
bold: true
|
|
|
|
}
|
|
|
|
color: Theme.primaryColor
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: chatListViewItem.unreadMentionCount > 0
|
|
|
|
opacity: isMuted ? Theme.opacityHigh : 1.0
|
|
|
|
text: "@"
|
|
|
|
}
|
2022-06-06 16:55:21 +03:00
|
|
|
}
|
2021-01-19 00:55:15 +03:00
|
|
|
}
|
|
|
|
}
|
2023-11-21 23:34:10 +03:00
|
|
|
|
2020-10-19 13:20:02 +03:00
|
|
|
Column {
|
2021-01-19 00:55:15 +03:00
|
|
|
id: contentColumn
|
2020-10-19 13:20:02 +03:00
|
|
|
anchors {
|
|
|
|
verticalCenter: parent.verticalCenter
|
2021-01-19 00:55:15 +03:00
|
|
|
left: pictureItem.right
|
|
|
|
leftMargin: Theme.paddingSmall
|
|
|
|
right: parent.right
|
|
|
|
rightMargin: Theme.horizontalPageMargin
|
2020-10-19 13:20:02 +03:00
|
|
|
}
|
2021-01-19 00:55:15 +03:00
|
|
|
spacing: Theme.paddingSmall / 2
|
2020-10-19 13:20:02 +03:00
|
|
|
|
|
|
|
Row {
|
2021-01-19 00:55:15 +03:00
|
|
|
id: primaryTextRow
|
2020-10-19 13:20:02 +03:00
|
|
|
spacing: Theme.paddingMedium
|
|
|
|
|
2021-01-19 00:55:15 +03:00
|
|
|
Label {
|
|
|
|
id: primaryText
|
|
|
|
textFormat: Text.StyledText
|
|
|
|
font.pixelSize: Theme.fontSizeMedium
|
|
|
|
truncationMode: TruncationMode.Fade
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: Math.min(contentColumn.width - (verifiedImage.visible ? (verifiedImage.width + primaryTextRow.spacing) : 0) - (mutedImage.visible ? (mutedImage.width + primaryTextRow.spacing) : 0), implicitWidth)
|
2023-11-19 00:40:12 +03:00
|
|
|
font.bold: appSettings.highlightUnreadConversations && ( !chatListViewItem.isMuted && (chatListViewItem.unreadCount > 0 || chatListViewItem.isMarkedAsUnread) )
|
|
|
|
font.italic: appSettings.highlightUnreadConversations && (chatListViewItem.unreadReactionCount > 0)
|
|
|
|
color: (appSettings.highlightUnreadConversations && (chatListViewItem.unreadCount > 0)) ? Theme.highlightColor : Theme.primaryColor
|
2021-01-19 00:55:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: verifiedImage
|
2020-10-19 13:20:02 +03:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-01-19 00:55:15 +03:00
|
|
|
source: chatListViewItem.isVerified ? "../../images/icon-verified.svg" : ""
|
|
|
|
sourceSize: Qt.size(Theme.iconSizeExtraSmall, Theme.iconSizeExtraSmall)
|
|
|
|
width: Theme.iconSizeSmall
|
|
|
|
height: Theme.iconSizeSmall
|
|
|
|
visible: status === Image.Ready
|
2020-10-19 13:20:02 +03:00
|
|
|
}
|
|
|
|
|
2021-01-19 00:55:15 +03:00
|
|
|
Image {
|
|
|
|
id: mutedImage
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
source: chatListViewItem.isMuted ? "../js/emoji/1f507.svg" : ""
|
|
|
|
sourceSize: Qt.size(Theme.iconSizeExtraSmall, Theme.iconSizeExtraSmall)
|
|
|
|
width: Theme.iconSizeSmall
|
|
|
|
height: Theme.iconSizeSmall
|
|
|
|
visible: status === Image.Ready
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Row {
|
|
|
|
width: parent.width
|
|
|
|
spacing: Theme.paddingSmall
|
|
|
|
Label {
|
|
|
|
id: prologSecondaryText
|
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
|
|
width: Math.min(implicitWidth, parent.width)
|
|
|
|
color: Theme.highlightColor
|
|
|
|
textFormat: Text.StyledText
|
|
|
|
truncationMode: TruncationMode.Fade
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
id: secondaryText
|
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
|
|
width: parent.width - Theme.paddingMedium - prologSecondaryText.width
|
|
|
|
truncationMode: TruncationMode.Fade
|
|
|
|
textFormat: Text.StyledText
|
|
|
|
visible: prologSecondaryText.width < ( parent.width - Theme.paddingLarge )
|
2020-10-19 13:20:02 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-19 00:55:15 +03:00
|
|
|
|
|
|
|
Label {
|
|
|
|
id: tertiaryText
|
|
|
|
width: parent.width
|
|
|
|
font.pixelSize: Theme.fontSizeTiny
|
|
|
|
color: Theme.secondaryColor
|
|
|
|
truncationMode: TruncationMode.Fade
|
|
|
|
}
|
2020-10-19 13:20:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
id: separator
|
|
|
|
anchors {
|
2021-01-19 00:55:15 +03:00
|
|
|
bottom: parent.bottom
|
|
|
|
bottomMargin: -1
|
2020-10-19 13:20:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
color: Theme.primaryColor
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|