Remove any dependencies on App from the spaces module.

Remove any dependencies on App from the spaces module. This requires moving some dialogs either to spaces, or libneochat if they're used more generically.
This commit is contained in:
James Graham
2025-05-18 14:38:57 +01:00
parent 2cb89807ef
commit 6ef7acc8e5
12 changed files with 46 additions and 36 deletions

View File

@@ -56,10 +56,8 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
qml/AccountMenu.qml qml/AccountMenu.qml
qml/CollapsedRoomDelegate.qml qml/CollapsedRoomDelegate.qml
qml/RoomPage.qml qml/RoomPage.qml
qml/ExploreRoomsPage.qml
qml/ManualRoomDialog.qml qml/ManualRoomDialog.qml
qml/ExplorerDelegate.qml qml/ExplorerDelegate.qml
qml/InviteUserPage.qml
qml/ImageEditorPage.qml qml/ImageEditorPage.qml
qml/NeochatMaximizeComponent.qml qml/NeochatMaximizeComponent.qml
qml/TypingPane.qml qml/TypingPane.qml
@@ -67,7 +65,6 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
qml/AttachmentPane.qml qml/AttachmentPane.qml
qml/QuickFormatBar.qml qml/QuickFormatBar.qml
qml/UserDetailDialog.qml qml/UserDetailDialog.qml
qml/CreateRoomDialog.qml
qml/OpenFileDialog.qml qml/OpenFileDialog.qml
qml/KeyVerificationDialog.qml qml/KeyVerificationDialog.qml
qml/ConfirmLogoutDialog.qml qml/ConfirmLogoutDialog.qml
@@ -83,7 +80,6 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
qml/OsmLocationPlugin.qml qml/OsmLocationPlugin.qml
qml/FullScreenMap.qml qml/FullScreenMap.qml
qml/ChooseRoomDialog.qml qml/ChooseRoomDialog.qml
qml/RemoveChildDialog.qml
qml/QrCodeMaximizeComponent.qml qml/QrCodeMaximizeComponent.qml
qml/NotificationsView.qml qml/NotificationsView.qml
qml/ServerComboBox.qml qml/ServerComboBox.qml
@@ -105,8 +101,6 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
qml/AvatarNotification.qml qml/AvatarNotification.qml
qml/ReasonDialog.qml qml/ReasonDialog.qml
qml/NewPollDialog.qml qml/NewPollDialog.qml
qml/CreateSpaceDialog.qml
qml/SelectExistingRoomDialog.qml
DEPENDENCIES DEPENDENCIES
QtCore QtCore
QtQuick QtQuick

View File

