Port devtools to FormCard

This commit is contained in:
Tobias Fella
2023-09-01 16:44:50 +02:00
parent be71a4349b
commit a3b40a5e6d
3 changed files with 108 additions and 134 deletions

View File

@@ -6,28 +6,37 @@ import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.15 as Kirigami import org.kde.kirigami 2.15 as Kirigami
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm import org.kde.kirigamiaddons.formcard 1.0 as FormCard
import org.kde.kitemmodels 1.0 import org.kde.kitemmodels 1.0
import org.kde.neochat 1.0 import org.kde.neochat 1.0
ColumnLayout { ColumnLayout {
MobileForm.FormCard { id: root
Layout.fillWidth: true
contentItem: ColumnLayout { required property NeoChatRoom room
spacing: 0
MobileForm.FormComboBoxDelegate { FormCard.FormHeader {
title: i18nc("@title", "Choose Room")
}
FormCard.FormCard {
FormCard.FormComboBoxDelegate {
id: roomComboBox
text: i18n("Room") text: i18n("Room")
textRole: "displayName" textRole: "displayName"
valueRole: "id" valueRole: "roomId"
model: RoomListModel { model: RoomListModel {
id: roomListModel id: roomListModel
connection: Controller.activeConnection connection: Controller.activeConnection
} }
Component.onCompleted: currentIndex = indexOfValue(room.id) currentIndex: -1
onCurrentValueChanged: room = roomListModel.roomByAliasOrId(currentValue) Component.onCompleted: currentIndex = roomListModel.rowForRoom(root.room)
onCurrentValueChanged: root.room = roomListModel.roomByAliasOrId(roomComboBox.currentValue)
} }
MobileForm.FormCheckDelegate { FormCard.FormTextDelegate {
text: i18n("Room Id: %1", root.room.id)
}
FormCard.FormCheckDelegate {
text: i18n("Show m.room.member events") text: i18n("Show m.room.member events")
checked: true checked: true
onToggled: { onToggled: {
@@ -38,28 +47,24 @@ ColumnLayout {
} }
} }
} }
MobileForm.FormCheckDelegate { FormCard.FormCheckDelegate {
id: roomAccoutnDataVisibleCheck id: roomAccountDataVisibleCheck
text: i18n("Show room account data") text: i18n("Show room account data")
checked: false checked: false
} }
} }
FormCard.FormHeader {
visible: roomAccountDataVisibleCheck.checked
title: i18n("Room Account Data")
} }
MobileForm.FormCard { FormCard.FormCard {
Layout.fillWidth: true visible: roomAccountDataVisibleCheck.checked
visible: roomAccoutnDataVisibleCheck.checked
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCardHeader {
title: i18n("Room Account Data for %1 - %2", room.displayName, room.id)
}
Repeater { Repeater {
model: room.accountDataEventTypes model: root.room.accountDataEventTypes
delegate: MobileForm.FormTextDelegate { delegate: FormCard.FormButtonDelegate {
text: modelData text: modelData
onClicked: applicationWindow().pageStack.pushDialogLayer("qrc:/MessageSourceSheet.qml", { onClicked: applicationWindow().pageStack.pushDialogLayer("qrc:/MessageSourceSheet.qml", {
"sourceText": room.roomAcountDataJson(text) "sourceText": root.room.roomAcountDataJson(text)
}, { }, {
"title": i18n("Event Source"), "title": i18n("Event Source"),
"width": Kirigami.Units.gridUnit * 25 "width": Kirigami.Units.gridUnit * 25
@@ -67,37 +72,21 @@ ColumnLayout {
} }
} }
} }
} FormCard.FormHeader {
MobileForm.FormCard {
Layout.fillWidth: true
Layout.fillHeight: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCardHeader {
id: stateEventListHeader id: stateEventListHeader
title: i18n("Room State for %1", room.displayName) title: i18n("Room State")
subtitle: room.id
} }
QQC2.ScrollView { FormCard.FormCard {
Layout.fillWidth: true Repeater {
Layout.fillHeight: true
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
ListView {
id: stateEventListView
clip: true
model: StateFilterModel { model: StateFilterModel {
id: stateEventFilterModel id: stateEventFilterModel
sourceModel: StateModel { sourceModel: StateModel {
id: stateModel id: stateModel
room: devtoolsPage.room room: root.room
} }
} }
delegate: MobileForm.FormTextDelegate { delegate: FormCard.FormButtonDelegate {
text: model.type text: model.type
description: model.stateKey description: model.stateKey
onClicked: applicationWindow().pageStack.pushDialogLayer('qrc:/MessageSourceSheet.qml', { onClicked: applicationWindow().pageStack.pushDialogLayer('qrc:/MessageSourceSheet.qml', {
@@ -109,6 +98,4 @@ ColumnLayout {
} }
} }
} }
}
}
} }

View File

@@ -6,48 +6,37 @@ import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.15 as Kirigami import org.kde.kirigami 2.15 as Kirigami
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm import org.kde.kirigamiaddons.formcard 1.0 as FormCard
import org.kde.kitemmodels 1.0 import org.kde.kitemmodels 1.0
import org.kde.neochat 1.0 import org.kde.neochat 1.0
ColumnLayout { ColumnLayout {
MobileForm.FormCard { FormCard.FormHeader {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCardHeader {
title: i18n("Server Capabilities") title: i18n("Server Capabilities")
} }
MobileForm.FormTextDelegate { FormCard.FormCard {
FormCard.FormTextDelegate {
text: i18n("Can change password") text: i18n("Can change password")
description: Controller.activeConnection.canChangePassword description: Controller.activeConnection.canChangePassword
} }
} }
} FormCard.FormHeader {
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCardHeader {
title: i18n("Default Room Version") title: i18n("Default Room Version")
} }
MobileForm.FormTextDelegate { FormCard.FormCard {
FormCard.FormTextDelegate {
text: Controller.activeConnection.defaultRoomVersion text: Controller.activeConnection.defaultRoomVersion
} }
} }
} FormCard.FormHeader {
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCardHeader {
title: i18n("Available Room Versions") title: i18n("Available Room Versions")
} }
FormCard.FormCard {
Repeater { Repeater {
model: Controller.getSupportedRoomVersions(room.connection) model: room.connection.getSupportedRoomVersions()
delegate: MobileForm.FormTextDelegate { delegate: FormCard.FormTextDelegate {
text: modelData.id text: modelData.id
contentItem.children: QQC2.Label { contentItem.children: QQC2.Label {
text: modelData.status text: modelData.status
@@ -56,8 +45,4 @@ ColumnLayout {
} }
} }
} }
}
Item {
Layout.fillHeight: true
}
} }

View File

@@ -6,11 +6,12 @@ import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.20 as Kirigami import org.kde.kirigami 2.20 as Kirigami
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
import org.kde.neochat 1.0 import org.kde.neochat 1.0
Kirigami.Page { FormCard.FormCardPage {
id: devtoolsPage id: root
property NeoChatRoom room property NeoChatRoom room
@@ -32,11 +33,12 @@ Kirigami.Page {
StackLayout { StackLayout {
id: swipeView id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex currentIndex: tabBar.currentIndex
RoomData {} RoomData {
room: root.room
}
ServerData {} ServerData {}
} }
} }