Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,26 @@ Item {
required property string imageSource

property string transitionType: Config.options.background.transitionType ?? "radial"

property int animationDuration: transitionType === "radial" ? 1100 : 1000
readonly property var effectFiles: ({
radial: "Radial.qml",
crossfade: "Crossfade.qml",
wipe: "Wipe.qml",
diamond: "Diamond.qml",
slash: "Slash.qml",
outer: "Outer.qml",
wave: "Wave.qml",
fade: "Fade.qml",
doom: "Doom.qml",
magic: "Magic.qml",
peel: "Peel.qml",
pixelate: "Pixelate.qml",
stripes: "Stripes.qml"
})
readonly property list<string> randomTransitions: ["fade", "doom", "magic", "peel", "pixelate", "stripes"]
readonly property string fallbackTransition: "Fade"
property string activeTransitionType: "radial"

property int animationDuration: activeTransitionType === "radial" ? 1100 : 1000
property var fillMode: Image.PreserveAspectCrop
property bool animated: Config.options.background.animateWallpaperChanges

Expand All @@ -38,13 +56,21 @@ Item {

property string currentWallpaper: ""

function resolveTransitionType(requested) {
if (requested === "random") {
return root.randomTransitions[Math.floor(Math.random() * root.randomTransitions.length)]
}
return root.effectFiles[requested] ? requested : "fade"
}

function fadeTo(newSrc) {
if (!newSrc || newSrc === currentWallpaper) return

let hasWallpaper = (currentWallpaper !== "")

if (root.animated && ready && root.width > 0 && root.height > 0 && hasWallpaper) {
cleanupTransition()
root.activeTransitionType = resolveTransitionType(root.transitionType)

// Flip AT THE START so frontImg is ALWAYS the new image with z=1
root.imgAIsBack = !root.imgAIsBack
Expand All @@ -53,11 +79,6 @@ Item {
frontImg.source = newSrc
currentWallpaper = newSrc

let wait = effectLoader.item ? effectLoader.item.waitForReady !== false : true

if (!wait || frontImg.status === Image.Ready) {
startTransition()
}
} else {
cleanupTransition()
root.imgAIsBack = !root.imgAIsBack
Expand All @@ -76,18 +97,18 @@ Item {
}

function cleanupTransition() {
root.transitionActive = false
if (effectLoader.item && typeof effectLoader.item.cleanup === "function") {
effectLoader.item.cleanup()
}
root.transitionActive = false
}

Image {
id: imgA
anchors.fill: parent
// Visible if backImg OR (if frontImg and no hideFront requested during transition)
visible: root.imgAIsBack || (!root.transitionActive || !effectLoader.item || effectLoader.item.hideFront === false)
layer.enabled: !visible && root.transitionActive
layer.enabled: root.transitionActive
z: root.imgAIsBack ? 0 : 1

fillMode: root.fillMode
Expand All @@ -111,7 +132,7 @@ Item {
id: imgB
anchors.fill: parent
visible: !root.imgAIsBack || (!root.transitionActive || !effectLoader.item || effectLoader.item.hideFront === false)
layer.enabled: !visible && root.transitionActive
layer.enabled: root.transitionActive
z: !root.imgAIsBack ? 0 : 1

fillMode: root.fillMode
Expand All @@ -134,12 +155,18 @@ Item {
Loader {
id: effectLoader
anchors.fill: parent
source: "transitions/" + (root.transitionType.charAt(0).toUpperCase() + root.transitionType.slice(1)) + ".qml"
active: root.transitionActive
asynchronous: false
source: active ? "transitions/" + (root.effectFiles[root.activeTransitionType] ?? (root.fallbackTransition + ".qml")) : ""

onLoaded: {
item.frontImg = Qt.binding(function() { return root.frontImg })
item.backImg = Qt.binding(function() { return root.backImg })
item.duration = Qt.binding(function() { return root.animationDuration })
const wait = item.waitForReady !== false
if (root.transitionActive && (!wait || root.frontImg.status === Image.Ready)) {
root.startTransition()
}
}

Connections {
Expand All @@ -149,4 +176,4 @@ Item {
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import QtQuick
import "." as LocalTransitions
LocalTransitions.ForkShaderTransition { shaderFile: "Doom.frag.qsb" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import QtQuick
import "." as LocalTransitions
LocalTransitions.ForkShaderTransition { shaderFile: "transition.frag.qsb" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import QtQuick

// Ported and adapted from https://github.com/pctrade/end4-pC.
Item {
id: effect
property Item frontImg
property Item backImg
property int duration: 1200
required property string shaderFile
property bool hideFront: true
property bool waitForReady: true
signal finished()

function start() {
shader.progress = 0
shader.visible = true
progressAnimation.restart()
}

function cleanup() {
progressAnimation.stop()
shader.visible = false
shader.progress = 0
}

NumberAnimation {
id: progressAnimation
target: shader
property: "progress"
from: 0
to: 1
duration: effect.duration
easing.type: Easing.InOutCubic
onFinished: effect.finished()
}

ShaderEffect {
id: shader
anchors.fill: parent
visible: false
property var fromImage: effect.backImg
property var toImage: effect.frontImg
property real progress: 0
property real aspectX: width / height
property real aspectY: 1
property vector2d aspectRatio: Qt.vector2d(aspectX, aspectY)
property vector2d origin: Qt.vector2d(0.5, 0.5)
fragmentShader: Qt.resolvedUrl("shaders/" + effect.shaderFile)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import QtQuick
import "." as LocalTransitions
LocalTransitions.ForkShaderTransition { shaderFile: "magic.frag.qsb" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import QtQuick
import "." as LocalTransitions
LocalTransitions.ForkShaderTransition { shaderFile: "Peel.frag.qsb" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import QtQuick
import "." as LocalTransitions
LocalTransitions.ForkShaderTransition { shaderFile: "pixelate.frag.qsb" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import QtQuick
import "." as LocalTransitions
LocalTransitions.ForkShaderTransition { shaderFile: "stripes.frag.qsb" }
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#version 440

const int _45[256] = int[](-8, -8, -8, -9, -9, -8, -7, -8, -7, -6, -5, -5, -6, -5, -6, -6, -5, -4, -3, -3, -4, -4, -3, -2, -1, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, -1, -1, 0, 0, -1, -2, -1, -2, -3, -4, -4, -5, -6, -5, -5, -6, -7, -7, -6, -6, -5, -5, -6, -6, -5, -5, -5, -6, -7, -6, -6, -6, -5, -4, -4, -5, -4, -5, -5, -6, -5, -4, -3, -3, -2, -2, -1, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, -2, -2, -3, -2, -1, -2, -1, -2, -2, -2, -1, 0, 0, 0, 0, -1, -1, -2, -1, -2, -1, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -2, -3, -4, -4, -4, -3, -3, -3, -3, -3, -4, -4, -3, -4, -5, -5, -6, -6, -5, -6, -6, -7, -6, -5, -5, -4, -5, -4, -4, -5, -6, -7, -8, -9, -8, -9, -10, -9, -9, -9, -10, -9, -8, -8, -9, -9, -8, -8, -9, -8, -8, -8, -7, -6, -5, -6, -7, -8, -8, -9, -8, -8, -9, -8, -7, -8, -7, -7, -7, -8, -8, -8, -8, -7, -8, -8, -9, -10, -9, -9, -8, -7, -6, -6, -7, -7, -6, -6, -6, -7, -7, -8, -8, -8, -9, -9, -8, -9, -10);

layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float progress;
} _92;

layout(binding = 1) uniform sampler2D fromImage;
layout(binding = 2) uniform sampler2D toImage;

layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;

float getMeltTableValue(float x)
{
float screenWidth = 360.0;
int index = int(floor(x * screenWidth)) & 255;
int melt_height = _45[index];
float result_height = float(melt_height + 20) / 10.0;
return result_height;
}
float melt_pattern(float x)
{
float param = x;
float height = getMeltTableValue(param) * 2.0;
return height;
}

float inNormal(float x)
{
return float((x >= 0.0) && (x <= 1.0));
}

void main()
{
vec2 uv = qt_TexCoord0;
float t = _92.progress;
float animationTime = clamp((t * 1.0) - 1.0, -1.0, 2.0);
vec2 uv2 = uv;
float acceleration = (smoothstep(0.5, 1.0, t * 1.0) * 0.5) + 1.0;
float param = uv.x;
float push = (melt_pattern(param) * 0.5) + ((animationTime * acceleration) * 2.0);
float maxPush = 2.0;
push = clamp(push, 0.0, maxPush);
uv2.y += push;
vec4 topColor = texture(fromImage, uv2);
vec4 bottomColor = texture(toImage, uv);
float param_1 = uv2.y;
vec4 mask = vec4(inNormal(param_1));
fragColor = vec4((mask.xyz * topColor.xyz) + (bottomColor.xyz * (vec3(1.0) - mask.xyz)), 1.0);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#version 440

layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float progress;
} _19;

layout(binding = 2) uniform sampler2D toImage;
layout(binding = 1) uniform sampler2D fromImage;

layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;

void main()
{
vec2 uv = qt_TexCoord0;
float threshold = _19.progress;
float diagonal = (uv.x + uv.y) / 2.0;
if (diagonal < threshold)
{
fragColor = texture(toImage, uv) * _19.qt_Opacity;
}
else
{
vec2 newUv = uv - vec2(_19.progress * 0.20000000298023223876953125);
fragColor = texture(fromImage, newUv) * _19.qt_Opacity;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#version 440

layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float progress;
vec2 aspectRatio;
vec2 origin;
} _33;

layout(binding = 1) uniform sampler2D fromImage;
layout(binding = 2) uniform sampler2D toImage;

layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;

float getDistance(vec2 uv)
{
vec2 scaled = (uv - _33.origin) * _33.aspectRatio;
return length(scaled);
}

float random(vec2 co)
{
return fract(sin(dot(co, vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875);
}

void main()
{
vec2 uv = qt_TexCoord0;
float p = clamp(_33.progress, 0.0, 1.0);
if (p <= 0.0)
{
fragColor = texture(fromImage, uv) * _33.qt_Opacity;
return;
}
if (p >= 1.0)
{
fragColor = texture(toImage, uv) * _33.qt_Opacity;
return;
}
vec2 distortedUV = clamp(uv, vec2(0.0), vec2(1.0));
vec4 fromColor = texture(toImage, distortedUV);
vec4 toColor = texture(fromImage, distortedUV);
vec2 param = uv;
float dist = getDistance(param);
vec2 maxVec = max(_33.origin, vec2(1.0) - _33.origin) * _33.aspectRatio;
float maxDistance = length(maxVec);
float threshold = p * maxDistance;
vec2 param_1 = uv * 150.0;
float edgeNoise = smoothstep(0.0, 1.0, random(param_1)) * 0.119999997317790985107421875;
float blend = smoothstep(threshold - 0.0500000007450580596923828125, threshold + edgeNoise, dist);
fragColor = mix(toColor, fromColor, vec4(1.0 - blend)) * _33.qt_Opacity;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#version 440

layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float progress;
float aspectX;
float aspectY;
vec2 aspectRatio;
vec2 origin;
} ubuf;

layout(binding = 1) uniform sampler2D fromImage;
layout(binding = 2) uniform sampler2D toImage;

layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;

void main()
{
vec2 uv = qt_TexCoord0;
float pixelIntensity = 1.0 - abs((2.0 * ubuf.progress) - 1.0);
vec2 sampleUV = uv;
if (pixelIntensity > 0.001000000047497451305389404296875)
{
float blockSize = 0.0500000007450580596923828125 * pixelIntensity;
sampleUV = (floor(uv / vec2(blockSize)) * blockSize) + vec2(blockSize * 0.5);
}
vec4 color1 = texture(fromImage, sampleUV);
vec4 color2 = texture(toImage, sampleUV);
float blend = smoothstep(0.4000000059604644775390625, 0.60000002384185791015625, ubuf.progress);
fragColor = mix(color1, color2, vec4(blend)) * ubuf.qt_Opacity;
}
Loading