diff --git a/resources/qml/Avatar.qml b/resources/qml/Avatar.qml index 1b7497c1..bf936bff 100644 --- a/resources/qml/Avatar.qml +++ b/resources/qml/Avatar.qml @@ -12,6 +12,7 @@ Rectangle { property string url property string userid + property string roomid property string displayName property alias textColor: label.color property bool crop: true @@ -43,7 +44,7 @@ Rectangle { id: identicon anchors.fill: parent visible: img.status != Image.Ready && Settings.useIdenticon - source: Settings.useIdenticon ? "image://jdenticon/" + userid + "?radius=" + radius : "" + source: Settings.useIdenticon ? ("image://jdenticon/" + (userid !== "" ? userid : roomid) + "?radius=" + (Settings.avatarCircles ? 100 : 25) + ((avatar.crop) ? "" : "&scale")) : "" layer.enabled: true MouseArea { diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml index fcb2644e..3b7fa84e 100644 --- a/resources/qml/RoomList.qml +++ b/resources/qml/RoomList.qml @@ -143,7 +143,7 @@ Page { required property int notificationCount required property bool hasLoudNotification required property bool hasUnreadMessages - required property int roomMemberCount + required property bool isDirect required property string directChatAvatarMxid color: background @@ -239,7 +239,8 @@ Page { width: avatarSize url: avatarUrl.replace("mxc://", "image://MxcImage/") displayName: roomName - userid: roomMemberCount < 3 ? directChatAvatarMxid : roomId + userid: isDirect ? directChatAvatarMxid : undefined + roomid: roomId Rectangle { id: collapsedNotificationBubble diff --git a/resources/qml/TopBar.qml b/resources/qml/TopBar.qml index 0b50f7c6..78f81b7f 100644 --- a/resources/qml/TopBar.qml +++ b/resources/qml/TopBar.qml @@ -65,7 +65,8 @@ Rectangle { width: Nheko.avatarSize height: Nheko.avatarSize url: avatarUrl.replace("mxc://", "image://MxcImage/") - userid: room.roomMemberCount < 3 ? room.directChatAvatarMxid : room.roomId + roomid: room.roomId + userid: room.isDirect ? room.directChatAvatarMxid : undefined displayName: roomName onClicked: { if (room) diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp index 88411236..d12fb426 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp @@ -76,7 +76,7 @@ RoomlistModel::roleNames() const {IsSpace, "isSpace"}, {Tags, "tags"}, {ParentSpaces, "parentSpaces"}, - {RoomMemberCount, "roomMemberCount"}, + {IsDirect, "isDirect"}, {DirectChatAvatarMxid, "directChatAvatarMxid"}, }; } @@ -131,8 +131,8 @@ RoomlistModel::data(const QModelIndex &index, int role) const list.push_back(QString::fromStdString(t)); return list; } - case Roles::RoomMemberCount: - return room->roomMemberCount(); + case Roles::IsDirect: + return room->isDirect(); case Roles::DirectChatAvatarMxid: return room->directChatAvatarMxid(); default: diff --git a/src/timeline/RoomlistModel.h b/src/timeline/RoomlistModel.h index aca74ea1..57669087 100644 --- a/src/timeline/RoomlistModel.h +++ b/src/timeline/RoomlistModel.h @@ -65,7 +65,7 @@ public: IsPreviewFetched, Tags, ParentSpaces, - RoomMemberCount, + IsDirect, DirectChatAvatarMxid, }; diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 4daf44f3..0e1e8f5d 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -817,6 +817,12 @@ TimelineModel::syncState(const mtx::responses::State &s) emit roomAvatarUrlChanged(); emit roomNameChanged(); emit roomMemberCountChanged(); + + if (roomMemberCount() <= 2) + { + emit isDirectChanged(); + emit directChatAvatarMxidChanged(); + } } else if (std::holds_alternative>(e)) { this->isEncrypted_ = cache::isRoomEncrypted(room_id_.toStdString()); emit encryptionChanged(); diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index 8c34fc1d..03e33066 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -176,6 +176,7 @@ class TimelineModel : public QAbstractListModel Q_PROPERTY(bool isEncrypted READ isEncrypted NOTIFY encryptionChanged) Q_PROPERTY(bool isSpace READ isSpace CONSTANT) Q_PROPERTY(int trustlevel READ trustlevel NOTIFY trustlevelChanged) + Q_PROPERTY(bool isDirect READ isDirect NOTIFY isDirectChanged) Q_PROPERTY( QString directChatAvatarMxid READ directChatAvatarMxid NOTIFY directChatAvatarMxidChanged) Q_PROPERTY(InputBar *input READ input CONSTANT) @@ -294,6 +295,7 @@ public: bool isEncrypted() const { return isEncrypted_; } crypto::Trust trustlevel() const; int roomMemberCount() const; + bool isDirect() const { return roomMemberCount() <= 2; } // TODO: handle invites QString directChatAvatarMxid() const; std::optional eventById(const QString &id) @@ -394,6 +396,7 @@ signals: void roomTopicChanged(); void roomAvatarUrlChanged(); void roomMemberCountChanged(); + void isDirectChanged(); void directChatAvatarMxidChanged(); void permissionsChanged(); void forwardToRoom(mtx::events::collections::TimelineEvents *e, QString roomId);