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:
@@ -54,7 +54,16 @@ Labs.MenuBar {
|
|||||||
}
|
}
|
||||||
Labs.MenuItem {
|
Labs.MenuItem {
|
||||||
text: i18nc("menu", "Browse Chats…")
|
text: i18nc("menu", "Browse Chats…")
|
||||||
onTriggered: pushReplaceLayer("qrc:/JoinRoomPage.qml", {connection: Controller.activeConnection})
|
onTriggered: {
|
||||||
|
let dialog = pageStack.pushDialogLayer("qrc:/JoinRoomPage.qml", {connection: Controller.activeConnection}, {title: i18nc("@title", "Explore Rooms")})
|
||||||
|
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||||
|
if (isJoined) {
|
||||||
|
RoomManager.enterRoom(Controller.activeConnection.room(roomId))
|
||||||
|
} else {
|
||||||
|
Controller.joinRoom(roomId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EditMenu {
|
EditMenu {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import org.kde.neochat 1.0
|
|||||||
Delegates.RoundedItemDelegate {
|
Delegates.RoundedItemDelegate {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property NeoChatConnection connection
|
|
||||||
required property string roomId
|
required property string roomId
|
||||||
required property string displayName
|
required property string displayName
|
||||||
required property url avatarUrl
|
required property url avatarUrl
|
||||||
@@ -24,16 +23,32 @@ Delegates.RoundedItemDelegate {
|
|||||||
required property bool isJoined
|
required property bool isJoined
|
||||||
property bool justJoined: false
|
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: {
|
onClicked: {
|
||||||
if (!isJoined) {
|
if (!isJoined) {
|
||||||
Controller.joinRoom(root.roomId)
|
|
||||||
justJoined = true;
|
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 {
|
contentItem: RowLayout {
|
||||||
|
|||||||
@@ -20,6 +20,21 @@ Kirigami.ScrollablePage {
|
|||||||
property alias keyword: identifierField.text
|
property alias keyword: identifierField.text
|
||||||
property string server
|
property string server
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Signal emitted when a room is selected.
|
||||||
|
*
|
||||||
|
* The signal contains all the room's info so that it can be acted
|
||||||
|
* upon as required, e.g. joinng 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)
|
||||||
|
|
||||||
title: i18n("Explore Rooms")
|
title: i18n("Explore Rooms")
|
||||||
|
|
||||||
Component.onCompleted: identifierField.forceActiveFocus()
|
Component.onCompleted: identifierField.forceActiveFocus()
|
||||||
@@ -211,7 +226,10 @@ Kirigami.ScrollablePage {
|
|||||||
}
|
}
|
||||||
delegate: ExplorerDelegate {
|
delegate: ExplorerDelegate {
|
||||||
connection: root.connection
|
connection: root.connection
|
||||||
onRoomSelected: root.closeDialog()
|
onRoomSelected: (roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||||
|
root.roomSelected(roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined);
|
||||||
|
root.closeDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
footer: RowLayout {
|
footer: RowLayout {
|
||||||
|
|||||||
@@ -19,7 +19,14 @@ RowLayout {
|
|||||||
text: i18n("Explore rooms")
|
text: i18n("Explore rooms")
|
||||||
icon.name: "compass"
|
icon.name: "compass"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
pageStack.pushDialogLayer("qrc:/JoinRoomPage.qml", {connection: Controller.activeConnection}, {title: i18nc("@title", "Explore Rooms")})
|
let dialog = pageStack.pushDialogLayer("qrc:/JoinRoomPage.qml", {connection: Controller.activeConnection}, {title: i18nc("@title", "Explore Rooms")})
|
||||||
|
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||||
|
if (isJoined) {
|
||||||
|
RoomManager.enterRoom(Controller.activeConnection.room(roomId))
|
||||||
|
} else {
|
||||||
|
Controller.joinRoom(roomId)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
property Kirigami.Action chatAction: Kirigami.Action {
|
property Kirigami.Action chatAction: Kirigami.Action {
|
||||||
|
|||||||
@@ -153,10 +153,21 @@ Kirigami.Page {
|
|||||||
helpfulAction: Kirigami.Action {
|
helpfulAction: Kirigami.Action {
|
||||||
icon.name: sortFilterRoomListModel.filterText.length > 0 ? "search" : "list-add"
|
icon.name: sortFilterRoomListModel.filterText.length > 0 ? "search" : "list-add"
|
||||||
text: sortFilterRoomListModel.filterText.length > 0 ? i18n("Search in room directory") : i18n("Explore rooms")
|
text: sortFilterRoomListModel.filterText.length > 0 ? i18n("Search in room directory") : i18n("Explore rooms")
|
||||||
onTriggered: pageStack.layers.push("qrc:/JoinRoomPage.qml", {
|
onTriggered: {
|
||||||
connection: Controller.activeConnection,
|
let dialog = pageStack.layers.push("qrc:/JoinRoomPage.qml", {
|
||||||
keyword: sortFilterRoomListModel.filterText
|
connection: Controller.activeConnection,
|
||||||
})
|
keyword: sortFilterRoomListModel.filterText
|
||||||
|
}, {
|
||||||
|
title: i18nc("@title", "Explore Rooms")
|
||||||
|
})
|
||||||
|
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||||
|
if (isJoined) {
|
||||||
|
RoomManager.enterRoom(Controller.activeConnection.room(roomId))
|
||||||
|
} else {
|
||||||
|
Controller.joinRoom(roomId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user