Port GlobalNotificationsPage to FormCard
This commit is contained in:
@@ -6,205 +6,166 @@ 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
|
||||||
|
|
||||||
title: i18nc("@title:window", "Notifications")
|
title: i18nc("@title:window", "Notifications")
|
||||||
topPadding: 0
|
|
||||||
leftPadding: 0
|
|
||||||
rightPadding: 0
|
|
||||||
|
|
||||||
ColumnLayout {
|
FormCard.FormCard {
|
||||||
id: notificationLayout
|
Layout.topMargin: Kirigami.Units.largeSpacing
|
||||||
spacing: 0
|
FormCard.FormCheckDelegate {
|
||||||
|
text: i18n("Enable notifications for this account")
|
||||||
MobileForm.FormCard {
|
description: i18n("Whether push notifications are generated by your Matrix server")
|
||||||
Layout.fillWidth: true
|
checked: Controller.pushRuleModel.globalNotificationsEnabled
|
||||||
Layout.topMargin: Kirigami.Units.largeSpacing
|
enabled: Controller.pushRuleModel.globalNotificationsSet
|
||||||
contentItem: MobileForm.FormCheckDelegate {
|
onToggled: {
|
||||||
text: i18n("Enable notifications for this account")
|
Controller.pushRuleModel.globalNotificationsEnabled = checked
|
||||||
description: i18n("Whether push notifications are generated by your Matrix server")
|
|
||||||
checked: Controller.pushRuleModel.globalNotificationsEnabled
|
|
||||||
enabled: Controller.pushRuleModel.globalNotificationsSet
|
|
||||||
onToggled: {
|
|
||||||
Controller.pushRuleModel.globalNotificationsEnabled = checked
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MobileForm.FormHeader {
|
FormCard.FormHeader {
|
||||||
Layout.fillWidth: true
|
title: i18n("Room Notifications")
|
||||||
title: i18n("Room Notifications")
|
}
|
||||||
}
|
FormCard.FormCard {
|
||||||
MobileForm.FormCard {
|
Repeater {
|
||||||
Layout.fillWidth: true
|
model: KSortFilterProxyModel {
|
||||||
|
sourceModel: Controller.pushRuleModel
|
||||||
contentItem: ColumnLayout {
|
filterRowCallback: function(source_row, source_parent) {
|
||||||
spacing: 0
|
let sectionRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), PushRuleModel.SectionRole)
|
||||||
|
return sectionRole == PushNotificationSection.Room;
|
||||||
Repeater {
|
|
||||||
model: KSortFilterProxyModel {
|
|
||||||
sourceModel: Controller.pushRuleModel
|
|
||||||
filterRowCallback: function(source_row, source_parent) {
|
|
||||||
let sectionRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), PushRuleModel.SectionRole)
|
|
||||||
return sectionRole == PushNotificationSection.Room;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: ruleDelegate
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delegate: ruleDelegate
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MobileForm.FormHeader {
|
FormCard.FormHeader {
|
||||||
Layout.fillWidth: true
|
title: i18n("@Mentions")
|
||||||
title: i18n("@Mentions")
|
}
|
||||||
}
|
FormCard.FormCard {
|
||||||
MobileForm.FormCard {
|
Repeater {
|
||||||
Layout.fillWidth: true
|
model: KSortFilterProxyModel {
|
||||||
|
sourceModel: Controller.pushRuleModel
|
||||||
contentItem: ColumnLayout {
|
filterRowCallback: function(source_row, source_parent) {
|
||||||
spacing: 0
|
let sectionRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), PushRuleModel.SectionRole)
|
||||||
Repeater {
|
return sectionRole == PushNotificationSection.Mentions;
|
||||||
model: KSortFilterProxyModel {
|
|
||||||
sourceModel: Controller.pushRuleModel
|
|
||||||
filterRowCallback: function(source_row, source_parent) {
|
|
||||||
let sectionRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), PushRuleModel.SectionRole)
|
|
||||||
return sectionRole == PushNotificationSection.Mentions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: ruleDelegate
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delegate: ruleDelegate
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MobileForm.FormHeader {
|
FormCard.FormHeader {
|
||||||
Layout.fillWidth: true
|
title: i18n("Keywords")
|
||||||
title: i18n("Keywords")
|
}
|
||||||
}
|
FormCard.FormCard {
|
||||||
MobileForm.FormCard {
|
Repeater {
|
||||||
Layout.fillWidth: true
|
model: KSortFilterProxyModel {
|
||||||
|
sourceModel: Controller.pushRuleModel
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
filterRowCallback: function(source_row, source_parent) {
|
||||||
spacing: 0
|
let sectionRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), PushRuleModel.SectionRole)
|
||||||
Repeater {
|
return sectionRole == PushNotificationSection.Keywords;
|
||||||
model: KSortFilterProxyModel {
|
|
||||||
sourceModel: Controller.pushRuleModel
|
|
||||||
|
|
||||||
filterRowCallback: function(source_row, source_parent) {
|
|
||||||
let sectionRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), PushRuleModel.SectionRole)
|
|
||||||
return sectionRole == PushNotificationSection.Keywords;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: ruleDelegate
|
|
||||||
}
|
}
|
||||||
MobileForm.AbstractFormDelegate {
|
}
|
||||||
|
|
||||||
|
delegate: ruleDelegate
|
||||||
|
}
|
||||||
|
FormCard.AbstractFormDelegate {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
contentItem : RowLayout {
|
||||||
|
Kirigami.ActionTextField {
|
||||||
|
id: keywordAddField
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
contentItem : RowLayout {
|
placeholderText: i18n("Keyword…")
|
||||||
Kirigami.ActionTextField {
|
enabled: NotificationsManager.keywordNotificationAction !== PushNotificationAction.Unknown
|
||||||
id: keywordAddField
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
rightActions: Kirigami.Action {
|
||||||
|
icon.name: "edit-clear"
|
||||||
placeholderText: i18n("Keyword…")
|
visible: keywordAddField.text.length > 0
|
||||||
enabled: NotificationsManager.keywordNotificationAction !== PushNotificationAction.Unknown
|
onTriggered: {
|
||||||
|
keywordAddField.text = ""
|
||||||
rightActions: Kirigami.Action {
|
|
||||||
icon.name: "edit-clear"
|
|
||||||
visible: keywordAddField.text.length > 0
|
|
||||||
onTriggered: {
|
|
||||||
keywordAddField.text = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onAccepted: {
|
|
||||||
Controller.pushRuleModel.addKeyword(keywordAddField.text)
|
|
||||||
keywordAddField.text = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QQC2.Button {
|
}
|
||||||
id: addButton
|
|
||||||
|
|
||||||
text: i18n("Add keyword")
|
onAccepted: {
|
||||||
Accessible.name: text
|
Controller.pushRuleModel.addKeyword(keywordAddField.text)
|
||||||
icon.name: "list-add"
|
keywordAddField.text = ""
|
||||||
display: QQC2.AbstractButton.IconOnly
|
|
||||||
enabled: NotificationsManager.keywordNotificationAction !== PushNotificationAction.Unknown
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
Controller.pushRuleModel.addKeyword(keywordAddField.text)
|
|
||||||
keywordAddField.text = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
QQC2.ToolTip {
|
|
||||||
text: addButton.text
|
|
||||||
delay: Kirigami.Units.toolTipDelay
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
QQC2.Button {
|
||||||
}
|
id: addButton
|
||||||
|
|
||||||
MobileForm.FormHeader {
|
text: i18n("Add keyword")
|
||||||
Layout.fillWidth: true
|
Accessible.name: text
|
||||||
title: i18n("Invites")
|
icon.name: "list-add"
|
||||||
}
|
display: QQC2.AbstractButton.IconOnly
|
||||||
MobileForm.FormCard {
|
enabled: NotificationsManager.keywordNotificationAction !== PushNotificationAction.Unknown
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
onClicked: {
|
||||||
spacing: 0
|
Controller.pushRuleModel.addKeyword(keywordAddField.text)
|
||||||
Repeater {
|
keywordAddField.text = ""
|
||||||
model: KSortFilterProxyModel {
|
|
||||||
sourceModel: Controller.pushRuleModel
|
|
||||||
filterRowCallback: function(source_row, source_parent) {
|
|
||||||
let sectionRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), PushRuleModel.SectionRole)
|
|
||||||
return sectionRole == PushNotificationSection.Invites;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: ruleDelegate
|
QQC2.ToolTip {
|
||||||
}
|
text: addButton.text
|
||||||
}
|
delay: Kirigami.Units.toolTipDelay
|
||||||
}
|
|
||||||
|
|
||||||
MobileForm.FormHeader {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
title: i18n("Unknown")
|
|
||||||
visible: unknownModel.rowCount() > 0
|
|
||||||
}
|
|
||||||
MobileForm.FormCard {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
visible: unknownModel.rowCount() > 0
|
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
|
||||||
spacing: 0
|
|
||||||
Repeater {
|
|
||||||
model: KSortFilterProxyModel {
|
|
||||||
id: unknownModel
|
|
||||||
sourceModel: Controller.pushRuleModel
|
|
||||||
filterRowCallback: function(source_row, source_parent) {
|
|
||||||
let sectionRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), PushRuleModel.SectionRole)
|
|
||||||
return sectionRole == PushNotificationSection.Unknown;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: ruleDelegate
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
FormCard.FormHeader {
|
||||||
|
title: i18n("Invites")
|
||||||
|
}
|
||||||
|
FormCard.FormCard {
|
||||||
|
Repeater {
|
||||||
|
model: KSortFilterProxyModel {
|
||||||
|
sourceModel: Controller.pushRuleModel
|
||||||
|
filterRowCallback: function(source_row, source_parent) {
|
||||||
|
let sectionRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), PushRuleModel.SectionRole)
|
||||||
|
return sectionRole == PushNotificationSection.Invites;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: ruleDelegate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FormCard.FormHeader {
|
||||||
|
title: i18n("Unknown")
|
||||||
|
visible: unknownModel.rowCount() > 0
|
||||||
|
}
|
||||||
|
FormCard.FormCard {
|
||||||
|
visible: unknownModel.rowCount() > 0
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: KSortFilterProxyModel {
|
||||||
|
id: unknownModel
|
||||||
|
sourceModel: Controller.pushRuleModel
|
||||||
|
filterRowCallback: function(source_row, source_parent) {
|
||||||
|
let sectionRole = sourceModel.data(sourceModel.index(source_row, 0, source_parent), PushRuleModel.SectionRole)
|
||||||
|
return sectionRole == PushNotificationSection.Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: ruleDelegate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
property Component ruleDelegate: Component {
|
||||||
id: ruleDelegate
|
id: ruleDelegate
|
||||||
NotificationRuleItem {
|
NotificationRuleItem {
|
||||||
onDeleteRule: {
|
onDeleteRule: {
|
||||||
|
|||||||
Reference in New Issue
Block a user