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,40 +17,45 @@ 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
text: i18n("Follow global setting") MobileForm.FormCardHeader {
Kirigami.FormData.label: i18n("Room notifications setting:") title: i18n("Room notifications setting")
checked: room.pushNotificationState === PushNotificationState.Default
enabled: room.pushNotificationState != PushNotificationState.Unknown
onToggled: {
room.pushNotificationState = PushNotificationState.Default
} }
} MobileForm.FormRadioDelegate {
QQC2.RadioButton { text: i18n("Follow global setting")
text: i18nc("As in 'notify for all messages'","All") checked: room.pushNotificationState === PushNotificationState.Default
checked: room.pushNotificationState === PushNotificationState.All enabled: room.pushNotificationState !== PushNotificationState.Unknown
enabled: room.pushNotificationState != PushNotificationState.Unknown onToggled: {
onToggled: { room.pushNotificationState = PushNotificationState.Default
room.pushNotificationState = PushNotificationState.All }
} }
} MobileForm.FormRadioDelegate {
QQC2.RadioButton { text: i18nc("As in 'notify for all messages'","All")
text: i18nc("As in 'notify when the user is mentioned or the message contains a set keyword'","@Mentions and Keywords") checked: room.pushNotificationState === PushNotificationState.All
checked: room.pushNotificationState === PushNotificationState.MentionKeyword enabled: room.pushNotificationState !== PushNotificationState.Unknown
enabled: room.pushNotificationState != PushNotificationState.Unknown onToggled: {
onToggled: { room.pushNotificationState = PushNotificationState.All
room.pushNotificationState = PushNotificationState.MentionKeyword }
} }
} MobileForm.FormRadioDelegate {
QQC2.RadioButton { text: i18nc("As in 'notify when the user is mentioned or the message contains a set keyword'","@Mentions and Keywords")
text: i18nc("As in 'do not notify for any messages'","Off") checked: room.pushNotificationState === PushNotificationState.MentionKeyword
checked: room.pushNotificationState === PushNotificationState.Mute enabled: room.pushNotificationState !== PushNotificationState.Unknown
enabled: room.pushNotificationState != PushNotificationState.Unknown onToggled: {
onToggled: { room.pushNotificationState = PushNotificationState.MentionKeyword
room.pushNotificationState = PushNotificationState.Mute }
}
MobileForm.FormRadioDelegate {
text: i18nc("As in 'do not notify for any messages'","Off")
checked: room.pushNotificationState === PushNotificationState.Mute
enabled: room.pushNotificationState !== PushNotificationState.Unknown
onToggled: {
room.pushNotificationState = PushNotificationState.Mute
}
} }
} }
} }

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
text: i18nc("@option:check", "Private (invite only)") MobileForm.FormCardHeader {
Kirigami.FormData.label: i18nc("@option:check", "Access:") title: i18nc("@option:check", "Access")
checked: room.joinRule === "invite"
enabled: room.canSendState("m.room.join_rules")
onCheckedChanged: if (checked) {
room.joinRule = "invite";
} }
} MobileForm.FormRadioDelegate {
QQC2.Label { text: i18nc("@option:check", "Private (invite only)")
text: i18n("Only invited people can join.") description: i18n("Only invited people can join.")
font: Kirigami.Theme.smallFont checked: room.joinRule === "invite"
} enabled: room.canSendState("m.room.join_rules")
QQC2.RadioButton { onCheckedChanged: if (checked) {
text: i18nc("@option:check", "Space members") room.joinRule = "invite";
checked: room.joinRule === "restricted" }
enabled: room.canSendState("m.room.join_rules") && ["8", "9", "10"].includes(room.version) && false
onCheckedChanged: if (checked) {
room.joinRule = "restricted";
} }
} MobileForm.FormRadioDelegate {
QQC2.Label { text: i18nc("@option:check", "Space members")
text: i18n("Anyone in a space can find and join.") description: !["8", "9", "10"].includes(room.version)
wrapMode: Qt.Wrap ? i18n("Anyone in a space can find and join.") + '\n' +
width: root.width i18n("You need to upgrade this room to a newer version to enable this setting.")
font: Kirigami.Theme.smallFont : i18n("Anyone in a space can find and join.")
} checked: room.joinRule === "restricted"
QQC2.Label { enabled: room.canSendState("m.room.join_rules") && ["8", "9", "10"].includes(room.version) && false
font: Kirigami.Theme.smallFont onCheckedChanged: if (checked) {
visible: !["8", "9", "10"].includes(room.version) room.joinRule = "restricted";
text: i18n("You need to upgrade this room to a newer version to enable this setting.") }
} }
QQC2.RadioButton { MobileForm.FormRadioDelegate {
text: i18nc("@option:check", "Public") text: i18nc("@option:check", "Public")
checked: room.joinRule === "public" description: i18nc("@option:check", "Anyone can find and join.")
enabled: room.canSendState("m.room.join_rules") checked: room.joinRule === "public"
onCheckedChanged: if (checked) { enabled: room.canSendState("m.room.join_rules")
room.joinRule = "public"; onCheckedChanged: if (checked) {
room.joinRule = "public";
}
} }
}
QQC2.Label {
text: i18nc("@option:check", "Anyone can find and join.")
font: Kirigami.Theme.smallFont
} }
} }
} }