Require notify button on for other push actions

In the notification push rules UI:

- When the notify button for a rule (blue +1) is toggled off, show
  all other action buttons as toggled off too

- When clicking on another action while notify is off, enable notify and
  that action
This commit is contained in:
miruka 2021-01-21 11:40:18 -04:00
parent a06ce3352e
commit 977be541aa
2 changed files with 14 additions and 3 deletions

View File

@ -6,8 +6,9 @@ import "../../Base"
HButton {
property string toggles: ""
property var nextValue: ! on
property HButton requiresOn: null
readonly property bool on:
readonly property bool on: (requiresOn === null || requiresOn.on) && (
toggles && page.pendingEdits[model.id] &&
toggles in page.pendingEdits[model.id] ?
Boolean(page.pendingEdits[model.id][toggles]) :
@ -16,13 +17,20 @@ HButton {
Boolean(model[toggles]) :
true
)
opacity: on ? 1 : theme.disabledElementsOpacity
hoverEnabled: true
backgroundColor: "transparent"
onClicked: {
if (requiresOn !== null && ! requiresOn.on) {
requiresOn.clicked()
print(on, clicked)
if (! on) clicked()
return
}
if (! toggles) return
if (! (model.id in page.pendingEdits)) page.pendingEdits[model.id] = {}

View File

@ -118,7 +118,7 @@ HTile {
}
NotificationRuleButton {
enabled: notifyButton.on
requiresOn: notifyButton
toggles: "highlight"
contentItem: MessageIndicator {
@ -135,11 +135,13 @@ HTile {
}
NotificationRuleButton {
requiresOn: notifyButton
icon.name: "pushrule-action-bubble"
toggles: "bubble"
}
NotificationRuleButton {
requiresOn: notifyButton
icon.name: "pushrule-action-sound"
toggles: "sound"
nextValue:
@ -150,6 +152,7 @@ HTile {
}
NotificationRuleButton {
requiresOn: notifyButton
icon.name: "pushrule-action-urgency-hint"
toggles: "urgency_hint"
}