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:
@@ -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
|
||||
|
||||
49
src/spaces/RemoveChildDialog.qml
Normal file
49
src/spaces/RemoveChildDialog.qml
Normal file
@@ -0,0 +1,49 @@
|
||||
// SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
|
||||
import org.kde.neochat.libneochat
|
||||
|
||||
Kirigami.Dialog {
|
||||
id: root
|
||||
|
||||
required property NeoChatRoom parentRoom
|
||||
|
||||
required property string roomId
|
||||
|
||||
required property string displayName
|
||||
|
||||
required property string parentDisplayName
|
||||
|
||||
required property bool canSetParent
|
||||
|
||||
required property bool isDeclaredParent
|
||||
|
||||
title: i18nc("@title", "Remove Child")
|
||||
|
||||
width: Math.min(applicationWindow().width, Kirigami.Units.gridUnit * 24)
|
||||
|
||||
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
|
||||
|
||||
onAccepted: parentRoom.removeChild(root.roomId, removeOfficalCheck.checked)
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
spacing: 0
|
||||
FormCard.FormTextDelegate {
|
||||
text: i18n("The child %1 will be removed from the space %2", root.displayName, root.parentDisplayName)
|
||||
textItem.wrapMode: Text.Wrap
|
||||
}
|
||||
FormCard.FormCheckDelegate {
|
||||
id: removeOfficalCheck
|
||||
visible: root.isDeclaredParent
|
||||
enabled: root.canSetParent
|
||||
text: i18n("The current space is the official parent of this room, should this be cleared?")
|
||||
checked: root.canSetParent
|
||||
}
|
||||
}
|
||||
}
|
||||
180
src/spaces/SelectExistingRoomDialog.qml
Normal file
180
src/spaces/SelectExistingRoomDialog.qml
Normal file
@@ -0,0 +1,180 @@
|
||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-or-later OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
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.libneochat
|
||||
|
||||
Kirigami.Dialog {
|
||||
id: root
|
||||
|
||||
property string parentId
|
||||
|
||||
required property NeoChatConnection connection
|
||||
|
||||
signal addChild(string childId, bool setChildParent, bool canonical)
|
||||
signal newChild(string childName)
|
||||
|
||||
title: i18nc("@title", "Select Existing Room")
|
||||
implicitWidth: Kirigami.Units.gridUnit * 20
|
||||
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
|
||||
|
||||
onAccepted: root.addChild(chosenRoomDelegate.roomId, existingOfficialCheck.checked, makeCanonicalCheck.checked);
|
||||
|
||||
Component.onCompleted: pickRoomDelegate.forceActiveFocus()
|
||||
|
||||
ColumnLayout {
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
id: pickRoomDelegate
|
||||
|
||||
visible: !chosenRoomDelegate.visible
|
||||
text: i18nc("@action:button", "Pick Room")
|
||||
onClicked: {
|
||||
let dialog = pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.libneochat', 'ExploreRoomsPage'), {
|
||||
connection: root.connection
|
||||
}, {
|
||||
title: i18nc("@title", "Explore Rooms")
|
||||
});
|
||||
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||
chosenRoomDelegate.roomId = roomId;
|
||||
chosenRoomDelegate.displayName = displayName;
|
||||
chosenRoomDelegate.avatarUrl = avatarUrl;
|
||||
chosenRoomDelegate.alias = alias;
|
||||
chosenRoomDelegate.topic = topic;
|
||||
chosenRoomDelegate.memberCount = memberCount;
|
||||
chosenRoomDelegate.isJoined = isJoined;
|
||||
chosenRoomDelegate.visible = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
FormCard.AbstractFormDelegate {
|
||||
id: chosenRoomDelegate
|
||||
property string roomId
|
||||
property string displayName
|
||||
property url avatarUrl
|
||||
property string alias
|
||||
property string topic
|
||||
property int memberCount
|
||||
property bool isJoined
|
||||
|
||||
visible: false
|
||||
|
||||
contentItem: RowLayout {
|
||||
Components.Avatar {
|
||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
|
||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
||||
|
||||
source: chosenRoomDelegate.avatarUrl
|
||||
name: chosenRoomDelegate.displayName
|
||||
}
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Kirigami.Heading {
|
||||
Layout.fillWidth: true
|
||||
level: 4
|
||||
text: chosenRoomDelegate.displayName
|
||||
font.bold: true
|
||||
textFormat: Text.PlainText
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
QQC2.Label {
|
||||
visible: chosenRoomDelegate.isJoined
|
||||
text: i18n("Joined")
|
||||
color: Kirigami.Theme.linkColor
|
||||
}
|
||||
}
|
||||
QQC2.Label {
|
||||
Layout.fillWidth: true
|
||||
visible: text
|
||||
text: chosenRoomDelegate.topic ? chosenRoomDelegate.topic.replace(/(\r\n\t|\n|\r\t)/gm, " ") : ""
|
||||
textFormat: Text.PlainText
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Kirigami.Icon {
|
||||
source: "user"
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
implicitHeight: Kirigami.Units.iconSizes.small
|
||||
implicitWidth: Kirigami.Units.iconSizes.small
|
||||
}
|
||||
QQC2.Label {
|
||||
text: chosenRoomDelegate.memberCount + " " + (chosenRoomDelegate.alias ?? chosenRoomDelegate.roomId)
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
elide: Text.ElideRight
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
let dialog = pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ExploreRoomsPage'), {
|
||||
connection: root.connection
|
||||
}, {
|
||||
title: i18nc("@title", "Explore Rooms")
|
||||
});
|
||||
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||
chosenRoomDelegate.roomId = roomId;
|
||||
chosenRoomDelegate.displayName = displayName;
|
||||
chosenRoomDelegate.avatarUrl = avatarUrl;
|
||||
chosenRoomDelegate.alias = alias;
|
||||
chosenRoomDelegate.topic = topic;
|
||||
chosenRoomDelegate.memberCount = memberCount;
|
||||
chosenRoomDelegate.isJoined = isJoined;
|
||||
chosenRoomDelegate.visible = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormDelegateSeparator {
|
||||
below: existingOfficialCheck
|
||||
}
|
||||
|
||||
FormCard.FormCheckDelegate {
|
||||
id: existingOfficialCheck
|
||||
visible: root.parentId.length > 0
|
||||
text: i18nc("@option:check As in make the space from which this dialog was created an official parent.", "Make this parent official")
|
||||
description: enabled ? i18nc("@info:description", "You have the required privilege level in the child to set this state") : i18n("You do not have a high enough privilege level in the child to set this state")
|
||||
checked: enabled
|
||||
|
||||
enabled: {
|
||||
if (chosenRoomDelegate.visible) {
|
||||
let room = root.connection.room(chosenRoomDelegate.roomId);
|
||||
if (room) {
|
||||
if (room.canSendState("m.space.parent")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormDelegateSeparator {
|
||||
above: existingOfficialCheck
|
||||
below: makeCanonicalCheck
|
||||
}
|
||||
|
||||
FormCard.FormCheckDelegate {
|
||||
id: makeCanonicalCheck
|
||||
text: i18nc("@option:check The canonical parent is the default one if a room has multiple parent spaces.", "Make this space the canonical parent")
|
||||
description: i18nc("@info:description", "The canonical parent is the default one if a room has multiple parent spaces.")
|
||||
checked: enabled
|
||||
|
||||
enabled: existingOfficialCheck.enabled
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user