Remove Space Child

Add button to remove a child in a space if the user has the correct power levels
This commit is contained in:
James Graham
2023-09-29 20:15:17 +00:00
parent 925393deab
commit eba62103a4
7 changed files with 157 additions and 3 deletions

View File

@@ -0,0 +1,53 @@
// 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.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
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: FormCard.FormCardPage {
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
FormCard.FormTextDelegate {
text: i18n("The child ") + root.displayName + i18n(" will be removed from the space ") + 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
}
}
}
}

View File

@@ -26,6 +26,11 @@ Item {
required property string topic
required property bool isJoined
required property bool canAddChildren
required property string parentDisplayName
required property bool canSetParent
required property bool isDeclaredParent
required property bool canRemove
required property NeoChatRoom parentRoom
signal createRoom()
signal enterRoom()
@@ -95,8 +100,29 @@ Item {
visible: root.isSpace && root.canAddChildren
text: i18nc("@button", "Add new child")
icon.name: "list-add"
display: QQC2.AbstractButton.IconOnly
onClicked: root.createRoom()
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
QQC2.ToolButton {
visible: root.canRemove
text: i18nc("@button", "Remove")
icon.name: "list-remove"
display: QQC2.AbstractButton.IconOnly
onClicked: {
removeChildDialog.createObject(QQC2.ApplicationWindow.overlay, {
parentRoom: root.parentRoom,
roomId: root.roomId,
displayName: root.displayName,
parentDisplayName: root.parentDisplayName,
canSetParent: root.canSetParent,
isDeclaredParent: root.isDeclaredParent
}).open();
}
QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
@@ -128,4 +154,9 @@ Item {
parentWidth: root.treeView ? root.treeView.width : 0
}
Component {
id: removeChildDialog
RemoveChildDialog {}
}
}