diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index d1683243f..8d6413958 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -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 diff --git a/src/app/qml/RoomPage.qml b/src/app/qml/RoomPage.qml index e82ee1ff5..166dd16cd 100644 --- a/src/app/qml/RoomPage.qml +++ b/src/app/qml/RoomPage.qml @@ -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 { diff --git a/src/libneochat/CMakeLists.txt b/src/libneochat/CMakeLists.txt index faac80c4f..0f4d462f4 100644 --- a/src/libneochat/CMakeLists.txt +++ b/src/libneochat/CMakeLists.txt @@ -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 diff --git a/src/app/qml/CreateRoomDialog.qml b/src/libneochat/qml/CreateRoomDialog.qml similarity index 100% rename from src/app/qml/CreateRoomDialog.qml rename to src/libneochat/qml/CreateRoomDialog.qml diff --git a/src/app/qml/CreateSpaceDialog.qml b/src/libneochat/qml/CreateSpaceDialog.qml similarity index 100% rename from src/app/qml/CreateSpaceDialog.qml rename to src/libneochat/qml/CreateSpaceDialog.qml diff --git a/src/app/qml/ExploreRoomsPage.qml b/src/libneochat/qml/ExploreRoomsPage.qml similarity index 100% rename from src/app/qml/ExploreRoomsPage.qml rename to src/libneochat/qml/ExploreRoomsPage.qml diff --git a/src/app/qml/InviteUserPage.qml b/src/libneochat/qml/InviteUserPage.qml similarity index 100% rename from src/app/qml/InviteUserPage.qml rename to src/libneochat/qml/InviteUserPage.qml diff --git a/src/spaces/CMakeLists.txt b/src/spaces/CMakeLists.txt index f83169485..db9f1133e 100644 --- a/src/spaces/CMakeLists.txt +++ b/src/spaces/CMakeLists.txt @@ -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 diff --git a/src/app/qml/RemoveChildDialog.qml b/src/spaces/RemoveChildDialog.qml similarity index 97% rename from src/app/qml/RemoveChildDialog.qml rename to src/spaces/RemoveChildDialog.qml index 7f50f29ab..2ccaeb9e4 100644 --- a/src/app/qml/RemoveChildDialog.qml +++ b/src/spaces/RemoveChildDialog.qml @@ -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 diff --git a/src/app/qml/SelectExistingRoomDialog.qml b/src/spaces/SelectExistingRoomDialog.qml similarity index 98% rename from src/app/qml/SelectExistingRoomDialog.qml rename to src/spaces/SelectExistingRoomDialog.qml index 74967a2c8..2bfba7382 100644 --- a/src/app/qml/SelectExistingRoomDialog.qml +++ b/src/spaces/SelectExistingRoomDialog.qml @@ -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") diff --git a/src/spaces/SpaceHierarchyDelegate.qml b/src/spaces/SpaceHierarchyDelegate.qml index f542b9679..9f418d9cb 100644 --- a/src/spaces/SpaceHierarchyDelegate.qml +++ b/src/spaces/SpaceHierarchyDelegate.qml @@ -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 diff --git a/src/spaces/SpaceHomePage.qml b/src/spaces/SpaceHomePage.qml index d6dc20a47..c7d90312a 100644 --- a/src/spaces/SpaceHomePage.qml +++ b/src/spaces/SpaceHomePage.qml @@ -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); }