port Security and Notifications tab of room settings to mobileform

This commit is contained in:
Gary Wang
2022-11-17 20:56:07 +08:00
committed by Carl Schwan
parent d7f3284aa2
commit de1833cc40
2 changed files with 71 additions and 72 deletions

View File

@@ -6,6 +6,7 @@ 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.neochat 1.0 import org.kde.neochat 1.0
@@ -16,38 +17,42 @@ Kirigami.ScrollablePage {
title: i18nc('@title:window', 'Notifications') title: i18nc('@title:window', 'Notifications')
ColumnLayout { ColumnLayout {
Kirigami.FormLayout { MobileForm.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true Layout.fillWidth: true
contentItem: ColumnLayout {
QQC2.RadioButton { spacing: 0
MobileForm.FormCardHeader {
title: i18n("Room notifications setting")
}
MobileForm.FormRadioDelegate {
text: i18n("Follow global setting") text: i18n("Follow global setting")
Kirigami.FormData.label: i18n("Room notifications setting:")
checked: room.pushNotificationState === PushNotificationState.Default checked: room.pushNotificationState === PushNotificationState.Default
enabled: room.pushNotificationState != PushNotificationState.Unknown enabled: room.pushNotificationState !== PushNotificationState.Unknown
onToggled: { onToggled: {
room.pushNotificationState = PushNotificationState.Default room.pushNotificationState = PushNotificationState.Default
} }
} }
QQC2.RadioButton { MobileForm.FormRadioDelegate {
text: i18nc("As in 'notify for all messages'","All") text: i18nc("As in 'notify for all messages'","All")
checked: room.pushNotificationState === PushNotificationState.All checked: room.pushNotificationState === PushNotificationState.All
enabled: room.pushNotificationState != PushNotificationState.Unknown enabled: room.pushNotificationState !== PushNotificationState.Unknown
onToggled: { onToggled: {
room.pushNotificationState = PushNotificationState.All room.pushNotificationState = PushNotificationState.All
} }
} }
QQC2.RadioButton { MobileForm.FormRadioDelegate {
text: i18nc("As in 'notify when the user is mentioned or the message contains a set keyword'","@Mentions and Keywords") text: i18nc("As in 'notify when the user is mentioned or the message contains a set keyword'","@Mentions and Keywords")
checked: room.pushNotificationState === PushNotificationState.MentionKeyword checked: room.pushNotificationState === PushNotificationState.MentionKeyword
enabled: room.pushNotificationState != PushNotificationState.Unknown enabled: room.pushNotificationState !== PushNotificationState.Unknown
onToggled: { onToggled: {
room.pushNotificationState = PushNotificationState.MentionKeyword room.pushNotificationState = PushNotificationState.MentionKeyword
} }
} }
QQC2.RadioButton { MobileForm.FormRadioDelegate {
text: i18nc("As in 'do not notify for any messages'","Off") text: i18nc("As in 'do not notify for any messages'","Off")
checked: room.pushNotificationState === PushNotificationState.Mute checked: room.pushNotificationState === PushNotificationState.Mute
enabled: room.pushNotificationState != PushNotificationState.Unknown enabled: room.pushNotificationState !== PushNotificationState.Unknown
onToggled: { onToggled: {
room.pushNotificationState = PushNotificationState.Mute room.pushNotificationState = PushNotificationState.Mute
} }
@@ -55,3 +60,4 @@ Kirigami.ScrollablePage {
} }
} }
} }
}

View File

@@ -6,6 +6,7 @@ import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2 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.neochat 1.0 import org.kde.neochat 1.0
@@ -17,52 +18,44 @@ Kirigami.ScrollablePage {
title: i18n("Security") title: i18n("Security")
ColumnLayout { ColumnLayout {
Kirigami.FormLayout { MobileForm.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true Layout.fillWidth: true
contentItem: ColumnLayout {
QQC2.RadioButton { spacing: 0
MobileForm.FormCardHeader {
title: i18nc("@option:check", "Access")
}
MobileForm.FormRadioDelegate {
text: i18nc("@option:check", "Private (invite only)") text: i18nc("@option:check", "Private (invite only)")
Kirigami.FormData.label: i18nc("@option:check", "Access:") description: i18n("Only invited people can join.")
checked: room.joinRule === "invite" checked: room.joinRule === "invite"
enabled: room.canSendState("m.room.join_rules") enabled: room.canSendState("m.room.join_rules")
onCheckedChanged: if (checked) { onCheckedChanged: if (checked) {
room.joinRule = "invite"; room.joinRule = "invite";
} }
} }
QQC2.Label { MobileForm.FormRadioDelegate {
text: i18n("Only invited people can join.")
font: Kirigami.Theme.smallFont
}
QQC2.RadioButton {
text: i18nc("@option:check", "Space members") text: i18nc("@option:check", "Space members")
description: !["8", "9", "10"].includes(room.version)
? i18n("Anyone in a space can find and join.") + '\n' +
i18n("You need to upgrade this room to a newer version to enable this setting.")
: i18n("Anyone in a space can find and join.")
checked: room.joinRule === "restricted" checked: room.joinRule === "restricted"
enabled: room.canSendState("m.room.join_rules") && ["8", "9", "10"].includes(room.version) && false enabled: room.canSendState("m.room.join_rules") && ["8", "9", "10"].includes(room.version) && false
onCheckedChanged: if (checked) { onCheckedChanged: if (checked) {
room.joinRule = "restricted"; room.joinRule = "restricted";
} }
} }
QQC2.Label { MobileForm.FormRadioDelegate {
text: i18n("Anyone in a space can find and join.")
wrapMode: Qt.Wrap
width: root.width
font: Kirigami.Theme.smallFont
}
QQC2.Label {
font: Kirigami.Theme.smallFont
visible: !["8", "9", "10"].includes(room.version)
text: i18n("You need to upgrade this room to a newer version to enable this setting.")
}
QQC2.RadioButton {
text: i18nc("@option:check", "Public") text: i18nc("@option:check", "Public")
description: i18nc("@option:check", "Anyone can find and join.")
checked: room.joinRule === "public" checked: room.joinRule === "public"
enabled: room.canSendState("m.room.join_rules") enabled: room.canSendState("m.room.join_rules")
onCheckedChanged: if (checked) { onCheckedChanged: if (checked) {
room.joinRule = "public"; room.joinRule = "public";
} }
} }
QQC2.Label {
text: i18nc("@option:check", "Anyone can find and join.")
font: Kirigami.Theme.smallFont
} }
} }
} }