From dcddaed4a7dc141d0ecb1e905c9fcb2dde86b263 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Fri, 9 Jun 2023 15:41:26 +0200 Subject: [PATCH] Incoming chat messages : Display avatar and author name if not grouped. Fix author name on call events. --- .../src/components/chat-events/ChatCallModel.cpp | 11 +++++++++++ .../src/components/chat-events/ChatCallModel.hpp | 3 +++ linphone-app/ui/modules/Linphone/Chat/Chat.qml | 12 ++---------- .../ui/modules/Linphone/Chat/IncomingMessage.qml | 8 +------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/linphone-app/src/components/chat-events/ChatCallModel.cpp b/linphone-app/src/components/chat-events/ChatCallModel.cpp index 5191e3a48..c84f29def 100644 --- a/linphone-app/src/components/chat-events/ChatCallModel.cpp +++ b/linphone-app/src/components/chat-events/ChatCallModel.cpp @@ -22,6 +22,7 @@ #include "app/App.hpp" #include "components/core/CoreManager.hpp" +#include "utils/Utils.hpp" #include "ChatCallModel.hpp" @@ -58,6 +59,16 @@ QSharedPointer ChatCallModel::create(std::shared_ptr ChatCallModel::getCallLog(){ return mCallLog; } + +QString ChatCallModel::getFromDisplayName(){ + if(!mFromDisplayNameCache.isEmpty()) + return mFromDisplayNameCache; + if(!mCallLog) + return ""; + mFromDisplayNameCache = Utils::getDisplayName(mCallLog->getFromAddress()); + return mFromDisplayNameCache; +} + //-------------------------------------------------------------------------------------------------------------------------- void ChatCallModel::setIsStart(const bool& data){ if(data != mIsStart) { diff --git a/linphone-app/src/components/chat-events/ChatCallModel.hpp b/linphone-app/src/components/chat-events/ChatCallModel.hpp index dcfebe7e2..7a47e0141 100644 --- a/linphone-app/src/components/chat-events/ChatCallModel.hpp +++ b/linphone-app/src/components/chat-events/ChatCallModel.hpp @@ -38,12 +38,14 @@ public: Q_PROPERTY(ChatRoomModel::EntryType type MEMBER mType CONSTANT) Q_PROPERTY(QDateTime timestamp MEMBER mTimestamp CONSTANT) Q_PROPERTY(QDateTime receivedTimestamp MEMBER mReceivedTimestamp CONSTANT) + Q_PROPERTY(QString fromDisplayName READ getFromDisplayName CONSTANT) Q_PROPERTY(bool isStart MEMBER mIsStart WRITE setIsStart NOTIFY isStartChanged) Q_PROPERTY(LinphoneEnums::CallStatus status MEMBER mStatus WRITE setStatus NOTIFY statusChanged) Q_PROPERTY(bool isOutgoing MEMBER mIsOutgoing WRITE setIsOutgoing NOTIFY isOutgoingChanged) std::shared_ptr getCallLog(); + QString getFromDisplayName(); void setIsStart(const bool& isStart); void setStatus(const LinphoneEnums::CallStatus& status); @@ -63,6 +65,7 @@ signals: private: std::shared_ptr mCallLog; + QString mFromDisplayNameCache; }; Q_DECLARE_METATYPE(QSharedPointer) Q_DECLARE_METATYPE(ChatCallModel*) diff --git a/linphone-app/ui/modules/Linphone/Chat/Chat.qml b/linphone-app/ui/modules/Linphone/Chat/Chat.qml index 7f19d6f81..f1211724d 100644 --- a/linphone-app/ui/modules/Linphone/Chat/Chat.qml +++ b/linphone-app/ui/modules/Linphone/Chat/Chat.qml @@ -195,7 +195,7 @@ Rectangle { Layout.rightMargin: ChatStyle.entry.message.outgoing.areaSize spacing:0 // Display time. - visible: !entry.isTopGrouped + visible: !entry.isTopGrouped// && !entry.isNotice Text { id:timeDisplay @@ -216,7 +216,6 @@ Rectangle { TooltipArea { text: entry.chatEntry ? UtilsCpp.toDateTimeString(entry.chatEntry.timestamp) : '' } - visible:!entry.isNotice } Text{ id:authorName @@ -226,14 +225,7 @@ Rectangle { color: ChatStyle.entry.event.text.colorModel.color font.pointSize: ChatStyle.entry.event.text.pointSize - visible: entry.isMessage - && entry.chatEntry - && !entry.chatEntry.isOutgoing // Only outgoing - && (!entry.previousItem //No previous entry - || entry.previousItem.type != ChatRoomModel.MessageEntry // Previous entry is a message - || entry.previousItem.fromSipAddress != entry.chatEntry.fromSipAddress // Different user - || (new Date(entry.previousItem.timestamp)).setHours(0, 0, 0, 0) != (new Date(entry.chatEntry.timestamp)).setHours(0, 0, 0, 0) // Same day == section - ) + visible: entry.chatEntry && !entry.chatEntry.isOutgoing && text != '' } } // Display content. diff --git a/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml b/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml index 620988e64..9d4ebc305 100644 --- a/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml +++ b/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml @@ -47,13 +47,7 @@ RowLayout { if (index <= 0) { return true // 1. First message, so visible. } - var previousEntry = proxyModel.getAt(index - 1) - return !$chatEntry.isOutgoing && (// Only outgoing - !previousEntry //No previous entry - || previousEntry.type != ChatRoomModel.MessageEntry // Previous entry is a message - || previousEntry.fromSipAddress != $chatEntry.fromSipAddress // Different user - || (new Date(previousEntry.timestamp)).setHours(0, 0, 0, 0) != (new Date($chatEntry.timestamp)).setHours(0, 0, 0, 0) // Same day == section - ) + return !$chatEntry.isOutgoing && !mainRow.isTopGrouped } TooltipArea{ delay:0