Implement adding new custom push rules
This commit is contained in:
		@@ -3,7 +3,6 @@
 | 
				
			|||||||
- combo box custom item
 | 
					- combo box custom item
 | 
				
			||||||
- explain pattern
 | 
					- explain pattern
 | 
				
			||||||
- fix spinbox buttons
 | 
					- fix spinbox buttons
 | 
				
			||||||
- way to add new rule 
 | 
					 | 
				
			||||||
- quick room & sender rule changes
 | 
					- quick room & sender rule changes
 | 
				
			||||||
- config & keybind for global rule disabling
 | 
					- config & keybind for global rule disabling
 | 
				
			||||||
- quick settings
 | 
					- quick settings
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1822,8 +1822,8 @@ class MatrixClient(nio.AsyncClient):
 | 
				
			|||||||
        if None not in key:
 | 
					        if None not in key:
 | 
				
			||||||
            old = self.models[self.user_id, "pushrules"].get(key)
 | 
					            old = self.models[self.user_id, "pushrules"].get(key)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        kind_change    = old_kind is not None and old_kind != kind
 | 
					        kind_change    = old and old_kind and old_kind != kind
 | 
				
			||||||
        rule_id_change = old_rule_id is not None and old_rule_id != rule_id
 | 
					        rule_id_change = old and old_rule_id and old_rule_id != rule_id
 | 
				
			||||||
        explicit_move  = move_before_rule_id or move_after_rule_id
 | 
					        explicit_move  = move_before_rule_id or move_after_rule_id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if old and not kind_change and not explicit_move:
 | 
					        if old and not kind_change and not explicit_move:
 | 
				
			||||||
