Canonical Parent

So the original space parent and child stuff was technically a bit naughty in that it allowed multiple rooms to be set as the canonical parent. Because while a room can have multiple parents only one should be canonical. This adds the following:
- When adding a child or parent there is an extra check to select if the new parent should be canonical
- Any parent can be selected as the canonical one from the room settings
- All functions ensure that there is only ever one canonical parent by ensuring all others are false when a new one is set.
This commit is contained in:
James Graham
2023-10-13 12:00:47 +00:00
parent fe70e2773f
commit e480299563
5 changed files with 137 additions and 31 deletions

View File

@@ -309,18 +309,38 @@ FormCard.FormCardPage {
}
}
contentItem.children: QQC2.ToolButton {
visible: officalParentDelegate?.space.canSendState("m.space.child") && root.room.canSendState("m.space.parent")
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
id: removeParentAction
text: i18n("Remove parent")
icon.name: "edit-delete-remove"
onTriggered: root.room.removeParent(officalParentDelegate.modelData)
contentItem.children: RowLayout {
QQC2.Label {
visible: root.room.canonicalParent === officalParentDelegate.modelData
text: i18n("Canonical")
}
QQC2.ToolTip {
text: removeParentAction.text
delay: Kirigami.Units.toolTipDelay
QQC2.ToolButton {
visible: root.room.canSendState("m.space.parent") && root.room.canonicalParent !== officalParentDelegate.modelData
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
id: canonicalParentAction
text: i18n("Make canonical parent")
icon.name: "checkmark"
onTriggered: root.room.canonicalParent = officalParentDelegate.modelData
}
QQC2.ToolTip {
text: canonicalParentAction.text
delay: Kirigami.Units.toolTipDelay
}
}
QQC2.ToolButton {
visible: officalParentDelegate?.space.canSendState("m.space.child") && root.room.canSendState("m.space.parent")
display: QQC2.AbstractButton.IconOnly
action: Kirigami.Action {
id: removeParentAction
text: i18n("Remove parent")
icon.name: "edit-delete-remove"
onTriggered: root.room.removeParent(officalParentDelegate.modelData)
}
QQC2.ToolTip {
text: removeParentAction.text
delay: Kirigami.Units.toolTipDelay
}
}
}
}
@@ -445,11 +465,18 @@ FormCard.FormCardPage {
text: existingOfficialCheck.space ? (existingOfficialCheck.space.isSpace ? i18n("You do not have a high enough privilege level in the parent to set this state") : i18n("The selected room is not a space")) : i18n("You do not have the privileges to complete this action")
textItem.color: Kirigami.Theme.negativeTextColor
}
FormCard.FormCheckDelegate {
id: makeCanonicalCheck
text: i18n("Make this space the canonical parent")
checked: enabled
enabled: chosenRoomDelegate.visible
}
FormCard.FormButtonDelegate {
text: i18nc("@action:button", "Ok")
enabled: chosenRoomDelegate.visible && root.room.canModifyParent(chosenRoomDelegate.roomId)
onClicked: {
root.room.addParent(chosenRoomDelegate.roomId)
root.room.addParent(chosenRoomDelegate.roomId, makeCanonicalCheck.checked, existingOfficialCheck.checked)
}
}
}