diff --git a/ApplicationContent.qml b/ApplicationContent.qml index ebe13bf33..b0f29f709 100644 --- a/ApplicationContent.qml +++ b/ApplicationContent.qml @@ -50,7 +50,7 @@ Item { ScreenBlanker { id: screenBlanker - enabled: !Global.splashScreenVisible && !(!!Global.notifications && Global.notifications.alert) + enabled: !Global.splashScreenVisible && !(!!Global.pageManager && Global.pageManager.statusBar.notificationButtonVisible) displayOffTime: displayOffItem.isValid ? 1000*displayOffItem.value : 0.0 property VeQuickItem displayOffItem: VeQuickItem { uid: !!Global.systemSettings ? Global.systemSettings.serviceUid + "/Settings/Gui/DisplayOff" : "" diff --git a/components/StatusBar.qml b/components/StatusBar.qml index 197d47505..c93f6ff08 100644 --- a/components/StatusBar.qml +++ b/components/StatusBar.qml @@ -14,7 +14,8 @@ Rectangle { property int leftButton: VenusOS.StatusBar_LeftButton_None property int rightButton: VenusOS.StatusBar_RightButton_None - property alias rightSideRow: rightSideRow + readonly property bool notificationButtonsEnabled: Global.mainView.currentPage && Global.mainView.currentPage.url.endsWith("NotificationsPage.qml") + readonly property bool notificationButtonVisible: alertButton.enabled || alertButton.animating || alarmButton.enabled || alarmButton.animating property bool animationEnabled @@ -55,6 +56,26 @@ Rectangle { } } + component NotificationButton : Button { + readonly property bool animating: animator.running + + 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 + font.family: Global.fontFamily + font.pixelSize: Theme.font_size_caption + Behavior on opacity { + OpacityAnimator { + id: animator + + duration: Theme.animation_toastNotification_fade_duration + } + } + } + + StatusBarButton { id: leftButton @@ -90,6 +111,36 @@ Rectangle { rightMargin: Theme.geometry_statusBar_rightSideRow_horizontalMargin verticalCenter: parent.verticalCenter } + width: Math.max(20, implicitWidth) + } + + NotificationButton { + id: alertButton + + anchors { + right: rightSideRow.right + verticalCenter: parent.verticalCenter + } + enabled: notificationButtonsEnabled && !!Global.notifications && Global.notifications.alert && !alarmButton.enabled + backgroundColor: Theme.color_warning + //% "Acknowledge alerts" + text: qsTrId("notifications_acknowledge_alerts") + onClicked: Global.notifications.acknowledgeAll() + } + + NotificationButton { + id: alarmButton + + anchors { + right: rightSideRow.right + verticalCenter: parent.verticalCenter + } + enabled: notificationButtonsEnabled && !!Global.notifications && Global.notifications.alarm + backgroundColor: Theme.color_critical_background + icon.source: "qrc:/images/icon_alarm_snooze_24.svg" + //% "Silence alarm" + text: qsTrId("notifications_silence_alarm") + onClicked: Global.notifications.acknowledgeAll() } Row { diff --git a/pages/NotificationsPage.qml b/pages/NotificationsPage.qml index fddf9b257..2205be147 100644 --- a/pages/NotificationsPage.qml +++ b/pages/NotificationsPage.qml @@ -160,41 +160,4 @@ SwipeViewPage { spacing: Theme.geometry_gradientList_spacing 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 { - anchors.verticalCenter: parent.verticalCenter - spacing: Theme.geometry_notificationsPage_snoozeButton_spacing - - 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") - } - } - - onClicked: Global.notifications.acknowledgeAll() - } }