diff --git a/imports/NeoChat/Component/ChatTextInput.qml b/imports/NeoChat/Component/ChatTextInput.qml index 658c60f48..27a100b10 100644 --- a/imports/NeoChat/Component/ChatTextInput.qml +++ b/imports/NeoChat/Component/ChatTextInput.qml @@ -95,7 +95,7 @@ ToolBar { Layout.preferredHeight: Kirigami.Units.gridUnit source: replyUser ? ("image://mxc/" + replyUser.avatarMediaId) : "" - name: replyUser ? replyUser.displayName : i18n("No name") + name: replyUser ? replyUser.name : i18n("No name") } Label { diff --git a/imports/NeoChat/Component/Timeline/MessageDelegate.qml b/imports/NeoChat/Component/Timeline/MessageDelegate.qml index 49f620b07..72278f7f7 100644 --- a/imports/NeoChat/Component/Timeline/MessageDelegate.qml +++ b/imports/NeoChat/Component/Timeline/MessageDelegate.qml @@ -51,7 +51,7 @@ RowLayout { Layout.alignment: Qt.AlignTop visible: showAuthor && Config.showAvatarInTimeline - name: author.displayName + name: author.name source: author.avatarMediaId ? ("image://mxc/" + author.avatarMediaId) : "" color: author.color diff --git a/imports/NeoChat/Component/Timeline/ReplyComponent.qml b/imports/NeoChat/Component/Timeline/ReplyComponent.qml index 5e37af492..641883871 100644 --- a/imports/NeoChat/Component/Timeline/ReplyComponent.qml +++ b/imports/NeoChat/Component/Timeline/ReplyComponent.qml @@ -31,7 +31,7 @@ QQC2.AbstractButton { Layout.alignment: Qt.AlignTop visible: Config.showAvatarInTimeline source: replyVisible && reply.author.avatarMediaId ? ("image://mxc/" + reply.author.avatarMediaId) : "" - name: replyVisible ? reply.author.displayName : "H" + name: replyVisible ? reply.author.name : "H" color: replyVisible ? reply.author.color : Kirigami.Theme.highlightColor } diff --git a/imports/NeoChat/Component/Timeline/StateDelegate.qml b/imports/NeoChat/Component/Timeline/StateDelegate.qml index a88a2bbdf..7ced5476c 100644 --- a/imports/NeoChat/Component/Timeline/StateDelegate.qml +++ b/imports/NeoChat/Component/Timeline/StateDelegate.qml @@ -25,7 +25,7 @@ RowLayout { Layout.preferredWidth: Kirigami.Units.iconSizes.small Layout.preferredHeight: Kirigami.Units.iconSizes.small - name: author.displayName + name: author.name source: author.avatarMediaId ? ("image://mxc/" + author.avatarMediaId) : "" color: author.color diff --git a/imports/NeoChat/Dialog/RoomSettingsDialog.qml b/imports/NeoChat/Dialog/RoomSettingsDialog.qml index fd95626a9..0ea859934 100644 --- a/imports/NeoChat/Dialog/RoomSettingsDialog.qml +++ b/imports/NeoChat/Dialog/RoomSettingsDialog.qml @@ -42,7 +42,7 @@ Kirigami.OverlaySheet { Layout.preferredHeight: 72 Layout.alignment: Qt.AlignTop - name: room.displayName + name: room.name source: room.avatarMediaId ? ("image://mxc/" + room.avatarMediaId) : "" MouseArea { diff --git a/imports/NeoChat/Page/RoomListPage.qml b/imports/NeoChat/Page/RoomListPage.qml index e952653bf..e615433e8 100644 --- a/imports/NeoChat/Page/RoomListPage.qml +++ b/imports/NeoChat/Page/RoomListPage.qml @@ -92,7 +92,7 @@ Kirigami.ScrollablePage { id: roomListItem property bool itemVisible: model.categoryVisible || sortFilterRoomListModel.filterText.length > 0 || Config.mergeRoomList visible: itemVisible - highlighted: roomManager.currentRoom && roomManager.currentRoom.name === name + highlighted: roomManager.currentRoom && roomManager.currentRoom.displayName === displayName focus: true action: Kirigami.Action { id: enterRoomAction @@ -151,7 +151,7 @@ Kirigami.ScrollablePage { QQC2.Label { Layout.fillWidth: true Layout.fillHeight: true - text: name ?? "" + text: displayName ?? "" elide: Text.ElideRight font.bold: unreadCount >= 0 || highlightCount > 0 || notificationCount > 0 wrapMode: Text.NoWrap diff --git a/imports/NeoChat/Panel/RoomDrawer.qml b/imports/NeoChat/Panel/RoomDrawer.qml index 5abe2e84e..ab6a596cf 100644 --- a/imports/NeoChat/Panel/RoomDrawer.qml +++ b/imports/NeoChat/Panel/RoomDrawer.qml @@ -104,7 +104,7 @@ Kirigami.OverlayDrawer { Layout.preferredWidth: Kirigami.Units.gridUnit * 3.5 Layout.preferredHeight: Kirigami.Units.gridUnit * 3.5 - name: room ? room.displayName : i18n("No name") + name: room ? room.name : i18n("No name") source: room ? ("image://mxc/" + room.avatarMediaId) : "" } diff --git a/src/messageeventmodel.cpp b/src/messageeventmodel.cpp index 1490aa1d1..cceefb01f 100644 --- a/src/messageeventmodel.cpp +++ b/src/messageeventmodel.cpp @@ -303,6 +303,7 @@ inline QVariantMap userAtEvent(NeoChatUser *user, NeoChatRoom *room, const RoomE {"avatarMediaId", user->avatarMediaId(room)}, {"avatarUrl", user->avatarUrl(room)}, {"displayName", user->displayname(room)}, + {"display", user->name()}, {"color", user->color()}, {"object", QVariant::fromValue(user)}, }; diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index 65e282929..4f13ba749 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -288,7 +288,7 @@ QString NeoChatRoom::avatarMediaId() const const auto dcUsers = directChatUsers(); for (const auto u : dcUsers) { if (u != localUser()) { - return u->avatarMediaId(); + return u->avatarMediaId(this); } } diff --git a/src/roomlistmodel.cpp b/src/roomlistmodel.cpp index e6f515b16..fe5bc392f 100644 --- a/src/roomlistmodel.cpp +++ b/src/roomlistmodel.cpp @@ -256,6 +256,9 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const } NeoChatRoom *room = m_rooms.at(index.row()); if (role == NameRole) { + return !room->name().isEmpty() ? room->name() : room->displayName(); + } + if (role == DisplayNameRole) { return room->displayName(); } if (role == AvatarRole) { @@ -324,6 +327,7 @@ QHash RoomListModel::roleNames() const { QHash roles; roles[NameRole] = "name"; + roles[DisplayNameRole] = "displayName"; roles[AvatarRole] = "avatar"; roles[TopicRole] = "topic"; roles[CategoryRole] = "category"; diff --git a/src/roomlistmodel.h b/src/roomlistmodel.h index 4f63695ce..43969860f 100644 --- a/src/roomlistmodel.h +++ b/src/roomlistmodel.h @@ -39,6 +39,7 @@ class RoomListModel : public QAbstractListModel public: enum EventRoles { NameRole = Qt::UserRole + 1, + DisplayNameRole, AvatarRole, TopicRole, CategoryRole,