@@ -1841,7 +1841,7 @@ class MatrixClient(nio.AsyncClient):
 | 
				
			|||||||
            rule_id    = rule_id,
 | 
					            rule_id    = rule_id,
 | 
				
			||||||
            before     = move_before_rule_id,
 | 
					            before     = move_before_rule_id,
 | 
				
			||||||
            after      = move_after_rule_id,
 | 
					            after      = move_after_rule_id,
 | 
				
			||||||
            actions    = actions,
 | 
					            actions    = actions or [],
 | 
				
			||||||
            conditions = conditions,
 | 
					            conditions = conditions,
 | 
				
			||||||
            pattern    = pattern,
 | 
					            pattern    = pattern,
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,16 +68,50 @@ HListView {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    section.property: "kind"
 | 
					    section.property: "kind"
 | 
				
			||||||
    section.delegate: HLabel {
 | 
					    section.delegate: HRowLayout {
 | 
				
			||||||
        width: root.width
 | 
					        width: root.width
 | 
				
			||||||
        padding: theme.spacing
 | 
					
 | 
				
			||||||
        font.pixelSize: theme.fontSize.big
 | 
					        HLabel {
 | 
				
			||||||
        text:
 | 
					            padding: theme.spacing
 | 
				
			||||||
            section === "override" ? qsTr("High priority general rules") :
 | 
					            font.pixelSize: theme.fontSize.big
 | 
				
			||||||
            section === "content" ? qsTr("Message content rules") :
 | 
					            text:
 | 
				
			||||||
            section === "room" ? qsTr("Room rules") :
 | 
					                section === "override" ? qsTr("High priority general rules") :
 | 
				
			||||||
            section === "sender" ? qsTr("Sender rules") :
 | 
					                section === "content" ? qsTr("Message content rules") :
 | 
				
			||||||
            qsTr("Low priority general rules")
 | 
					                section === "room" ? qsTr("Room rules") :
 | 
				
			||||||
 | 
					                section === "sender" ? qsTr("Sender rules") :
 | 
				
			||||||
 | 
					                qsTr("Low priority general rules")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Layout.fillWidth: true
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        PositiveButton {
 | 
				
			||||||
 | 
					            readonly property var newRule: ({
 | 
				
			||||||
 | 
					                id: '[section, ""]',
 | 
				
			||||||
 | 
					                kind: section,
 | 
				
			||||||
 | 
					                rule_id: "",
 | 
				
			||||||
 | 
					                order: 0,
 | 
				
			||||||
 | 
					                default: false,
 | 
				
			||||||
 | 
					                enabled: true,
 | 
				
			||||||
 | 
					                conditions: "[]",
 | 
				
			||||||
 | 
					                pattern: "",
 | 
				
			||||||
 | 
					                actions: "[]",
 | 
				
			||||||
 | 
					                notify: false,
 | 
				
			||||||
 | 
					                highlight: false,
 | 
				
			||||||
 | 
					                bubble: false,
 | 
				
			||||||
 | 
					                sound: false,
 | 
				
			||||||
 | 
					                urgency_hint: false,
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            backgroundColor: "transparent"
 | 
				
			||||||
 | 
					            icon.name: "pushrule-add"
 | 
				
			||||||
 | 
					            iconItem.small: true
 | 
				
			||||||
 | 
					            Layout.fillHeight: true
 | 
				
			||||||
 | 
					            Layout.fillWidth: false
 | 
				
			||||||
 | 
					            onClicked: window.makePopup(
 | 
				
			||||||
 | 
					                "Popups/PushRuleSettingsPopup/PushRuleSettingsPopup.qml",
 | 
				
			||||||
 | 
					                {userId: root.userId, rule: newRule, ruleExists: false},
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    delegate: NotificationRuleDelegate {
 | 
					    delegate: NotificationRuleDelegate {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,7 @@ HFlickableColumnPopup {
 | 
				
			|||||||
    property string userId
 | 
					    property string userId
 | 
				
			||||||
    // A rule item from ModelStore.get(userId, "pushrules")
 | 
					    // A rule item from ModelStore.get(userId, "pushrules")
 | 
				
			||||||
    property var rule
 | 
					    property var rule
 | 
				
			||||||
 | 
					    property bool ruleExists: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    readonly property bool generalChecked:
 | 
					    readonly property bool generalChecked:
 | 
				
			||||||
        overrideRadio.checked || underrideRadio.checked
 | 
					        overrideRadio.checked || underrideRadio.checked
 | 
				
			||||||
@@ -184,6 +185,7 @@ HFlickableColumnPopup {
 | 
				
			|||||||
                )
 | 
					                )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            readonly property bool isCurrent:
 | 
					            readonly property bool isCurrent:
 | 
				
			||||||
 | 
					                root.ruleExists &&
 | 
				
			||||||
                model.length &&
 | 
					                model.length &&
 | 
				
			||||||
                currentIndex === currentPosition &&
 | 
					                currentIndex === currentPosition &&
 | 
				
			||||||
                root.rule.kind === root.checkedKind
 | 
					                root.rule.kind === root.checkedKind
 | 
				
			||||||
@@ -226,6 +228,7 @@ HFlickableColumnPopup {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                label.textFormat: HLabel.StyledText
 | 
					                label.textFormat: HLabel.StyledText
 | 
				
			||||||
                text:
 | 
					                text:
 | 
				
			||||||
 | 
					                    root.ruleExists &&
 | 
				
			||||||
                    model.index === positionCombo.currentPosition &&
 | 
					                    model.index === positionCombo.currentPosition &&
 | 
				
			||||||
                    root.rule.kind === root.checkedKind ?
 | 
					                    root.rule.kind === root.checkedKind ?
 | 
				
			||||||
                    qsTr("Current") :
 | 
					                    qsTr("Current") :
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								src/icons/thin/pushrule-add.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/icons/thin/pushrule-add.svg
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
 | 
				
			||||||
 | 
					    <path d="m24 10h-10v-10h-4v10h-10v4h10v10h4v-10h10z"/>
 | 
				
			||||||
 | 
					</svg>
 | 
				
			||||||
| 
		 After Width: | Height: | Size: 150 B  | 
		Reference in New Issue
	
	Block a user