Display profile pictures and names in groups

This commit is contained in:
Sebastian J. Wolf 2020-08-23 19:17:30 +02:00
parent 63966f052a
commit 1b18a78efc
4 changed files with 105 additions and 49 deletions

View file

@ -182,7 +182,7 @@ Page {
Row { Row {
id: headerRow id: headerRow
width: parent.width - (3 * Theme.horizontalPageMargin) width: parent.width - (3 * Theme.horizontalPageMargin)
height: chatOverviewColumn.height + ( 2 * Theme.horizontalPageMargin ) height: chatOverviewColumn.height + ( 2 * Theme.paddingLarge )
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
spacing: Theme.paddingMedium spacing: Theme.paddingMedium
@ -260,64 +260,112 @@ Page {
delegate: ListItem { delegate: ListItem {
id: messageListItem id: messageListItem
contentHeight: messageTextItem.height + Theme.paddingMedium contentHeight: messageBackground.height + Theme.paddingMedium
contentWidth: parent.width contentWidth: parent.width
property variant myMessage: display property variant myMessage: display
property variant userInformation: tdLibWrapper.getUserInformation(display.sender_user_id)
Column { Row {
id: messageTextItem id: messageTextRow
spacing: Theme.paddingSmall spacing: Theme.paddingSmall
width: parent.width - ( 2 * Theme.horizontalPageMargin )
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width ProfileThumbnail {
height: messageText.height + messageDateText.height + Theme.paddingMedium id: messagePictureThumbnail
anchors.verticalCenter: parent.verticalCenter photoData: (typeof messageListItem.userInformation.profile_photo !== "undefined") ? messageListItem.userInformation.profile_photo.small : ""
replacementStringHint: userText.text
Text { width: visible ? Theme.itemSizeSmall : 0
anchors { height: visible ? Theme.itemSizeSmall : 0
left: parent.left anchors.bottom: parent.bottom
leftMargin: (chatPage.myUserId === display.sender_user_id) ? 4 * Theme.horizontalPageMargin : Theme.horizontalPageMargin anchors.bottomMargin: Theme.paddingSmall
right: parent.right visible: ( chatPage.isBasicGroup || chatPage.isSuperGroup ) && !chatPage.isChannel
rightMargin: (chatPage.myUserId === display.sender_user_id) ? Theme.horizontalPageMargin : 4 * Theme.horizontalPageMargin
}
id: messageText
text: Emoji.emojify(Functions.getSimpleMessageText(display), font.pixelSize)
font.pixelSize: Theme.fontSizeSmall
color: chatPage.myUserId === display.sender_user_id ? Theme.highlightColor : Theme.primaryColor
wrapMode: Text.Wrap
textFormat: Text.StyledText
onLinkActivated: {
// Functions.handleLink(link);
}
horizontalAlignment: (chatPage.myUserId === display.sender_user_id) ? Text.AlignRight : Text.AlignLeft
linkColor: Theme.highlightColor
} }
Timer { Item {
id: messageDateUpdater id: messageTextItem
interval: 60000
running: true width: parent.width - messagePictureThumbnail.width - Theme.paddingSmall
repeat: true height: messageBackground.height
onTriggered: {
messageDateText.text = Functions.getDateTimeElapsed(display.date); Rectangle {
} id: messageBackground
} anchors {
left: parent.left
leftMargin: (chatPage.myUserId === display.sender_user_id) ? 2 * Theme.horizontalPageMargin : 0
right: parent.right
rightMargin: (chatPage.myUserId === display.sender_user_id) ? 0 : 2 * Theme.horizontalPageMargin
verticalCenter: parent.verticalCenter
}
height: messageTextColumn.height + ( 2 * Theme.paddingMedium )
color: Theme.secondaryColor
radius: parent.width / 50
opacity: 0.2
}
Column {
id: messageTextColumn
spacing: Theme.paddingSmall
width: messageBackground.width - Theme.horizontalPageMargin
anchors.centerIn: messageBackground
Text {
id: userText
width: parent.width
text: display.sender_user_id !== chatPage.myUserId ? Emoji.emojify(Functions.getUserName(messageListItem.userInformation), font.pixelSize) : qsTr("You")
font.pixelSize: Theme.fontSizeExtraSmall
font.weight: Font.ExtraBold
color: (chatPage.myUserId === display.sender_user_id) ? Theme.highlightColor : Theme.primaryColor
maximumLineCount: 1
elide: Text.ElideRight
textFormat: Text.StyledText
horizontalAlignment: (chatPage.myUserId === display.sender_user_id) ? Text.AlignRight : Text.AlignLeft
visible: ( chatPage.isBasicGroup || chatPage.isSuperGroup ) && !chatPage.isChannel
}
Text {
id: messageText
width: parent.width
text: Emoji.emojify(Functions.getSimpleMessageText(display), font.pixelSize)
font.pixelSize: Theme.fontSizeSmall
color: (chatPage.myUserId === display.sender_user_id) ? Theme.highlightColor : Theme.primaryColor
wrapMode: Text.Wrap
textFormat: Text.StyledText
onLinkActivated: {
// Functions.handleLink(link);
}
horizontalAlignment: (chatPage.myUserId === display.sender_user_id) ? Text.AlignRight : Text.AlignLeft
linkColor: Theme.highlightColor
}
Timer {
id: messageDateUpdater
interval: 60000
running: true
repeat: true
onTriggered: {
messageDateText.text = Functions.getDateTimeElapsed(display.date);
}
}
Text {
width: parent.width
id: messageDateText
text: Functions.getDateTimeElapsed(display.date)
font.pixelSize: Theme.fontSizeTiny
color: (chatPage.myUserId === display.sender_user_id) ? Theme.secondaryHighlightColor : Theme.secondaryColor
horizontalAlignment: (chatPage.myUserId === display.sender_user_id) ? Text.AlignRight : Text.AlignLeft
}
Text {
anchors {
left: parent.left
leftMargin: (chatPage.myUserId === display.sender_user_id) ? 4 * Theme.horizontalPageMargin : Theme.horizontalPageMargin
right: parent.right
rightMargin: (chatPage.myUserId === display.sender_user_id) ? Theme.horizontalPageMargin : 4 * Theme.horizontalPageMargin
} }
id: messageDateText
text: Functions.getDateTimeElapsed(display.date)
font.pixelSize: Theme.fontSizeTiny
color: chatPage.myUserId === display.sender_user_id ? Theme.secondaryHighlightColor : Theme.secondaryColor
horizontalAlignment: (chatPage.myUserId === display.sender_user_id) ? Text.AlignRight : Text.AlignLeft
} }
} }

View file

@ -203,7 +203,7 @@ QVariantMap TDLibWrapper::getUserInformation()
QVariantMap TDLibWrapper::getUserInformation(const QString &userId) QVariantMap TDLibWrapper::getUserInformation(const QString &userId)
{ {
qDebug() << "[TDLibWrapper] Returning user information for ID " << userId; // qDebug() << "[TDLibWrapper] Returning user information for ID " << userId;
return this->allUsers.value(userId).toMap(); return this->allUsers.value(userId).toMap();
} }

View file

@ -130,6 +130,10 @@
<source>%1 subscribers</source> <source>%1 subscribers</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>You</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>CoverPage</name> <name>CoverPage</name>

View file

@ -130,6 +130,10 @@
<source>%1 subscribers</source> <source>%1 subscribers</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>You</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>CoverPage</name> <name>CoverPage</name>