Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications: Don't display 'acknowledge all' after clicking 'silenc… #1349

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ set (VENUS_QML_MODULE_SOURCES
components/LoadGraphShapePath.qml
components/NavBar.qml
components/NavButton.qml
components/NotificationButton.qml
components/NotificationDelegate.qml
components/ObjectModelMonitor.qml
components/Page.qml
Expand Down
32 changes: 32 additions & 0 deletions components/NotificationButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
** Copyright (C) 2024 Victron Energy B.V.
** See LICENSE.txt for license information.
*/

import QtQuick
import Victron.VenusOS

Button {
id: root

property alias contentItemChildren: row.children

anchors {
right: parent ? parent.rightSideRow.right : undefined
verticalCenter: parent.verticalCenter
}
parent: !!Global.pageManager ? Global.pageManager.statusBar : undefined
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The button used to be parented to Global.pageManager.statusBar.rightSideRow, I had to change to to Global.pageManager.statusBar and anchor it to the RHS of Global.pageManager.statusBar.rightSideRow, as Row doesn't re-layout itself in a timely manner when its children's visibility changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if other buttons (aside from Display Sleep etc) get added to the rightSideRow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to add other stuff to rightSideRow, we will have to revisit this. It would depend how the new button is supposed to behave.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about moving the buttons to StatusBar.qml and defining the NotificationButton component inline (like how StatusBarButton is defined there)? That way the buttons are defined directly within the layout in StatusBar.qml, and we wouldn't need awkward alias properties like Global.pageManager.statusBar.rightSideRow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as suggested.

leftPadding: Theme.geometry_silenceAlarmButton_horizontalPadding
rightPadding: Theme.geometry_silenceAlarmButton_horizontalPadding
height: Theme.geometry_notificationsPage_snoozeButton_height
radius: Theme.geometry_button_radius
opacity: enabled ? 1 : 0
Behavior on opacity { OpacityAnimator { duration: Theme.animation_toastNotification_fade_duration } }

contentItem: Row {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Button already supports showing an icon and text side-by-side, so it should be possible to do:

NotificationButton {
    icon.source: "qrc:/images/icon_alarm_snooze_24.svg"
    text: "Silence alarm"
}

instead of overriding the contentItem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated as suggested

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the side effect of the button text color changing while the button is pressed, as per our default Button behaviour. Looks ok to me.

id: row

anchors.verticalCenter: parent.verticalCenter
spacing: Theme.geometry_notificationsPage_snoozeButton_spacing
}
}
47 changes: 23 additions & 24 deletions pages/NotificationsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -161,40 +161,39 @@ SwipeViewPage {
delegate: NotificationDelegate {}
}

Button {
parent: !!Global.pageManager ? Global.pageManager.statusBar.rightSideRow : root
leftPadding: Theme.geometry_silenceAlarmButton_horizontalPadding
rightPadding: Theme.geometry_silenceAlarmButton_horizontalPadding
height: Theme.geometry_notificationsPage_snoozeButton_height
radius: Theme.geometry_button_radius

enabled: !!Global.notifications && (Global.notifications.alarm || Global.notifications.alert) && root.isCurrentPage
opacity: enabled ? 1 : 0
Behavior on opacity { OpacityAnimator { duration: Theme.animation_toastNotification_fade_duration} }
backgroundColor: Global.notifications.alarm ? Theme.color_critical_background : Theme.color_warning

contentItem: Row {
NotificationButton {
enabled: root.isCurrentPage && !!Global.notifications && Global.notifications.alert && !alarmButton.enabled
backgroundColor: Theme.color_warning

contentItemChildren: Label {
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.geometry_notificationsPage_snoozeButton_spacing
font.pixelSize: Theme.font_size_caption
//% "Acknowledge alerts"
text: qsTrId("notifications_acknowledge_alerts")
}

onClicked: Global.notifications.acknowledgeAll()
}

NotificationButton {
id: alarmButton

enabled: root.isCurrentPage && !!Global.notifications && Global.notifications.alarm
backgroundColor: Theme.color_critical_background

contentItemChildren: [
CP.ColorImage {
anchors.verticalCenter: parent.verticalCenter
visible: Global.notifications.alarm
source: "qrc:/images/icon_alarm_snooze_24.svg"
color: Theme.color_font_primary
}

},
Label {
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: Theme.font_size_caption
text: Global.notifications.alarm
//% "Silence alarm"
? qsTrId("notifications_silence_alarm")
//% "Acknowledge alerts"
: qsTrId("notifications_acknowledge_alerts")
//% "Silence alarm"
text: qsTrId("notifications_silence_alarm")
}
}

]
onClicked: Global.notifications.acknowledgeAll()
}
}