Port remaining room settings to FormCard

This commit is contained in:
Tobias Fella
2023-09-02 11:42:38 +00:00
parent 43ecd188f1
commit 48f7e06c01
3 changed files with 746 additions and 818 deletions

View File

@@ -8,33 +8,24 @@ import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
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.kirigamiaddons.labs.components 1.0 as KirigamiComponents
import org.kde.neochat 1.0
Kirigami.ScrollablePage {
FormCard.FormCardPage {
id: root
property NeoChatRoom room
title: i18n("General")
topPadding: 0
leftPadding: 0
rightPadding: 0
ColumnLayout {
spacing: 0
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
title: i18n("Room Information")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.AbstractFormDelegate {
Layout.fillWidth: true
background: Item {}
FormCard.FormCard {
FormCard.AbstractFormDelegate {
background: null
contentItem: RowLayout {
Item {
Layout.fillWidth: true
@@ -75,15 +66,14 @@ Kirigami.ScrollablePage {
}
}
}
MobileForm.FormTextFieldDelegate {
FormCard.FormTextFieldDelegate {
id: roomNameField
label: i18n("Room name:")
text: room.name
enabled: room.canSendState("m.room.name")
}
MobileForm.AbstractFormDelegate {
FormCard.AbstractFormDelegate {
id: roomTopicField
Layout.fillWidth: true
enabled: room.canSendState("m.room.topic")
background: Item {}
contentItem: ColumnLayout {
@@ -100,8 +90,7 @@ Kirigami.ScrollablePage {
}
}
}
MobileForm.AbstractFormDelegate {
Layout.fillWidth: true
FormCard.AbstractFormDelegate {
background: Item {}
contentItem: RowLayout {
Item {
@@ -124,7 +113,7 @@ Kirigami.ScrollablePage {
}
}
}
MobileForm.FormTextDelegate {
FormCard.FormTextDelegate {
id: roomIdDelegate
text: i18n("Room ID")
description: room.id
@@ -144,7 +133,7 @@ Kirigami.ScrollablePage {
QQC2.ToolTip.visible: hovered
}
}
MobileForm.FormTextDelegate {
FormCard.FormTextDelegate {
text: i18n("Room version")
description: room.version
@@ -168,17 +157,12 @@ Kirigami.ScrollablePage {
}
}
}
}
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
title: i18n("Aliases")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormTextDelegate {
FormCard.FormCard {
FormCard.FormTextDelegate {
visible: room.aliases.length <= 0
text: i18n("No canonical alias set")
}
@@ -186,7 +170,7 @@ Kirigami.ScrollablePage {
id: altAliasRepeater
model: room.aliases.slice().reverse()
delegate: MobileForm.FormTextDelegate {
delegate: FormCard.FormTextDelegate {
text: modelData
description: room.canonicalAlias.length > 0 && modelData === room.canonicalAlias ? "Canonical alias" : ""
contentItem.children: [
@@ -224,8 +208,7 @@ Kirigami.ScrollablePage {
}
}
MobileForm.AbstractFormDelegate {
Layout.fillWidth: true
FormCard.AbstractFormDelegate {
visible: room.canSendState("m.room.canonical_alias")
contentItem : RowLayout {
@@ -268,17 +251,12 @@ Kirigami.ScrollablePage {
}
}
}
}
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
title: i18n("URL Previews")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCheckDelegate {
FormCard.FormCard {
FormCard.FormCheckDelegate {
text: i18n("Enable URL previews by default for room members")
checked: room.defaultUrlPreviewState
visible: room.canSendState("org.matrix.room.preview_urls")
@@ -286,7 +264,7 @@ Kirigami.ScrollablePage {
room.defaultUrlPreviewState = checked
}
}
MobileForm.FormCheckDelegate {
FormCard.FormCheckDelegate {
text: i18n("Enable URL previews")
// Most users won't see the above setting so tell them the default.
description: room.defaultUrlPreviewState ? i18n("URL previews are enabled by default in this room") : i18n("URL previews are disabled by default in this room")
@@ -296,10 +274,8 @@ Kirigami.ScrollablePage {
}
}
}
}
Kirigami.InlineMessage {
Layout.fillWidth: true
Layout.maximumWidth: Kirigami.Units.gridUnit * 30
Layout.alignment: Qt.AlignHCenter
text: i18n("This room continues another conversation.")
@@ -314,7 +290,6 @@ Kirigami.ScrollablePage {
}
}
Kirigami.InlineMessage {
Layout.fillWidth: true
Layout.maximumWidth: Kirigami.Units.gridUnit * 30
Layout.alignment: Qt.AlignHCenter
text: i18n("This room has been replaced.")
@@ -329,7 +304,7 @@ Kirigami.ScrollablePage {
}
}
Component {
property Component openFileDialog: Component {
id: openFileDialog
OpenFileDialog {
@@ -337,7 +312,7 @@ Kirigami.ScrollablePage {
}
}
Kirigami.OverlaySheet {
property Kirigami.OverlaySheet roomUpgradeSheet: Kirigami.OverlaySheet {
id: roomUpgradeSheet
property var currentRoomVersion
@@ -360,6 +335,6 @@ Kirigami.ScrollablePage {
}
}
}
}
}

View File

@@ -6,53 +6,44 @@ import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15
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.kirigamiaddons.delegates 1.0 as Delegates
import org.kde.kirigamiaddons.labs.components 1.0 as KirigamiComponents
import org.kde.kitemmodels 1.0
import org.kde.neochat 1.0
Kirigami.ScrollablePage {
FormCard.FormCardPage {
id: root
property NeoChatRoom room
title: i18nc('@title:window', 'Permissions')
topPadding: 0
leftPadding: 0
rightPadding: 0
UserListModel {
property UserListModel userListModel: UserListModel {
id: userListModel
room: root.room
}
ListModel {
property ListModel powerLevelModel: ListModel {
id: powerLevelModel
}
ColumnLayout {
spacing: 0
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
title: i18n("Privileged Users")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
FormCard.FormCard {
Repeater {
model: KSortFilterProxyModel {
sourceModel: userListModel
sortRole: "powerLevel"
sortRoleName: "powerLevel"
sortOrder: Qt.DescendingOrder
filterRowCallback: function(source_row, source_parent) {
let powerLevelRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), UserListModel.PowerLevelRole)
return powerLevelRole > 0;
}
}
delegate: MobileForm.FormTextDelegate {
delegate: FormCard.FormTextDelegate {
text: name
description: userId
contentItem.children: RowLayout {
@@ -88,10 +79,9 @@ Kirigami.ScrollablePage {
}
}
}
MobileForm.FormDelegateSeparator { below: userListSearchCard }
MobileForm.AbstractFormDelegate {
FormCard.FormDelegateSeparator { below: userListSearchCard }
FormCard.AbstractFormDelegate {
id: userListSearchCard
Layout.fillWidth: true
visible: room.canSendState("m.room.power_levels")
contentItem: Kirigami.SearchField {
@@ -234,19 +224,14 @@ Kirigami.ScrollablePage {
}
}
}
}
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
visible: room.canSendState("m.room.power_levels")
title: i18n("Default permissions")
}
MobileForm.FormCard {
Layout.fillWidth: true
FormCard.FormCard {
visible: room.canSendState("m.room.power_levels")
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Default user power level")
description: i18n("This is power level for all new users when joining the room")
textRole: "text"
@@ -255,7 +240,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.defaultUserPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.defaultUserPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Default power level to set the room state")
description: i18n("This is used for all state events that do not have their own entry here")
textRole: "text"
@@ -264,7 +249,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.statePowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.statePowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Default power level to send messages")
description: i18n("This is used for all message events that do not have their own entry here")
textRole: "text"
@@ -274,19 +259,14 @@ Kirigami.ScrollablePage {
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.defaultEventPowerLevel = currentValue
}
}
}
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
visible: room.canSendState("m.room.power_levels")
title: i18n("Basic permissions")
}
MobileForm.FormCard {
Layout.fillWidth: true
FormCard.FormCard {
visible: room.canSendState("m.room.power_levels")
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Invite users")
textRole: "text"
valueRole: "powerLevel"
@@ -294,7 +274,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.invitePowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.invitePowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Kick users")
textRole: "text"
valueRole: "powerLevel"
@@ -302,7 +282,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.kickPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.kickPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Ban users")
textRole: "text"
valueRole: "powerLevel"
@@ -310,7 +290,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.banPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.banPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Remove message sent by other users")
textRole: "text"
valueRole: "powerLevel"
@@ -319,19 +299,14 @@ Kirigami.ScrollablePage {
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.redactPowerLevel = currentValue
}
}
}
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
visible: room.canSendState("m.room.power_levels")
title: i18n("Event permissions")
}
MobileForm.FormCard {
Layout.fillWidth: true
FormCard.FormCard {
visible: room.canSendState("m.room.power_levels")
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Change user permissions")
description: "m.room.power_levels"
textRole: "text"
@@ -340,7 +315,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.powerLevelPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.powerLevelPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Change the room name")
description: "m.room.name"
textRole: "text"
@@ -349,7 +324,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.namePowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.namePowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Change the room avatar")
description: "m.room.avatar"
textRole: "text"
@@ -358,7 +333,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.avatarPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.avatarPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Change the room canonical alias")
description: "m.room.canonical_alias"
textRole: "text"
@@ -367,7 +342,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.canonicalAliasPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.canonicalAliasPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Change the room topic")
description: "m.room.topic"
textRole: "text"
@@ -376,7 +351,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.topicPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.topicPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Enable encryption for the room")
description: "m.room.encryption"
textRole: "text"
@@ -385,7 +360,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.encryptionPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.encryptionPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Change the room history visibility")
description: "m.room.history_visibility"
textRole: "text"
@@ -394,7 +369,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.historyVisibilityPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.historyVisibilityPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Set pinned events")
description: "m.room.pinned_events"
textRole: "text"
@@ -403,7 +378,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.pinnedEventsPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.pinnedEventsPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Upgrade the room")
description: "m.room.tombstone"
textRole: "text"
@@ -412,7 +387,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.tombstonePowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.tombstonePowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Set the room server access control list (ACL)")
description: "m.room.server_acl"
textRole: "text"
@@ -421,7 +396,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.serverAclPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.serverAclPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
visible: room.isSpace
text: i18n("Set the children of this space")
description: "m.space.child"
@@ -431,7 +406,7 @@ Kirigami.ScrollablePage {
Component.onCompleted: currentIndex = indexOfValue(room.spaceChildPowerLevel)
onCurrentValueChanged: if(room.canSendState("m.room.power_levels")) room.spaceChildPowerLevel = currentValue
}
MobileForm.FormComboBoxDelegate {
FormCard.FormComboBoxDelegate {
text: i18n("Set the parent space of this room")
description: "m.space.parent"
textRole: "text"
@@ -442,5 +417,3 @@ Kirigami.ScrollablePage {
}
}
}
}
}

View File

@@ -6,31 +6,23 @@ import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15
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.neochat 1.0
Kirigami.ScrollablePage {
FormCard.FormCardPage {
id: root
property NeoChatRoom room
property string needUpgradeRoom: i18n("You need to upgrade this room to a newer version to enable this setting.")
title: i18n("Security")
topPadding: 0
leftPadding: 0
rightPadding: 0
ColumnLayout {
spacing: 0
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
title: i18nc("@option:check", "Encryption")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormSwitchDelegate {
FormCard.FormCard {
FormCard.FormSwitchDelegate {
id: enableEncryptionSwitch
text: i18n("Enable encryption")
description: i18nc("option:check", "Once enabled, encryption cannot be disabled.")
@@ -42,17 +34,12 @@ Kirigami.ScrollablePage {
}
}
}
}
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
title: i18nc("@option:check", "Access")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormRadioDelegate {
FormCard.FormCard {
FormCard.FormRadioDelegate {
text: i18nc("@option:check", "Private (invite only)")
description: i18n("Only invited people can join.")
checked: room.joinRule === "invite"
@@ -61,7 +48,7 @@ Kirigami.ScrollablePage {
room.joinRule = "invite";
}
}
MobileForm.FormRadioDelegate {
FormCard.FormRadioDelegate {
text: i18nc("@option:check", "Space members")
description: i18n("Anyone in a space can find and join.") +
(!["8", "9", "10"].includes(room.version) ? `\n${needUpgradeRoom}` : "")
@@ -71,7 +58,7 @@ Kirigami.ScrollablePage {
room.joinRule = "restricted";
}
}
MobileForm.FormRadioDelegate {
FormCard.FormRadioDelegate {
text: i18nc("@option:check", "Knock")
description: i18n("People not in the room need to request an invite to join the room.") +
(!["7", "8", "9", "10"].includes(room.version) ? `\n${needUpgradeRoom}` : "")
@@ -82,7 +69,7 @@ Kirigami.ScrollablePage {
room.joinRule = "knock";
}
}
MobileForm.FormRadioDelegate {
FormCard.FormRadioDelegate {
text: i18nc("@option:check", "Public")
description: i18nc("@option:check", "Anyone can find and join.")
checked: room.joinRule === "public"
@@ -92,17 +79,12 @@ Kirigami.ScrollablePage {
}
}
}
}
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
title: i18nc("@option:check", "Message history visibility")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormRadioDelegate {
FormCard.FormCard {
FormCard.FormRadioDelegate {
text: i18nc("@option:check", "Anyone")
description: i18nc("@option:check", "Anyone, regardless of whether they have joined, can view history.")
checked: room.historyVisibility === "world_readable"
@@ -111,7 +93,7 @@ Kirigami.ScrollablePage {
room.historyVisibility = "world_readable"
}
}
MobileForm.FormRadioDelegate {
FormCard.FormRadioDelegate {
text: i18nc("@option:check", "Members only")
description: i18nc("@option:check", "All members can view the entire message history, even before they joined.")
checked: room.historyVisibility === "shared"
@@ -120,7 +102,7 @@ Kirigami.ScrollablePage {
room.historyVisibility = "shared"
}
}
MobileForm.FormRadioDelegate {
FormCard.FormRadioDelegate {
text: i18nc("@option:check", "Members only (since invite)")
description: i18nc("@option:check", "New members can view the message history from the point they were invited to the room.")
checked: room.historyVisibility === "invited"
@@ -129,7 +111,7 @@ Kirigami.ScrollablePage {
room.historyVisibility = "invited"
}
}
MobileForm.FormRadioDelegate {
FormCard.FormRadioDelegate {
text: i18nc("@option:check", "Members only (since joining)")
description: i18nc("@option:check", "New members can view the message history from the point they joined the room.")
checked: room.historyVisibility === "joined"
@@ -139,8 +121,6 @@ Kirigami.ScrollablePage {
}
}
}
}
}
footer: QQC2.ToolBar {
contentItem: RowLayout {
@@ -155,7 +135,7 @@ Kirigami.ScrollablePage {
}
}
Component {
property Component confirmEncryptionDialog: Component {
id: confirmEncryptionDialog
ConfirmEncryptionDialog {
@@ -168,7 +148,7 @@ Kirigami.ScrollablePage {
}
}
Connections {
property Connections connections: Connections {
target: room
onEncryption: {
enableEncryptionSwitch.checked = room.usesEncryption