Add actions to push rule settings popup
This commit is contained in:
parent
f466fe9f08
commit
4306098692
|
@ -1,5 +1,7 @@
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
- custom action
|
||||||
|
- sfx selection
|
||||||
- combo box custom item
|
- combo box custom item
|
||||||
- explain pattern
|
- explain pattern
|
||||||
- fix spinbox buttons
|
- fix spinbox buttons
|
||||||
|
|
|
@ -1795,7 +1795,9 @@ class MatrixClient(nio.AsyncClient):
|
||||||
pattern: Optional[str] = None,
|
pattern: Optional[str] = None,
|
||||||
actions: Optional[List[PushAction]] = None,
|
actions: Optional[List[PushAction]] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Create or edit an existing non-builtin pushrule."""
|
"""Create or edit an existing non-builtin pushrule.
|
||||||
|
For builtin server ("default") rules, only actions can be edited.
|
||||||
|
"""
|
||||||
|
|
||||||
# Convert arguments that were passed as basic types (usually from QML)
|
# Convert arguments that were passed as basic types (usually from QML)
|
||||||
|
|
||||||
|
@ -1810,7 +1812,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
] if isinstance(conditions, list) else None
|
] if isinstance(conditions, list) else None
|
||||||
|
|
||||||
actions = [
|
actions = [
|
||||||
nio.PushAction.from_dict(a) if isinstance(a, dict) else a
|
nio.PushAction.from_dict(a) if isinstance(a, (str, dict)) else a
|
||||||
for a in actions
|
for a in actions
|
||||||
] if isinstance(actions, list) else None
|
] if isinstance(actions, list) else None
|
||||||
|
|
||||||
|
@ -1835,16 +1837,19 @@ class MatrixClient(nio.AsyncClient):
|
||||||
# Matrix API forces us to always pass a non-null actions paramater
|
# Matrix API forces us to always pass a non-null actions paramater
|
||||||
actions = [nio.PushAction.from_dict(a) for a in old.actions]
|
actions = [nio.PushAction.from_dict(a) for a in old.actions]
|
||||||
|
|
||||||
await self.set_pushrule(
|
if old and old.default:
|
||||||
scope = "global",
|
await self.set_pushrule_actions("global", kind, rule_id, actions)
|
||||||
kind = kind,
|
else:
|
||||||
rule_id = rule_id,
|
await self.set_pushrule(
|
||||||
before = move_before_rule_id,
|
scope = "global",
|
||||||
after = move_after_rule_id,
|
kind = kind,
|
||||||
actions = actions or [],
|
rule_id = rule_id,
|
||||||
conditions = conditions,
|
before = move_before_rule_id,
|
||||||
pattern = pattern,
|
after = move_after_rule_id,
|
||||||
)
|
actions = actions or [],
|
||||||
|
conditions = conditions,
|
||||||
|
pattern = pattern,
|
||||||
|
)
|
||||||
|
|
||||||
# If we're editing an existing rule but its kind or ID is changed,
|
# If we're editing an existing rule but its kind or ID is changed,
|
||||||
# set_pushrule creates a new rule, thus we must delete the old one
|
# set_pushrule creates a new rule, thus we must delete the old one
|
||||||
|
|
|
@ -38,7 +38,7 @@ HColumnLayout {
|
||||||
Layout.topMargin: theme.spacing / 2
|
Layout.topMargin: theme.spacing / 2
|
||||||
|
|
||||||
CustomLabel {
|
CustomLabel {
|
||||||
text: qsTr("Conditions for a message to trigger this rule:")
|
text: qsTr("Conditions for messages to trigger this rule:")
|
||||||
}
|
}
|
||||||
|
|
||||||
PositiveButton {
|
PositiveButton {
|
||||||
|
|
|
@ -35,6 +35,14 @@ HFlickableColumnPopup {
|
||||||
positionCombo.model[positionCombo.currentIndex].rule_id :
|
positionCombo.model[positionCombo.currentIndex].rule_id :
|
||||||
undefined
|
undefined
|
||||||
|
|
||||||
|
const actions = []
|
||||||
|
const sfx = soundCheck.checked ? "default": false
|
||||||
|
notifyCheck.checked && actions.push("notify")
|
||||||
|
actions.push({set_tweak: "highlight", value: highlightCheck.checked})
|
||||||
|
actions.push({set_tweak: "bubble", value: bubbleCheck.checked})
|
||||||
|
actions.push({set_tweak: "sound", value: sfx})
|
||||||
|
actions.push({set_tweak: "urgency_hint", value: urgencyCheck.checked})
|
||||||
|
|
||||||
const args = [
|
const args = [
|
||||||
checkedKind,
|
checkedKind,
|
||||||
details.idField.text,
|
details.idField.text,
|
||||||
|
@ -45,6 +53,7 @@ HFlickableColumnPopup {
|
||||||
enableCheck.checked,
|
enableCheck.checked,
|
||||||
generalChecked ? details.matrixConditions : undefined,
|
generalChecked ? details.matrixConditions : undefined,
|
||||||
contentRadio.checked ? details.idField.text : undefined,
|
contentRadio.checked ? details.idField.text : undefined,
|
||||||
|
actions,
|
||||||
]
|
]
|
||||||
|
|
||||||
py.callClientCoro(userId, "edit_pushrule", args, root.close)
|
py.callClientCoro(userId, "edit_pushrule", args, root.close)
|
||||||
|
@ -169,9 +178,72 @@ HFlickableColumnPopup {
|
||||||
GeneralRule { enabled: SwipeView.isCurrentItem }
|
GeneralRule { enabled: SwipeView.isCurrentItem }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HColumnLayout {
|
||||||
|
spacing: theme.spacing / 2
|
||||||
|
|
||||||
|
HRowLayout {
|
||||||
|
CustomLabel {
|
||||||
|
text: qsTr("Actions for messages that trigger this rule:")
|
||||||
|
}
|
||||||
|
|
||||||
|
PositiveButton {
|
||||||
|
icon.name: "pushrule-action-add"
|
||||||
|
iconItem.small: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: false
|
||||||
|
// onClicked: addConditionMenu.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HCheckBox {
|
||||||
|
id: notifyCheck
|
||||||
|
text: qsTr("Mark as unread")
|
||||||
|
defaultChecked: root.rule.notify
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
HCheckBox {
|
||||||
|
id: highlightCheck
|
||||||
|
text: qsTr("Mark as important")
|
||||||
|
enabled: notifyCheck.checked
|
||||||
|
defaultChecked: root.rule.highlight
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
HCheckBox {
|
||||||
|
id: bubbleCheck
|
||||||
|
text: qsTr("Show notification bubble")
|
||||||
|
enabled: notifyCheck.checked
|
||||||
|
defaultChecked: root.rule.bubble
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
HCheckBox {
|
||||||
|
id: soundCheck
|
||||||
|
text: qsTr("Play sound")
|
||||||
|
enabled: notifyCheck.checked
|
||||||
|
defaultChecked: root.rule.sound
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
HCheckBox {
|
||||||
|
id: urgencyCheck
|
||||||
|
text:
|
||||||
|
Qt.platform === "windows" ?
|
||||||
|
qsTr("Make taskbar application icon flash") :
|
||||||
|
Qt.platform === "osx" ?
|
||||||
|
qsTr("Make dock application icon flash") :
|
||||||
|
qsTr("Highlight the application window")
|
||||||
|
|
||||||
|
enabled: notifyCheck.checked
|
||||||
|
defaultChecked: root.rule.urgency_hint
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HLabeledItem {
|
HLabeledItem {
|
||||||
visible: ! rule.default && positionCombo.model.length > 1
|
visible: ! rule.default && positionCombo.model.length > 1
|
||||||
label.text: qsTr("Position:")
|
label.text: qsTr("Rule position:")
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
HComboBox {
|
HComboBox {
|
||||||
|
|
3
src/icons/thin/pushrule-action-add.svg
Normal file
3
src/icons/thin/pushrule-action-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 |
Loading…
Reference in New Issue
Block a user