Emit Room Selected from JoinRoomPage

Change the `JoinRoomPage` so that it emits a `roomSelected` signal with the selected delegate's info instead of calling the functions to join or enter the room itself. This is so that the `JoinRoomPage` can be used for other purposes like selecting an existing child to add to a space.
This commit is contained in:
James Graham
2023-09-11 17:16:12 +00:00
parent 8285961c42
commit ff0990bb7c
5 changed files with 73 additions and 13 deletions

View File

@@ -14,7 +14,6 @@ import org.kde.neochat 1.0
Delegates.RoundedItemDelegate {
id: root
required property NeoChatConnection connection
required property string roomId
required property string displayName
required property url avatarUrl
@@ -24,16 +23,32 @@ Delegates.RoundedItemDelegate {
required property bool isJoined
property bool justJoined: false
signal roomSelected()
/**
* @brief Signal emitted when a room delegate is selected.
*
* The signal contains all the delegate's model info so that it can be acted
* upon as required, e.g. joining or entering the room or adding the room as
* the child of a space.
*/
signal roomSelected(string roomId,
string displayName,
url avatarUrl,
string alias,
string topic,
int memberCount,
bool isJoined)
onClicked: {
if (!isJoined) {
Controller.joinRoom(root.roomId)
justJoined = true;
} else {
RoomManager.enterRoom(root.connection.room(root.roomId))
}
root.roomSelected()
root.roomSelected(root.roomId,
root.displayName,
root.avatarUrl,
root.alias,
root.topic,
root.memberCount,
root.isJoined)
}
contentItem: RowLayout {