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 { HButton {
property string toggles: "" property string toggles: ""
property var nextValue: ! on 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 && page.pendingEdits[model.id] &&
toggles in page.pendingEdits[model.id] ? toggles in page.pendingEdits[model.id] ?
Boolean(page.pendingEdits[model.id][toggles]) : Boolean(page.pendingEdits[model.id][toggles]) :
@ -16,13 +17,20 @@ HButton {
Boolean(model[toggles]) : Boolean(model[toggles]) :
true true
)
opacity: on ? 1 : theme.disabledElementsOpacity opacity: on ? 1 : theme.disabledElementsOpacity
hoverEnabled: true hoverEnabled: true
backgroundColor: "transparent" backgroundColor: "transparent"
onClicked: { onClicked: {
if (requiresOn !== null && ! requiresOn.on) {
requiresOn.clicked()
print(on, clicked)
if (! on) clicked()
return
}
if (! toggles) return if (! toggles) return
if (! (model.id in page.pendingEdits)) page.pendingEdits[model.id] = {} if (! (model.id in page.pendingEdits)) page.pendingEdits[model.id] = {}

View File

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