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