Skip to content

Commit

Permalink
Notifications: Don't display 'acknowledge all' after clicking 'silenc…
Browse files Browse the repository at this point in the history
…e alarm'

Fixes #1348
  • Loading branch information
DanielMcInnes committed Aug 6, 2024
1 parent 66ed44b commit a25aaab
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 24 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,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
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 {
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()
}
}

0 comments on commit a25aaab

Please sign in to comment.