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 org.kde.kirigami 2.15 as Kirigami
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm
import org.kde.neochat 1.0
@@ -16,40 +17,45 @@ Kirigami.ScrollablePage {
title: i18nc('@title:window', 'Notifications')
ColumnLayout {
Kirigami.FormLayout {
MobileForm.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
QQC2.RadioButton {
text: i18n("Follow global setting")
Kirigami.FormData.label: i18n("Room notifications setting:")
checked: room.pushNotificationState === PushNotificationState.Default
enabled: room.pushNotificationState != PushNotificationState.Unknown
onToggled: {
room.pushNotificationState = PushNotificationState.Default
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCardHeader {
title: i18n("Room notifications setting")
}
}
QQC2.RadioButton {
text: i18nc("As in 'notify for all messages'","All")
checked: room.pushNotificationState === PushNotificationState.All
enabled: room.pushNotificationState != PushNotificationState.Unknown
onToggled: {
room.pushNotificationState = PushNotificationState.All
MobileForm.FormRadioDelegate {
text: i18n("Follow global setting")
checked: room.pushNotificationState === PushNotificationState.Default
enabled: room.pushNotificationState !== PushNotificationState.Unknown
onToggled: {
room.pushNotificationState = PushNotificationState.Default
}
}
}
QQC2.RadioButton {
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
enabled: room.pushNotificationState != PushNotificationState.Unknown
onToggled: {
room.pushNotificationState = PushNotificationState.MentionKeyword
MobileForm.FormRadioDelegate {
text: i18nc("As in 'notify for all messages'","All")
checked: room.pushNotificationState === PushNotificationState.All
enabled: room.pushNotificationState !== PushNotificationState.Unknown
onToggled: {
room.pushNotificationState = PushNotificationState.All
}
}
}
QQC2.RadioButton {
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
MobileForm.FormRadioDelegate {
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
enabled: room.pushNotificationState !== PushNotificationState.Unknown
onToggled: {
room.pushNotificationState = PushNotificationState.MentionKeyword
}
}
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.Layouts 1.15
import org.kde.kirigami 2.15 as Kirigami
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm
import org.kde.neochat 1.0
@@ -17,52 +18,44 @@ Kirigami.ScrollablePage {
title: i18n("Security")
ColumnLayout {
Kirigami.FormLayout {
MobileForm.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true
QQC2.RadioButton {
text: i18nc("@option:check", "Private (invite only)")
Kirigami.FormData.label: i18nc("@option:check", "Access:")
checked: room.joinRule === "invite"
enabled: room.canSendState("m.room.join_rules")
onCheckedChanged: if (checked) {
room.joinRule = "invite";
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCardHeader {
title: i18nc("@option:check", "Access")
}
}
QQC2.Label {
text: i18n("Only invited people can join.")
font: Kirigami.Theme.smallFont
}
QQC2.RadioButton {
text: i18nc("@option:check", "Space members")
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 {
text: i18nc("@option:check", "Private (invite only)")
description: i18n("Only invited people can join.")
checked: room.joinRule === "invite"
enabled: room.canSendState("m.room.join_rules")
onCheckedChanged: if (checked) {
room.joinRule = "invite";
}
}
}
QQC2.Label {
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")
checked: room.joinRule === "public"
enabled: room.canSendState("m.room.join_rules")
onCheckedChanged: if (checked) {
room.joinRule = "public";
MobileForm.FormRadioDelegate {
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"
enabled: room.canSendState("m.room.join_rules") && ["8", "9", "10"].includes(room.version) && false
onCheckedChanged: if (checked) {
room.joinRule = "restricted";
}
}
MobileForm.FormRadioDelegate {
text: i18nc("@option:check", "Public")
description: i18nc("@option:check", "Anyone can find and join.")
checked: room.joinRule === "public"
enabled: room.canSendState("m.room.join_rules")
onCheckedChanged: if (checked) {
room.joinRule = "public";
}
}
}
QQC2.Label {
text: i18nc("@option:check", "Anyone can find and join.")
font: Kirigami.Theme.smallFont
}
}
}