shift-shell/components/mobileshell/qml/widgets/mediacontrols/BlurredBackground.qml
Micah Stanley 7e2019cb0e MobileShell: Unify Item Background Elements
We so far have been recreating the background elements for all the item throughout the shell. This merge request simplifies this by unifying these elements into a single component, making is easier to keep things at a consistent design while also being able to adjust things when needed in the future.

Per request, I tried to keep thing looking mostly the same as before.

The first picture is what the action drawer looks like now, the one after is with these changes.

![Screenshot_20250621_154201](/uploads/7bd5129d942c8fbc3706dd1728b3a1dd/Screenshot_20250621_154201.png)
![Screenshot_20250621_155520](/uploads/9d2e925c9483579dec765813465e4d2d/Screenshot_20250621_155520.png)
2025-06-22 20:16:16 -04:00

69 lines
1.6 KiB
QML

// SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick
import QtQuick.Effects
import Qt5Compat.GraphicalEffects
import org.kde.kirigami 2.20 as Kirigami
Item {
id: root
property string imageSource
property bool darken: false
property bool inActionDrawer: false
// clip corners so that the image has rounded corners
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Item {
width: img.width
height: img.height
Rectangle {
anchors.centerIn: parent
width: img.width
height: img.height
radius: Kirigami.Units.cornerRadius
}
}
}
// darken background when pressed
Rectangle {
anchors.fill: parent
color: "black"
opacity: root.darken ? 0.05 : 0
}
Image {
id: img
source: root.imageSource
asynchronous: true
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
// ensure text is readable
Rectangle {
anchors.fill: parent
color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.2)
visible: img.progress
}
opacity: 0.1
// apply lighten, saturate and blur effect
layer.enabled: true
layer.effect: MultiEffect {
brightness: 0.075
blurEnabled: true
blurMax: 32
blur: 1.0
blurMultiplier: 2
autoPaddingEnabled: false
}
}
}