Devtools: Use ChooseRoomDialog to select a room for inspection
The combobox has several drawbacks: - It's not sorted in any meaningful way - It doesn't have a search - It doesn't show the icon and last message This makes it hard to find the intended room in that dialog. The ChooseRoomDialog provides these things for us
This commit is contained in:
@@ -21,19 +21,22 @@ ColumnLayout {
|
|||||||
title: i18nc("@title", "Choose Room")
|
title: i18nc("@title", "Choose Room")
|
||||||
}
|
}
|
||||||
FormCard.FormCard {
|
FormCard.FormCard {
|
||||||
FormCard.FormComboBoxDelegate {
|
FormCard.FormButtonDelegate {
|
||||||
id: roomComboBox
|
text: root.room?.displayNameForHtml ?? i18nc("@info", "No room selected")
|
||||||
text: i18n("Room")
|
description: i18nc("@info", "Click to choose a room");
|
||||||
textRole: "escapedDisplayName"
|
|
||||||
valueRole: "roomId"
|
onClicked: {
|
||||||
displayText: RoomManager.roomListModel.data(RoomManager.roomListModel.index(currentIndex, 0), RoomListModel.EscapedDisplayNameRole)
|
let dialog = root.Window.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ChooseRoomDialog'), {
|
||||||
model: RoomManager.roomListModel
|
connection: root.connection,
|
||||||
currentIndex: 0
|
}, {
|
||||||
displayMode: FormCard.FormComboBoxDelegate.Page
|
title: i18nc("@title:dialog", "Choose Room"),
|
||||||
Component.onCompleted: currentIndex = RoomManager.roomListModel.rowForRoom(root.room)
|
width: Kirigami.Units.gridUnit * 24
|
||||||
onCurrentValueChanged: root.room = RoomManager.roomListModel.roomByAliasOrId(roomComboBox.currentValue)
|
});
|
||||||
|
dialog.chosen.connect(id => root.room = root.connection.room(id))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FormCard.FormTextDelegate {
|
FormCard.FormTextDelegate {
|
||||||
|
visible: root.room
|
||||||
text: i18n("Room Id: %1", root.room.id)
|
text: i18n("Room Id: %1", root.room.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,11 @@ SearchPage {
|
|||||||
|
|
||||||
model: RoomManager.sortFilterRoomListModel
|
model: RoomManager.sortFilterRoomListModel
|
||||||
modelDelegate: RoomDelegate {
|
modelDelegate: RoomDelegate {
|
||||||
onClicked: root.chosen(currentRoom.id)
|
onClicked: {
|
||||||
|
root.chosen(currentRoom.id);
|
||||||
|
root.closeDialog();
|
||||||
|
}
|
||||||
connection: root.connection
|
connection: root.connection
|
||||||
|
openOnClick: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ Delegates.RoundedItemDelegate {
|
|||||||
required property string subtitleText
|
required property string subtitleText
|
||||||
required property string displayName
|
required property string displayName
|
||||||
|
|
||||||
|
property bool openOnClick: true
|
||||||
property bool showConfigure: true
|
property bool showConfigure: true
|
||||||
|
|
||||||
property bool collapsed: false
|
property bool collapsed: false
|
||||||
@@ -35,8 +36,10 @@ Delegates.RoundedItemDelegate {
|
|||||||
Accessible.onPressAction: clicked()
|
Accessible.onPressAction: clicked()
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
RoomManager.resolveResource(currentRoom.id);
|
if (root.openOnClick) {
|
||||||
pageStack.currentIndex = 1;
|
RoomManager.resolveResource(currentRoom.id);
|
||||||
|
pageStack.currentIndex = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onPressAndHold: createRoomListContextMenu()
|
onPressAndHold: createRoomListContextMenu()
|
||||||
|
|||||||
Reference in New Issue
Block a user