From 50e8b9ebf6c8472266993b5a2e2da9021215fa68 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sun, 27 Aug 2023 19:05:55 +0000 Subject: [PATCH] Visit User Move to using visit user in all cases. --- .../Component/Timeline/TimelineContainer.qml | 10 ++-------- src/qml/Component/TimelineView.qml | 13 ------------- src/qml/Page/RoomPage.qml | 17 ++++++++++++++++- src/qml/RoomDrawer/DirectChatDrawerHeader.qml | 12 +----------- src/qml/RoomDrawer/RoomInformation.qml | 14 +------------- src/qml/main.qml | 10 ---------- src/roommanager.h | 2 +- 7 files changed, 21 insertions(+), 57 deletions(-) diff --git a/src/qml/Component/Timeline/TimelineContainer.qml b/src/qml/Component/Timeline/TimelineContainer.qml index 8d63d592c..d6371431d 100644 --- a/src/qml/Component/Timeline/TimelineContainer.qml +++ b/src/qml/Component/Timeline/TimelineContainer.qml @@ -375,10 +375,7 @@ ColumnLayout { MouseArea { anchors.fill: parent onClicked: { - userDetailDialog.createObject(QQC2.ApplicationWindow.overlay, { - room: currentRoom, - user: root.author - }).open(); + RoomManager.visitUser(root.author.object, "mention") } cursorShape: Qt.PointingHandCursor } @@ -459,10 +456,7 @@ ColumnLayout { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - userDetailDialog.createObject(QQC2.ApplicationWindow.overlay, { - room: currentRoom, - user: root.author - }).open(); + RoomManager.visitUser(root.author.object, "mention") } } } diff --git a/src/qml/Component/TimelineView.qml b/src/qml/Component/TimelineView.qml index 8a8aa8281..c98be8f6f 100644 --- a/src/qml/Component/TimelineView.qml +++ b/src/qml/Component/TimelineView.qml @@ -222,12 +222,6 @@ QQC2.ScrollView { FileDelegateContextMenu {} } - Component { - id: userDetailDialog - - UserDetailDialog {} - } - TypingPane { id: typingPane visible: root.currentRoom && root.currentRoom.usersTyping.length > 0 @@ -445,11 +439,4 @@ QQC2.ScrollView { function positionViewAtBeginning() { messageListView.positionViewAtBeginning() } - - function showUserDetail(user) { - userDetailDialog.createObject(QQC2.ApplicationWindow.overlay, { - room: root.currentRoom, - user: root.currentRoom.getUser(user.id), - }).open(); - } } diff --git a/src/qml/Page/RoomPage.qml b/src/qml/Page/RoomPage.qml index cc76772e8..65bc741c8 100644 --- a/src/qml/Page/RoomPage.qml +++ b/src/qml/Page/RoomPage.qml @@ -189,7 +189,22 @@ Kirigami.Page { banner.visible = true; } + Connections { + target: RoomManager + function onShowUserDetail(user) { + root.showUserDetail(user) + } + } + function showUserDetail(user) { - timelineViewLoader.item.showUserDetail(user) + userDetailDialog.createObject(QQC2.ApplicationWindow.overlay, { + room: root.currentRoom, + user: root.currentRoom.getUser(user.id), + }).open(); + } + + Component { + id: userDetailDialog + UserDetailDialog {} } } diff --git a/src/qml/RoomDrawer/DirectChatDrawerHeader.qml b/src/qml/RoomDrawer/DirectChatDrawerHeader.qml index a2eb4ca9e..0a28b40f0 100644 --- a/src/qml/RoomDrawer/DirectChatDrawerHeader.qml +++ b/src/qml/RoomDrawer/DirectChatDrawerHeader.qml @@ -26,17 +26,7 @@ ColumnLayout { Layout.alignment: Qt.AlignHCenter onClicked: { - const popup = userDetailDialog.createObject(QQC2.ApplicationWindow.overlay, { - room: room, - user: room.getUser(room.directChatRemoteUser.id), - }) - popup.closed.connect(() => { - userListItem.highlighted = false - }) - if (roomDrawer.modal) { - roomDrawer.close() - } - popup.open() + RoomManager.visitUser(room.getUser(room.directChatRemoteUser.id).object, "mention") } contentItem: KirigamiComponents.Avatar { diff --git a/src/qml/RoomDrawer/RoomInformation.qml b/src/qml/RoomDrawer/RoomInformation.qml index 2f780f511..b04f4119f 100644 --- a/src/qml/RoomDrawer/RoomInformation.qml +++ b/src/qml/RoomDrawer/RoomInformation.qml @@ -207,14 +207,7 @@ ListView { onClicked: { userDelegate.highlighted = true; - const popup = userDetailDialog.createObject(QQC2.ApplicationWindow.overlay, { - room: root.room, - user: root.room.getUser(userDelegate.userId) - }); - popup.closed.connect(() => { - userDelegate.highlighted = false; - }); - popup.open(); + RoomManager.visitUser(room.getUser(userDelegate.userId).object, "mention") } contentItem: RowLayout { @@ -258,11 +251,6 @@ ListView { DirectChatDrawerHeader {} } - Component { - id: userDetailDialog - UserDetailDialog {} - } - onRoomChanged: { if (root.headerItem) { root.headerItem.userListSearchField.text = ""; diff --git a/src/qml/main.qml b/src/qml/main.qml index b4e85f208..6ad9aeda7 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -112,11 +112,6 @@ Kirigami.ApplicationWindow { secondaryWindow.show(); } - function onShowUserDetail(user) { - const roomItem = pageStack.get(pageStack.depth - 1); - roomItem.showUserDetail(user); - } - function onAskDirectChatConfirmation(user) { askDirectChatConfirmationComponent.createObject(QQC2.ApplicationWindow.overlay, { user: user, @@ -338,11 +333,6 @@ Kirigami.ApplicationWindow { RoomWindow {} } - Component { - id: userDialog - UserDetailDialog {} - } - Component { id: askDirectChatConfirmationComponent diff --git a/src/roommanager.h b/src/roommanager.h index 9fd9615c3..938a5ee4d 100644 --- a/src/roommanager.h +++ b/src/roommanager.h @@ -94,7 +94,7 @@ public: * * @sa Quotient::UriResolverBase::visitUser(), Quotient::UriResolverBase::visitResource() */ - UriResolveResult visitUser(User *user, const QString &action) override; + Q_INVOKABLE UriResolveResult visitUser(User *user, const QString &action) override; /** * @brief Visit a room.