1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 07:22:50 -05:00

wrap shaders in a loader

This commit is contained in:
bbedward
2025-09-25 23:33:57 -04:00
parent 066d1847e4
commit c7b4e2c49d

View File

@@ -77,7 +77,6 @@ LazyLoader {
monitor: modelData.name monitor: modelData.name
} }
Component.onDestruction: { Component.onDestruction: {
weProc.stop() weProc.stop()
} }
@@ -116,8 +115,10 @@ LazyLoader {
} }
function changeWallpaper(newPath, force) { function changeWallpaper(newPath, force) {
if (!force && newPath === currentWallpaper.source) return if (!force && newPath === currentWallpaper.source)
if (!newPath || newPath.startsWith("#")) return return
if (!newPath || newPath.startsWith("#"))
return
if (root.transitioning) { if (root.transitioning) {
transitionAnimation.stop() transitionAnimation.stop()
@@ -163,7 +164,6 @@ LazyLoader {
} }
} }
Loader { Loader {
anchors.fill: parent anchors.fill: parent
active: !root.source || root.isColorSource active: !root.source || root.isColorSource
@@ -212,15 +212,14 @@ LazyLoader {
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
onStatusChanged: { onStatusChanged: {
if (status !== Image.Ready) return if (status !== Image.Ready)
return
if (root.actualTransitionType === "none") { if (root.actualTransitionType === "none") {
currentWallpaper.source = source currentWallpaper.source = source
nextWallpaper.source = "" nextWallpaper.source = ""
root.transitionProgress = 0.0 root.transitionProgress = 0.0
} else { } else {
currentWallpaper.layer.enabled = true
layer.enabled = true
visible = true visible = true
if (!root.transitioning) { if (!root.transitioning) {
transitionAnimation.start() transitionAnimation.start()
@@ -229,166 +228,185 @@ LazyLoader {
} }
} }
ShaderEffect { Loader {
id: fadeShader id: effectLoader
anchors.fill: parent anchors.fill: parent
visible: root.actualTransitionType === "fade" && (root.hasCurrent || root.booting) active: root.actualTransitionType !== "none" && (root.hasCurrent || root.booting)
sourceComponent: {
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource switch (root.actualTransitionType) {
property variant source2: nextWallpaper case "fade":
property real progress: root.transitionProgress return fadeComp
property real fillMode: root.fillMode case "wipe":
property vector4d fillColor: root.fillColor return wipeComp
property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) case "disc":
property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) return discComp
property real imageWidth2: Math.max(1, source2.sourceSize.width) case "stripes":
property real imageHeight2: Math.max(1, source2.sourceSize.height) return stripesComp
property real screenWidth: modelData.width case "iris bloom":
property real screenHeight: modelData.height return irisComp
case "pixelate":
fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_fade.frag.qsb") return pixelateComp
case "portal":
return portalComp
default:
return null
}
}
} }
ShaderEffect { Component {
id: wipeShader id: fadeComp
anchors.fill: parent ShaderEffect {
visible: root.actualTransitionType === "wipe" && (root.hasCurrent || root.booting) anchors.fill: parent
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source2: nextWallpaper
property variant source2: nextWallpaper property real progress: root.transitionProgress
property real progress: root.transitionProgress property real fillMode: root.fillMode
property real smoothness: root.edgeSmoothness property vector4d fillColor: root.fillColor
property real direction: root.wipeDirection property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width)
property real fillMode: root.fillMode property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height)
property vector4d fillColor: root.fillColor property real imageWidth2: Math.max(1, source2.sourceSize.width)
property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) property real imageHeight2: Math.max(1, source2.sourceSize.height)
property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) property real screenWidth: modelData.width
property real imageWidth2: Math.max(1, source2.sourceSize.width) property real screenHeight: modelData.height
property real imageHeight2: Math.max(1, source2.sourceSize.height) fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_fade.frag.qsb")
property real screenWidth: modelData.width }
property real screenHeight: modelData.height
fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_wipe.frag.qsb")
} }
ShaderEffect { Component {
id: discShader id: wipeComp
anchors.fill: parent ShaderEffect {
visible: root.actualTransitionType === "disc" && (root.hasCurrent || root.booting) anchors.fill: parent
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source2: nextWallpaper
property variant source2: nextWallpaper property real progress: root.transitionProgress
property real progress: root.transitionProgress property real smoothness: root.edgeSmoothness
property real smoothness: root.edgeSmoothness property real direction: root.wipeDirection
property real aspectRatio: root.width / root.height property real fillMode: root.fillMode
property real centerX: root.discCenterX property vector4d fillColor: root.fillColor
property real centerY: root.discCenterY property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width)
property real fillMode: root.fillMode property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height)
property vector4d fillColor: root.fillColor property real imageWidth2: Math.max(1, source2.sourceSize.width)
property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) property real imageHeight2: Math.max(1, source2.sourceSize.height)
property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) property real screenWidth: modelData.width
property real imageWidth2: Math.max(1, source2.sourceSize.width) property real screenHeight: modelData.height
property real imageHeight2: Math.max(1, source2.sourceSize.height) fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_wipe.frag.qsb")
property real screenWidth: modelData.width }
property real screenHeight: modelData.height
fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_disc.frag.qsb")
} }
ShaderEffect { Component {
id: stripesShader id: discComp
anchors.fill: parent ShaderEffect {
visible: root.actualTransitionType === "stripes" && (root.hasCurrent || root.booting) anchors.fill: parent
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source2: nextWallpaper
property variant source2: nextWallpaper property real progress: root.transitionProgress
property real progress: root.transitionProgress property real smoothness: root.edgeSmoothness
property real smoothness: root.edgeSmoothness property real aspectRatio: root.width / root.height
property real aspectRatio: root.width / root.height property real centerX: root.discCenterX
property real stripeCount: root.stripesCount property real centerY: root.discCenterY
property real angle: root.stripesAngle property real fillMode: root.fillMode
property real fillMode: root.fillMode property vector4d fillColor: root.fillColor
property vector4d fillColor: root.fillColor property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width)
property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height)
property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) property real imageWidth2: Math.max(1, source2.sourceSize.width)
property real imageWidth2: Math.max(1, source2.sourceSize.width) property real imageHeight2: Math.max(1, source2.sourceSize.height)
property real imageHeight2: Math.max(1, source2.sourceSize.height) property real screenWidth: modelData.width
property real screenWidth: modelData.width property real screenHeight: modelData.height
property real screenHeight: modelData.height fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_disc.frag.qsb")
}
fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_stripes.frag.qsb")
} }
ShaderEffect { Component {
id: irisBloomShader id: stripesComp
anchors.fill: parent ShaderEffect {
visible: root.actualTransitionType === "iris bloom" && (root.hasCurrent || root.booting) anchors.fill: parent
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source2: nextWallpaper
property variant source2: nextWallpaper property real progress: root.transitionProgress
property real progress: root.transitionProgress property real smoothness: root.edgeSmoothness
property real smoothness: root.edgeSmoothness property real aspectRatio: root.width / root.height
property real centerX: 0.5 property real stripeCount: root.stripesCount
property real centerY: 0.5 property real angle: root.stripesAngle
property real aspectRatio: root.width / root.height property real fillMode: root.fillMode
property real fillMode: root.fillMode property vector4d fillColor: root.fillColor
property vector4d fillColor: root.fillColor property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width)
property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height)
property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) property real imageWidth2: Math.max(1, source2.sourceSize.width)
property real imageWidth2: Math.max(1, source2.sourceSize.width) property real imageHeight2: Math.max(1, source2.sourceSize.height)
property real imageHeight2: Math.max(1, source2.sourceSize.height) property real screenWidth: modelData.width
property real screenWidth: modelData.width property real screenHeight: modelData.height
property real screenHeight: modelData.height fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_stripes.frag.qsb")
}
fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_iris_bloom.frag.qsb")
} }
ShaderEffect { Component {
id: pixelateShader id: irisComp
anchors.fill: parent ShaderEffect {
visible: root.actualTransitionType === "pixelate" && (root.hasCurrent || root.booting) anchors.fill: parent
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source2: nextWallpaper
property variant source2: nextWallpaper property real progress: root.transitionProgress
property real progress: root.transitionProgress property real smoothness: root.edgeSmoothness
property real smoothness: root.edgeSmoothness // controls starting block size property real centerX: 0.5
property real fillMode: root.fillMode property real centerY: 0.5
property vector4d fillColor: root.fillColor property real aspectRatio: root.width / root.height
property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) property real fillMode: root.fillMode
property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) property vector4d fillColor: root.fillColor
property real imageWidth2: Math.max(1, source2.sourceSize.width) property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width)
property real imageHeight2: Math.max(1, source2.sourceSize.height) property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height)
property real screenWidth: modelData.width property real imageWidth2: Math.max(1, source2.sourceSize.width)
property real screenHeight: modelData.height property real imageHeight2: Math.max(1, source2.sourceSize.height)
property real centerX: root.discCenterX property real screenWidth: modelData.width
property real centerY: root.discCenterY property real screenHeight: modelData.height
property real aspectRatio: root.width / root.height fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_iris_bloom.frag.qsb")
}
fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_pixelate.frag.qsb")
} }
ShaderEffect { Component {
id: portalShader id: pixelateComp
anchors.fill: parent ShaderEffect {
visible: root.actualTransitionType === "portal" && (root.hasCurrent || root.booting) anchors.fill: parent
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source2: nextWallpaper
property real progress: root.transitionProgress
property real smoothness: root.edgeSmoothness
property real fillMode: root.fillMode
property vector4d fillColor: root.fillColor
property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width)
property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height)
property real imageWidth2: Math.max(1, source2.sourceSize.width)
property real imageHeight2: Math.max(1, source2.sourceSize.height)
property real screenWidth: modelData.width
property real screenHeight: modelData.height
property real centerX: root.discCenterX
property real centerY: root.discCenterY
property real aspectRatio: root.width / root.height
fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_pixelate.frag.qsb")
}
}
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource Component {
property variant source2: nextWallpaper id: portalComp
property real progress: root.transitionProgress ShaderEffect {
property real smoothness: root.edgeSmoothness anchors.fill: parent
property real aspectRatio: root.width / root.height property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property real centerX: root.discCenterX property variant source2: nextWallpaper
property real centerY: root.discCenterY property real progress: root.transitionProgress
property real fillMode: root.fillMode property real smoothness: root.edgeSmoothness
property vector4d fillColor: root.fillColor property real aspectRatio: root.width / root.height
property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) property real centerX: root.discCenterX
property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) property real centerY: root.discCenterY
property real imageWidth2: Math.max(1, source2.sourceSize.width) property real fillMode: root.fillMode
property real imageHeight2: Math.max(1, source2.sourceSize.height) property vector4d fillColor: root.fillColor
property real screenWidth: modelData.width property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width)
property real screenHeight: modelData.height property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height)
property real imageWidth2: Math.max(1, source2.sourceSize.width)
fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_portal.frag.qsb") property real imageHeight2: Math.max(1, source2.sourceSize.height)
property real screenWidth: modelData.width
property real screenHeight: modelData.height
fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_portal.frag.qsb")
}
} }
NumberAnimation { NumberAnimation {
@@ -401,16 +419,14 @@ LazyLoader {
easing.type: Easing.InOutCubic easing.type: Easing.InOutCubic
onFinished: { onFinished: {
Qt.callLater(() => { Qt.callLater(() => {
if (nextWallpaper.source && nextWallpaper.status === Image.Ready && !nextWallpaper.source.toString().startsWith("#")) { if (nextWallpaper.source && nextWallpaper.status === Image.Ready && !nextWallpaper.source.toString().startsWith("#")) {
currentWallpaper.source = nextWallpaper.source currentWallpaper.source = nextWallpaper.source
} }
nextWallpaper.source = "" nextWallpaper.source = ""
nextWallpaper.visible = false nextWallpaper.visible = false
currentWallpaper.visible = root.actualTransitionType === "none" currentWallpaper.visible = root.actualTransitionType === "none"
currentWallpaper.layer.enabled = false root.transitionProgress = 0.0
nextWallpaper.layer.enabled = false })
root.transitionProgress = 0.0
})
} }
} }
} }