Add actions to push rule settings popup
This commit is contained in:
parent
f466fe9f08
commit
4306098692
|
@ -1,5 +1,7 @@
|
|||
# TODO
|
||||
|
||||
- custom action
|
||||
- sfx selection
|
||||
- combo box custom item
|
||||
- explain pattern
|
||||
- fix spinbox buttons
|
||||
|
|
|
@ -1795,7 +1795,9 @@ class MatrixClient(nio.AsyncClient):
|
|||
pattern: Optional[str] = None,
|
||||
actions: Optional[List[PushAction]] = 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)
|
||||
|
||||
|
@ -1810,7 +1812,7 @@ class MatrixClient(nio.AsyncClient):
|
|||
] if isinstance(conditions, list) else None
|
||||
|
||||
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
|
||||
] if isinstance(actions, list) else None
|
||||
|
||||
|
@ -1835,6 +1837,9 @@ class MatrixClient(nio.AsyncClient):
|
|||
# Matrix API forces us to always pass a non-null actions paramater
|
||||
actions = [nio.PushAction.from_dict(a) for a in old.actions]
|
||||
|
||||
if old and old.default:
|
||||
await self.set_pushrule_actions("global", kind, rule_id, actions)
|
||||
else:
|
||||
await self.set_pushrule(
|
||||
scope = "global",
|
||||
kind = kind,
|
||||
|
|
|
@ -38,7 +38,7 @@ HColumnLayout {
|
|||
Layout.topMargin: theme.spacing / 2
|
||||
|
||||
CustomLabel {
|
||||
text: qsTr("Conditions for a message to trigger this rule:")
|
||||
text: qsTr("Conditions for messages to trigger this rule:")
|
||||
}
|
||||
|
||||
PositiveButton {
|
||||
|
|
|
@ -35,6 +35,14 @@ HFlickableColumnPopup {
|
|||
positionCombo.model[positionCombo.currentIndex].rule_id :
|
||||
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 = [
|
||||
checkedKind,
|
||||
details.idField.text,
|
||||
|
@ -45,6 +53,7 @@ HFlickableColumnPopup {
|
|||
enableCheck.checked,
|
||||
generalChecked ? details.matrixConditions : undefined,
|
||||
contentRadio.checked ? details.idField.text : undefined,
|
||||
actions,
|
||||
]
|
||||
|
||||
py.callClientCoro(userId, "edit_pushrule", args, root.close)
|
||||
|
@ -169,9 +178,72 @@ HFlickableColumnPopup {
|
|||
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 {
|
||||
visible: ! rule.default && positionCombo.model.length > 1
|
||||
label.text: qsTr("Position:")
|
||||
label.text: qsTr("Rule position:")
|
||||
Layout.fillWidth: true
|
||||
|
||||
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