actiondrawer: Reduce background opacity if no notifications are shown

This commit is contained in:
Devin Lin 2021-12-27 19:13:35 -05:00
parent 7adea6fd3d
commit 484e088508
3 changed files with 16 additions and 2 deletions

View file

@ -39,7 +39,12 @@ PlasmaCore.ColorScope {
// fullscreen background
Rectangle {
anchors.fill: parent
color: Qt.rgba(PlasmaCore.Theme.backgroundColor.r, PlasmaCore.Theme.backgroundColor.g, PlasmaCore.Theme.backgroundColor.b, 0.95)
// darken if there are notifications
color: Qt.rgba(PlasmaCore.Theme.backgroundColor.r,
PlasmaCore.Theme.backgroundColor.g,
PlasmaCore.Theme.backgroundColor.b,
notificationWidget.hasNotifications ? 0.95 : 0.7)
Behavior on color { ColorAnimation { duration: PlasmaCore.Units.longDuration } }
opacity: Math.max(0, Math.min(1, actionDrawer.offset / root.minimizedQuickSettingsOffset))
}
@ -89,6 +94,7 @@ PlasmaCore.ColorScope {
}
Widgets.NotificationsWidget {
id: notificationWidget
// don't allow notifications widget to get too wide
Layout.maximumWidth: PlasmaCore.Units.gridUnit * 25
Layout.fillHeight: true

View file

@ -36,7 +36,12 @@ PlasmaCore.ColorScope {
// fullscreen background
Rectangle {
anchors.fill: parent
color: Qt.rgba(PlasmaCore.Theme.backgroundColor.r, PlasmaCore.Theme.backgroundColor.g, PlasmaCore.Theme.backgroundColor.b, 0.95)
// darken if there are notifications
color: Qt.rgba(PlasmaCore.Theme.backgroundColor.r,
PlasmaCore.Theme.backgroundColor.g,
PlasmaCore.Theme.backgroundColor.b,
notificationWidget.hasNotifications ? 0.95 : 0.7)
Behavior on color { ColorAnimation { duration: PlasmaCore.Units.longDuration } }
opacity: Math.max(0, Math.min(1, actionDrawer.offset / root.minimizedQuickSettingsOffset))
}
@ -72,6 +77,7 @@ PlasmaCore.ColorScope {
}
Widgets.NotificationsWidget {
id: notificationWidget
anchors {
top: quickSettings.top
topMargin: quickSettings.height + translate.y

View file

@ -31,6 +31,8 @@ Item {
property var historyModel: MobileShell.NotificationProvider.historyModel
property var notificationSettings: MobileShell.NotificationProvider.notificationSettings
readonly property bool hasNotifications: list.count > 0
function clearHistory() {
historyModel.clear(NotificationManager.Notifications.ClearExpired);
}