Devtools: Implement changing room state

This commit is contained in:
Tobias Fella
2024-03-03 00:19:19 +01:00
parent d2695947ed
commit c344a3ee55
13 changed files with 236 additions and 33 deletions

View File

@@ -13,15 +13,51 @@ import org.kde.neochat
Kirigami.Page {
id: root
property string sourceText
property var model
property NeoChatRoom room
property string type
property string stateKey
property bool allowEdit: false
property string contentJson: model.stateEventContentJson(root.type, root.stateKey)
property string sourceText: model.stateEventJson(root.type, root.stateKey)
topPadding: 0
leftPadding: 0
rightPadding: 0
bottomPadding: 0
Connections {
enabled: root.model
target: root.room
function onChanged(): void {
root.contentJson = model.stateEventContentJson(root.type, root.stateKey);
root.sourceText = model.stateEventJson(root.type, root.stateKey);
}
}
title: i18n("Event Source")
actions: [
Kirigami.Action {
text: i18nc("@action As in 'edit the state of this rooms'", "Edit state")
icon.name: "document-edit"
visible: root.allowEdit
enabled: room.canSendState(root.type) && (!root.stateKey.startsWith("@") || root.stateKey === root.room.connection.localUserId) && root.type !== "m.room.create"
onTriggered: pageStack.pushDialogLayer(Qt.createComponent("org.kde.neochat", "EditStateDialog.qml"), {
room: root.room,
type: root.type,
stateKey: root.stateKey,
sourceText: root.contentJson,
}, {
title: i18nc("@title As in 'edit the state of this rooms'", "Edit State")
})
}
]
QQC2.ScrollView {
id: scrollView
anchors.fill: parent