Port away from qt5compat graphical effects

This commit is contained in:
Bart De Vries 2023-12-09 16:12:29 +01:00
parent 264a1ff974
commit 866d111049
7 changed files with 93 additions and 107 deletions

View File

@ -8,8 +8,8 @@
import QtQuick
import QtQuick.Controls as Controls
import QtQuick.Layouts
import QtQuick.Effects
import QtQml.Models
import Qt5Compat.GraphicalEffects
import org.kde.kirigami as Kirigami
import org.kde.kmediasession
@ -79,27 +79,25 @@ FocusScope {
Component {
id: backgroundImageComponent
ImageWithFallback {
id: backgroundImage
MultiEffect {
source: backgroundImage
anchors.fill: parent
imageSource: headerMetaData.blurredImage
imageResize: false // no "stuttering" on resizing the window
brightness: -0.3
saturation: 0.6
contrast: -0.5
blurMax: 64
blur: 1.0
blurEnabled: true
autoPaddingEnabled: false
opacity: handlePosition > 0 ? 1 : 0
ImageWithFallback {
id: backgroundImage
layer.enabled: true
layer.effect: HueSaturation {
cached: true
lightness: -0.6
saturation: 0.9
layer.enabled: true
layer.effect: FastBlur {
cached: true
radius: 64
transparentBorder: false
}
visible: false
imageSource: headerMetaData.blurredImage
imageResize: false // no "stuttering" on resizing the window
anchors.fill: parent
}
}
}

View File

@ -8,8 +8,8 @@
import QtQuick
import QtQuick.Controls as Controls
import QtQuick.Layouts
import QtQuick.Effects
import QtQml.Models
import Qt5Compat.GraphicalEffects
import org.kde.kirigami as Kirigami
@ -96,7 +96,6 @@ Controls.ItemDelegate {
id: mouseArea
anchors.fill: parent
anchors.margins: cardMargin + borderWidth
anchors.leftMargin: cardMargin + borderWidth
implicitWidth: cardSize - 2 * borderWidth
implicitHeight: cardSize - 2 * borderWidth
@ -167,6 +166,7 @@ Controls.ItemDelegate {
imageSource: feed.cachedImage
imageTitle: feed.name
isLoading: feed.refreshing
absoluteRadius: Kirigami.Units.smallSpacing + borderWidth
}
Rectangle {
@ -209,21 +209,6 @@ Controls.ItemDelegate {
icon.color: "white"
onClicked: actionOverlay.open()
}
// Rounded edges
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Item {
width: img.width
height: img.height
Rectangle {
anchors.centerIn: parent
width: img.adapt ? img.width : Math.min(img.width, img.height)
height: img.adapt ? img.height : width
radius: Kirigami.Units.smallSpacing - borderWidth
}
}
}
}
onClicked: {

View File

@ -7,7 +7,7 @@
import QtQuick
import QtQuick.Controls as Controls
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import QtQuick.Effects
import org.kde.kirigami as Kirigami
@ -29,25 +29,25 @@ Item {
implicitHeight: headerHeight
implicitWidth: parent.width
ImageWithFallback {
MultiEffect {
id: backgroundImage
source: backgroundImageRaw
anchors.fill: parent
imageSource: image
imageResize: false // no "stuttering" on resizing the window
layer.enabled: true
layer.effect: HueSaturation {
cached: true
brightness: -0.15
saturation: 0.6
contrast: -0.4
blurMax: 64
blur: 1.0
blurEnabled: true
autoPaddingEnabled: false
lightness: -0.3
saturation: 0.9
layer.enabled: true
layer.effect: FastBlur {
cached: true
radius: 64
transparentBorder: false
}
ImageWithFallback {
id: backgroundImageRaw
anchors.fill: parent
visible: false
imageSource: image
imageResize: false // no "stuttering" on resizing the window
}
}

View File

@ -7,7 +7,7 @@
import QtQuick
import QtQuick.Controls as Controls
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import QtQuick.Effects
import QtQuick.Window
import org.kde.kirigami as Kirigami
@ -29,19 +29,23 @@ Item {
Loader {
id: imageLoader
anchors.fill: parent
visible: false
sourceComponent: (imageSource === "no-image" || imageSource === "") ? fallbackImg : (imageSource === "fetching" ? loaderSymbol : realImg )
}
MultiEffect {
anchors.fill: parent
source: imageLoader.item
opacity: root.imageOpacity
layer.enabled: (root.absoluteRadius > 0 || root.fractionalRadius > 0)
layer.effect: OpacityMask {
maskSource: Item {
width: imageLoader.width
height: imageLoader.height
Rectangle {
anchors.centerIn: parent
width: imageLoader.adapt ? imageLoader.width : Math.min(imageLoader.width, imageLoader.height)
height: imageLoader.adapt ? imageLoader.height : width
radius: (absoluteRadius > 0) ? absoluteRadius : ( (fractionalRadius > 0) ? Math.min(width, height)*fractionalRadius : 0 )
}
maskEnabled: true
maskSource: ShaderEffectSource {
width: imageLoader.width
height: imageLoader.height
sourceItem: Rectangle {
anchors.centerIn: parent
width: imageLoader.adapt ? imageLoader.width : Math.min(imageLoader.width, imageLoader.height)
height: imageLoader.adapt ? imageLoader.height : width
radius: (absoluteRadius > 0) ? absoluteRadius : ( (fractionalRadius > 0) ? Math.min(width, height)*fractionalRadius : 0 )
}
}
}

View File

@ -8,7 +8,7 @@
import QtQuick
import QtQuick.Controls as Controls
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import QtQuick.Effects
import org.kde.kirigami as Kirigami
@ -119,27 +119,25 @@ Flickable {
Layout.fillWidth: true
padding: 0
background: Image {
opacity: 0.2
source: AudioManager.entry.cachedImage
asynchronous: true
background: MultiEffect {
source: backgroundImage
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
layer.enabled: true
layer.effect: HueSaturation {
cached: true
brightness: 0.55
saturation: -0.4
contrast: -0.7
blurMax: 64
blur: 1.0
blurEnabled: true
autoPaddingEnabled: false
lightness: 0.7
saturation: 0.9
layer.enabled: true
layer.effect: FastBlur {
cached: true
radius: 64
transparentBorder: false
}
Image {
id: backgroundImage
source: AudioManager.entry.cachedImage
asynchronous: true
visible: false
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
}
}

View File

@ -8,7 +8,7 @@
import QtQuick
import QtQuick.Controls as Controls
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import QtQuick.Effects
import org.kde.kirigami as Kirigami
import org.kde.kmediasession
@ -43,27 +43,25 @@ Kirigami.Page {
}
}
background: Image {
opacity: 0.2
source: AudioManager.entry.cachedImage
asynchronous: true
background: MultiEffect {
source: backgroundImage
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
layer.enabled: true
layer.effect: HueSaturation {
cached: true
brightness: 0.55
saturation: -0.4
contrast: -0.7
blurMax: 64
blur: 1.0
blurEnabled: true
autoPaddingEnabled: false
lightness: 0.7
saturation: 0.9
layer.enabled: true
layer.effect: FastBlur {
cached: true
radius: 100
transparentBorder: false
}
Image {
id: backgroundImage
source: AudioManager.entry.cachedImage
asynchronous: true
visible: false
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
}
}

View File

@ -8,8 +8,8 @@
import QtQuick
import QtQuick.Controls as Controls
import QtQuick.Layouts
import QtQuick.Effects
import QtCore
import Qt5Compat.GraphicalEffects
import org.kde.kirigami as Kirigami
@ -312,14 +312,17 @@ Kirigami.ApplicationWindow {
active: footer.active && !footerLoader.active
anchors.fill: footer
sourceComponent: RectangularGlow {
glowRadius: 5
spread: 0.3
color: Qt.rgba(0.0, 0.0, 0.0, 0.1)
sourceComponent: MultiEffect {
source: bottomToolbarLoader
shadowEnabled: true
shadowScale: 1.1
blurMax: 10
shadowColor: Qt.rgba(0.0, 0.0, 0.0, 0.1)
}
}
footer: Loader {
id: bottomToolbarLoader
visible: active
height: visible ? implicitHeight : 0
active: Kirigami.Settings.isMobile && !kastsMainWindow.isWidescreen