From fd7182f7a036ded5fe77823ddf53c3e01b78b3bd Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 23 Aug 2024 11:56:29 +0200 Subject: [PATCH] Fixed to show when there is a chat from a friend as overlay icon Fixed to show when there is a chat from a friend as overlay icon, when popup chat is disabled --- .../src/gui/common/FriendListModel.cpp | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 35cefa7ac..eee8e5597 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -34,6 +34,7 @@ #include "gui/common/FriendListModel.h" #include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsIdTreeWidgetItem.h" +#include "gui/chat/ChatUserNotify.h" #include "retroshare/rsexpr.h" #include "retroshare/rsmsgs.h" @@ -996,6 +997,12 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons { QPixmap sslAvatar; bool foundAvatar = false; + bool hasPrivateChat = false; + + // get peers with waiting incoming chats + std::vector privateChatIds; + ChatUserNotify::getPeersWithWaitingChat(privateChatIds); + const HierarchicalProfileInformation *hn = getProfileInfo(entry); uint32_t status = RS_STATUS_OFFLINE; const HierarchicalNodeInformation *bestNodeInformation = NULL; @@ -1023,11 +1030,26 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons if (!foundAvatar || sslAvatar.isNull()) { sslAvatar = FilesDefs::getPixmapFromQtResourcePath(AVATAR_DEFAULT_IMAGE); } + + if (mDisplayStatusIcon) { + for(uint32_t i=0;ichild_node_indices.size();++i) { + if (std::find(privateChatIds.begin(), privateChatIds.end(), RsPeerId(mLocations[hn->child_node_indices[i]].node_info.id.toStdString())) != privateChatIds.end()) { + // private chat is available + hasPrivateChat = true; + break; + } + } + } if (mDisplayStatusIcon) { if (bestNodeInformation) { - QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(status)); - return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon))); + if (hasPrivateChat) { + QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(":/images/orange-bubble-64.png"); + return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon))); + } else { + QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(status)); + return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon))); + } } } @@ -1045,10 +1067,31 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons return QVariant(); QPixmap sslAvatar; + bool hasPrivateChat = false; AvatarDefs::getAvatarFromSslId(RsPeerId(hn->node_info.id.toStdString()), sslAvatar); + + // get peers with waiting incoming chats + std::vector privateChatIds; + ChatUserNotify::getPeersWithWaitingChat(privateChatIds); + if (mDisplayStatusIcon) { - QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(statusRole(entry, col).toInt())); - return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon))); + for(uint32_t i=0;inode_info.id.toStdString())) != privateChatIds.end()) { + // private chat is available + hasPrivateChat = true; + break; + } + } + } + + if (mDisplayStatusIcon) { + if (hasPrivateChat) { + QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(":/images/orange-bubble-64.png"); + return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon))); + } else { + QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(statusRole(entry, col).toInt())); + return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon))); + } } return QVariant(QIcon(sslAvatar));