@@ -137,7 +137,11 @@ Kirigami.Page {
id: spaceLoader id: spaceLoader
active: root.currentRoom && root.currentRoom.isSpace active: root.currentRoom && root.currentRoom.isSpace
anchors.fill: parent anchors.fill: parent
sourceComponent: SpaceHomePage {} sourceComponent: SpaceHomePage {
room: root.currentRoom
onRequestLeaveRoom: room => RoomManager.leaveRoom(room);
}
} }
Loader { Loader {

View File

@@ -51,7 +51,11 @@ ecm_add_qml_module(LibNeoChat GENERATE_PLUGIN_SOURCE
QML_FILES QML_FILES
qml/GroupChatDrawerHeader.qml qml/GroupChatDrawerHeader.qml
qml/LocationMapItem.qml qml/LocationMapItem.qml
qml/InviteUserPage.qml
qml/ExploreRoomsPage.qml
qml/SearchPage.qml qml/SearchPage.qml
qml/CreateRoomDialog.qml
qml/CreateSpaceDialog.qml
) )
ecm_qt_declare_logging_category(LibNeoChat ecm_qt_declare_logging_category(LibNeoChat

View File

@@ -8,6 +8,8 @@ ecm_add_qml_module(Spaces GENERATE_PLUGIN_SOURCE
QML_FILES QML_FILES
SpaceHomePage.qml SpaceHomePage.qml
SpaceHierarchyDelegate.qml SpaceHierarchyDelegate.qml
RemoveChildDialog.qml
SelectExistingRoomDialog.qml
SOURCES SOURCES
models/spacechildrenmodel.cpp models/spacechildrenmodel.cpp
models/spacechildsortfiltermodel.cpp models/spacechildsortfiltermodel.cpp

View File

@@ -7,7 +7,7 @@ import QtQuick.Layouts
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.neochat import org.kde.neochat.libneochat
Kirigami.Dialog { Kirigami.Dialog {
id: root id: root

View File

@@ -9,7 +9,7 @@ import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.kirigamiaddons.labs.components as Components import org.kde.kirigamiaddons.labs.components as Components
import org.kde.neochat import org.kde.neochat.libneochat
Kirigami.Dialog { Kirigami.Dialog {
id: root id: root
@@ -38,7 +38,7 @@ Kirigami.Dialog {
visible: !chosenRoomDelegate.visible visible: !chosenRoomDelegate.visible
text: i18nc("@action:button", "Pick Room") text: i18nc("@action:button", "Pick Room")
onClicked: { onClicked: {
let dialog = pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ExploreRoomsPage'), { let dialog = pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.libneochat', 'ExploreRoomsPage'), {
connection: root.connection connection: root.connection
}, { }, {
title: i18nc("@title", "Explore Rooms") title: i18nc("@title", "Explore Rooms")

View File

@@ -9,8 +9,7 @@ import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.delegates as Delegates import org.kde.kirigamiaddons.delegates as Delegates
import org.kde.kirigamiaddons.labs.components as Components import org.kde.kirigamiaddons.labs.components as Components
import org.kde.neochat import org.kde.neochat.libneochat
import org.kde.neochat.libneochat as LibNeoChat
Item { Item {
id: root id: root
@@ -202,7 +201,7 @@ Item {
} }
} }
LibNeoChat.DelegateSizeHelper { DelegateSizeHelper {
id: sizeHelper id: sizeHelper
parentItem: root parentItem: root
startBreakpoint: Kirigami.Units.gridUnit * 46 startBreakpoint: Kirigami.Units.gridUnit * 46

View File

@@ -8,14 +8,21 @@ import QtQuick.Layouts
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.components as KirigamiComponents import org.kde.kirigamiaddons.components as KirigamiComponents
import org.kde.neochat import org.kde.neochat.libneochat
import org.kde.neochat.libneochat as LibNeoChat import org.kde.neochat.settings as Settings
import org.kde.neochat.settings
ColumnLayout { ColumnLayout {
id: root id: root
readonly property NeoChatRoom currentRoom: RoomManager.currentRoom /**
* @brief The NeoChatRoom the delegate is being displayed in.
*/
required property NeoChatRoom room
/**
* @brief Request to leave the given room.
*/
signal requestLeaveRoom(NeoChatRoom room)
anchors.fill: parent anchors.fill: parent
@@ -28,19 +35,19 @@ ColumnLayout {
Kirigami.Action { Kirigami.Action {
icon.name: "list-add-symbolic" icon.name: "list-add-symbolic"
text: i18nc("@action:inmenu", "New Room…") text: i18nc("@action:inmenu", "New Room…")
onTriggered: _private.createRoom(root.currentRoom.id) onTriggered: _private.createRoom(root.room.id)
} }
Kirigami.Action { Kirigami.Action {
icon.name: "list-add-symbolic" icon.name: "list-add-symbolic"
text: i18nc("@action:inmenu", "New Space…") text: i18nc("@action:inmenu", "New Space…")
onTriggered: _private.createSpace(root.currentRoom.id) onTriggered: _private.createSpace(root.room.id)
} }
Kirigami.Action { Kirigami.Action {
icon.name: "search-symbolic" icon.name: "search-symbolic"
text: i18nc("@action:inmenu", "Existing Room…") text: i18nc("@action:inmenu", "Existing Room…")
onTriggered: _private.selectExisting(root.currentRoom.id) onTriggered: _private.selectExisting(root.room.id)
} }
} }
} }
@@ -65,18 +72,18 @@ ColumnLayout {
GroupChatDrawerHeader { GroupChatDrawerHeader {
id: header id: header
Layout.fillWidth: true Layout.fillWidth: true
room: root.currentRoom room: root.room
} }
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing Layout.rightMargin: Kirigami.Units.largeSpacing
QQC2.Button { QQC2.Button {
visible: root.currentRoom.canSendState("invite") visible: root.room.canSendState("invite")
text: i18nc("@button", "Invite user to space") text: i18nc("@button", "Invite user to space")
icon.name: "list-add-user" icon.name: "list-add-user"
onClicked: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'InviteUserPage'), { onClicked: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.libneochat', 'InviteUserPage'), {
room: root.currentRoom room: root.room
}, { }, {
title: i18nc("@title", "Invite a User") title: i18nc("@title", "Invite a User")
}) })
@@ -84,7 +91,7 @@ ColumnLayout {
QQC2.Button { QQC2.Button {
id: addNewButton id: addNewButton
visible: root.currentRoom.canSendState("m.space.child") visible: root.room.canSendState("m.space.child")
text: i18nc("@button", "Add to Space") text: i18nc("@button", "Add to Space")
icon.name: "list-add" icon.name: "list-add"
onClicked: { onClicked: {
@@ -95,7 +102,7 @@ ColumnLayout {
QQC2.Button { QQC2.Button {
text: i18nc("@action:button", "Leave this space") text: i18nc("@action:button", "Leave this space")
icon.name: "go-previous" icon.name: "go-previous"
onClicked: RoomManager.leaveRoom(root.currentRoom) onClicked: root.requestLeaveRoom(root.room)
} }
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
@@ -106,7 +113,7 @@ ColumnLayout {
display: QQC2.AbstractButton.IconOnly display: QQC2.AbstractButton.IconOnly
text: i18nc("'Space' is a matrix space", "Space Settings") text: i18nc("'Space' is a matrix space", "Space Settings")
onClicked: { onClicked: {
RoomSettingsView.openRoomSettings(root.currentRoom, RoomSettingsView.Space); Settings.RoomSettingsView.openRoomSettings(root.room, Settings.RoomSettingsView.Space);
drawer.close(); drawer.close();
} }
icon.name: 'settings-configure-symbolic' icon.name: 'settings-configure-symbolic'
@@ -124,7 +131,7 @@ ColumnLayout {
onTextChanged: spaceChildSortFilterModel.filterText = text onTextChanged: spaceChildSortFilterModel.filterText = text
} }
} }
LibNeoChat.DelegateSizeHelper { DelegateSizeHelper {
id: sizeHelper id: sizeHelper
parentItem: root parentItem: root
startBreakpoint: Kirigami.Units.gridUnit * 46 startBreakpoint: Kirigami.Units.gridUnit * 46
@@ -155,7 +162,7 @@ ColumnLayout {
id: spaceChildSortFilterModel id: spaceChildSortFilterModel
sourceModel: SpaceChildrenModel { sourceModel: SpaceChildrenModel {
id: spaceChildrenModel id: spaceChildrenModel
space: root.currentRoom space: root.room
} }
} }
@@ -190,8 +197,8 @@ ColumnLayout {
id: _private id: _private
function createRoom(parentId) { function createRoom(parentId) {
const dialog = Qt.createComponent('org.kde.neochat', 'CreateRoomDialog').createObject(root, { const dialog = Qt.createComponent('org.kde.neochat.libneochat', 'CreateRoomDialog').createObject(root, {
connection: root.currentRoom.connection, connection: root.room.connection,
parentId: parentId parentId: parentId
}); });
dialog.newChild.connect(childName => { dialog.newChild.connect(childName => {
@@ -201,8 +208,8 @@ ColumnLayout {
} }
function createSpace(parentId) { function createSpace(parentId) {
const dialog = Qt.createComponent('org.kde.neochat', 'CreateSpaceDialog').createObject(root, { const dialog = Qt.createComponent('org.kde.neochat.libneochat', 'CreateSpaceDialog').createObject(root, {
connection: root.currentRoom.connection, connection: root.room.connection,
parentId: parentId, parentId: parentId,
}); });
dialog.newChild.connect(childName => { dialog.newChild.connect(childName => {
@@ -212,14 +219,14 @@ ColumnLayout {
} }
function selectExisting(parentId) { function selectExisting(parentId) {
const dialog = Qt.createComponent('org.kde.neochat', 'SelectExistingRoomDialog').createObject(root, { const dialog = Qt.createComponent('org.kde.neochat.spaces', 'SelectExistingRoomDialog').createObject(root, {
connection: root.currentRoom.connection, connection: root.room.connection,
parentId: parentId, parentId: parentId,
}); });
dialog.addChild.connect((childId, setChildParent, canonical) => { dialog.addChild.connect((childId, setChildParent, canonical) => {
// We have to get a room object from the connection as we may not // We have to get a room object from the connection as we may not
// be adding to the top level parent. // be adding to the top level parent.
let parent = root.currentRoom.connection.room(parentId); let parent = root.room.connection.room(parentId);
if (parent) { if (parent) {
parent.addChild(childId, setChildParent, canonical); parent.addChild(childId, setChildParent, canonical);
} }