Devtools: Split state keys into a separate list

This commit is contained in:
Tobias Fella
2024-02-21 22:31:35 +01:00
parent bc67033c00
commit 628de56087
7 changed files with 274 additions and 57 deletions

View File

@@ -36,38 +36,20 @@ ColumnLayout {
FormCard.FormTextDelegate {
text: i18n("Room Id: %1", root.room.id)
}
FormCard.FormCheckDelegate {
text: i18n("Show m.room.member events")
checked: true
onToggled: {
if (checked) {
stateEventFilterModel.removeStateEventTypeFiltered("m.room.member");
} else {
stateEventFilterModel.addStateEventTypeFiltered("m.room.member");
}
}
}
FormCard.FormCheckDelegate {
id: roomAccountDataVisibleCheck
text: i18n("Show room account data")
checked: false
}
}
FormCard.FormHeader {
visible: roomAccountDataVisibleCheck.checked
title: i18n("Room Account Data")
}
FormCard.FormCard {
visible: roomAccountDataVisibleCheck.checked
Repeater {
model: root.room.accountDataEventTypes
delegate: FormCard.FormButtonDelegate {
text: modelData
onClicked: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'MessageSourceSheet.qml'), {
"sourceText": root.room.roomAcountDataJson(text)
sourceText: root.room.roomAcountDataJson(text)
}, {
"title": i18n("Event Source"),
"width": Kirigami.Units.gridUnit * 25
title: i18n("Event Source"),
width: Kirigami.Units.gridUnit * 25
})
}
}
@@ -78,24 +60,36 @@ ColumnLayout {
}
FormCard.FormCard {
Repeater {
model: StateFilterModel {
id: stateEventFilterModel
sourceModel: StateModel {
id: stateModel
room: root.room
}
model: StateModel {
id: stateModel
room: root.room
}
delegate: FormCard.FormButtonDelegate {
text: model.type
description: model.stateKey
onClicked: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'MessageSourceSheet.qml'), {
sourceText: stateModel.stateEventJson(stateEventFilterModel.mapToSource(stateEventFilterModel.index(model.index, 0)))
}, {
title: i18n("Event Source"),
width: Kirigami.Units.gridUnit * 25
})
description: i18ncp("'Event' being some JSON data, not something physically happening.", "%1 event of this type", "%1 events of this type", model.eventCount)
onClicked: {
if (model.eventCount === 1) {
onClicked: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'MessageSourceSheet.qml'), {
sourceText: stateModel.stateEventJson(stateModel.index(model.index, 0))
}, {
title: i18n("Event Source"),
width: Kirigami.Units.gridUnit * 25
})
} else {
pageStack.pushDialogLayer(stateKeysComponent, {
room: root.room,
eventType: model.type
}, {
title: i18nc("'Event' being some JSON data, not something physically happening.", "Event Information")
});
}
}
}
}
Component {
id: stateKeysComponent
StateKeys {}
}
}
}

43
src/qml/StateKeys.qml Normal file
View File

@@ -0,0 +1,43 @@
// SPDX-FileCopyrightText: 2024 Tobias Fella <tobias.fella@kde.org>
// 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.kitemmodels
import org.kde.neochat
FormCard.FormCardPage {
id: root
required property NeoChatRoom room
required property string eventType
title: root.eventType
FormCard.FormHeader {
title: i18nc("The name of one instance of a state of configuration. Unless you really know what you're doing, best leave this untranslated.", "State Keys")
}
FormCard.FormCard {
Repeater {
model: StateKeysModel {
id: stateKeysModel
room: root.room
eventType: root.eventType
}
delegate: FormCard.FormButtonDelegate {
text: model.stateKey
onClicked: applicationWindow().pageStack.pushDialogLayer('qrc:/org/kde/neochat/qml/MessageSourceSheet.qml', {
sourceText: stateKeysModel.stateEventJson(stateKeysModel.index(model.index, 0))
}, {
title: i18nc("@title:window", "Event Source"),
width: Kirigami.Units.gridUnit * 25
})
}
}
}
}