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

View File

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

View File

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

View File

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

View File

@@ -7,7 +7,7 @@ import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.neochat
import org.kde.neochat.libneochat
Kirigami.Dialog {
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.labs.components as Components
import org.kde.neochat
import org.kde.neochat.libneochat
Kirigami.Dialog {
id: root
@@ -38,7 +38,7 @@ Kirigami.Dialog {
visible: !chosenRoomDelegate.visible
text: i18nc("@action:button", "Pick Room")
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
}, {
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.labs.components as Components
import org.kde.neochat
import org.kde.neochat.libneochat as LibNeoChat
import org.kde.neochat.libneochat
Item {
id: root
@@ -202,7 +201,7 @@ Item {
}
}
LibNeoChat.DelegateSizeHelper {
DelegateSizeHelper {
id: sizeHelper
parentItem: root
startBreakpoint: Kirigami.Units.gridUnit * 46

View File

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