Port PushNotification settings page to FormCard

This commit is contained in:
Tobias Fella
2023-08-30 18:46:54 +02:00
parent a3423e5724
commit 0c19052f32

View File

@@ -6,31 +6,24 @@ 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.kitemmodels 1.0
import org.kde.neochat 1.0
Kirigami.ScrollablePage {
FormCard.FormCardPage {
id: root
property NeoChatRoom room
title: i18nc('@title:window', 'Notifications')
topPadding: 0
leftPadding: 0
rightPadding: 0
ColumnLayout {
spacing: 0
MobileForm.FormHeader {
Layout.fillWidth: true
FormCard.FormHeader {
title: i18n("Room notifications setting")
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormRadioDelegate {
FormCard.FormCard {
FormCard.FormRadioDelegate {
text: i18n("Follow global setting")
checked: room.pushNotificationState === PushNotificationState.Default
enabled: room.pushNotificationState !== PushNotificationState.Unknown
@@ -38,7 +31,7 @@ Kirigami.ScrollablePage {
room.pushNotificationState = PushNotificationState.Default
}
}
MobileForm.FormRadioDelegate {
FormCard.FormRadioDelegate {
text: i18nc("As in 'notify for all messages'","All")
checked: room.pushNotificationState === PushNotificationState.All
enabled: room.pushNotificationState !== PushNotificationState.Unknown
@@ -46,7 +39,7 @@ Kirigami.ScrollablePage {
room.pushNotificationState = PushNotificationState.All
}
}
MobileForm.FormRadioDelegate {
FormCard.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
@@ -54,7 +47,7 @@ Kirigami.ScrollablePage {
room.pushNotificationState = PushNotificationState.MentionKeyword
}
}
MobileForm.FormRadioDelegate {
FormCard.FormRadioDelegate {
text: i18nc("As in 'do not notify for any messages'","Off")
checked: room.pushNotificationState === PushNotificationState.Mute
enabled: room.pushNotificationState !== PushNotificationState.Unknown
@@ -63,17 +56,11 @@ Kirigami.ScrollablePage {
}
}
}
}
MobileForm.FormCard {
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCardHeader {
FormCard.FormHeader {
title: i18n("Keywords")
}
FormCard.FormCard {
Repeater {
model: KSortFilterProxyModel {
sourceModel: Controller.pushRuleModel
@@ -86,8 +73,18 @@ Kirigami.ScrollablePage {
}
delegate: ruleDelegate
Component {
id: ruleDelegate
NotificationRuleItem {
onDeleteRule: {
Controller.pushRuleModel.removeKeyword(id)
}
MobileForm.AbstractFormDelegate {
onActionChanged: (action) => Controller.pushRuleModel.setPushRuleAction(id, action)
}
}
}
FormCard.AbstractFormDelegate {
Layout.fillWidth: true
contentItem : RowLayout {
@@ -135,15 +132,3 @@ Kirigami.ScrollablePage {
}
}
}
}
Component {
id: ruleDelegate
NotificationRuleItem {
onDeleteRule: {
Controller.pushRuleModel.removeKeyword(id)
}
onActionChanged: (action) => Controller.pushRuleModel.setPushRuleAction(id, action)
}
}
}