From de1833cc406df7c70792b7eb28fea7b010c847e1 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Thu, 17 Nov 2022 20:56:07 +0800 Subject: [PATCH] port Security and Notifications tab of room settings to mobileform --- src/qml/RoomSettings/PushNotification.qml | 66 ++++++++++--------- src/qml/RoomSettings/Security.qml | 77 +++++++++++------------ 2 files changed, 71 insertions(+), 72 deletions(-) diff --git a/src/qml/RoomSettings/PushNotification.qml b/src/qml/RoomSettings/PushNotification.qml index 4e8a342f8..93f617062 100644 --- a/src/qml/RoomSettings/PushNotification.qml +++ b/src/qml/RoomSettings/PushNotification.qml @@ -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 + } } } } diff --git a/src/qml/RoomSettings/Security.qml b/src/qml/RoomSettings/Security.qml index 624e4c215..5cc849f04 100644 --- a/src/qml/RoomSettings/Security.qml +++ b/src/qml/RoomSettings/Security.qml @@ -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 } } }