Improve the "Create a Room/Space" and "Select Existing Room" dialog

First of all, these are now all separate dialogs instead of shoving all
of these functions (which are only marginally related) into one single
dialog. We also convert these to in-app Kirigami Dialogs, which look a
bit nicer. I also touched up the UX in some places, such as adding
descriptions which were previously available to translators. I also hid
some not oft used options like setting a topic, which almost nobody does
before creating a room/space.
This commit is contained in:
Joshua Goins
2025-02-21 17:29:00 -05:00
parent e9568b50fc
commit d3fd441c88
8 changed files with 350 additions and 282 deletions

View File

@@ -6,6 +6,7 @@ import QtQuick.Controls as QQC2
import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.components as KirigamiComponents
import org.kde.neochat
import org.kde.neochat.libneochat as LibNeoChat
@@ -20,6 +21,30 @@ ColumnLayout {
spacing: 0
Component {
id: roomMenuComponent
KirigamiComponents.ConvergentContextMenu {
Kirigami.Action {
icon.name: "list-add-symbolic"
text: i18nc("@action:inmenu", "New Room…")
onTriggered: _private.createRoom(root.currentRoom.id)
}
Kirigami.Action {
icon.name: "list-add-symbolic"
text: i18nc("@action:inmenu", "New Space…")
onTriggered: _private.createSpace(root.currentRoom.id)
}
Kirigami.Action {
icon.name: "search-symbolic"
text: i18nc("@action:inmenu", "Existing Room…")
onTriggered: _private.selectExisting(root.currentRoom.id)
}
}
}
QQC2.Control {
id: headerItem
Layout.fillWidth: true
@@ -57,10 +82,15 @@ ColumnLayout {
})
}
QQC2.Button {
id: addNewButton
visible: root.currentRoom.canSendState("m.space.child")
text: i18nc("@button", "Add new room")
text: i18nc("@button", "Add to Space")
icon.name: "list-add"
onClicked: _private.createRoom(root.currentRoom.id)
onClicked: {
const menu = roomMenuComponent.createObject(addNewButton);
menu.popup();
}
}
QQC2.Button {
text: i18nc("@action:button", "Leave this space")
@@ -158,15 +188,33 @@ ColumnLayout {
}
QtObject {
id: _private
function createRoom(parentId) {
let dialog = applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'CreateRoomDialog'), {
title: i18nc("@title", "Create a Child"),
const dialog = Qt.createComponent('org.kde.neochat', 'CreateRoomDialog').createObject(root, {
connection: root.currentRoom.connection,
parentId: parentId
});
dialog.newChild.connect(childName => {
spaceChildrenModel.addPendingChild(childName);
});
dialog.open();
}
function createSpace(parentId) {
const dialog = Qt.createComponent('org.kde.neochat', 'CreateSpaceDialog').createObject(root, {
connection: root.currentRoom.connection,
parentId: parentId,
});
dialog.newChild.connect(childName => {
spaceChildrenModel.addPendingChild(childName);
});
dialog.open();
}
function selectExisting(parentId) {
const dialog = Qt.createComponent('org.kde.neochat', 'SelectExistingRoomDialog').createObject(root, {
connection: root.currentRoom.connection,
parentId: parentId,
showChildType: true,
showCreateChoice: true
}, {
title: i18nc("@title", "Create a Child")
});
dialog.addChild.connect((childId, setChildParent, canonical) => {
// We have to get a room object from the connection as we may not
@@ -176,9 +224,7 @@ ColumnLayout {
parent.addChild(childId, setChildParent, canonical);
}
});
dialog.newChild.connect(childName => {
spaceChildrenModel.addPendingChild(childName);
});
dialog.open();
}
}
}