Reveal native wallpaper changes with a soft growing circle
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e80ef1181
commit
47a7576d46
1 file changed
+60
-1
@@ -1,4 +1,5 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
|
import QtQuick.Effects
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import "../services"
|
import "../services"
|
||||||
@@ -14,12 +15,70 @@ PanelWindow {
|
|||||||
WlrLayershell.layer:WlrLayer.Background
|
WlrLayershell.layer:WlrLayer.Background
|
||||||
WlrLayershell.namespace:"glassMxrph-wallpaper"
|
WlrLayershell.namespace:"glassMxrph-wallpaper"
|
||||||
mask:Region {}
|
mask:Region {}
|
||||||
|
readonly property string target:ConfigService.ready && ConfigService.data.wallpaper.byMonitor[root.modelData.name] ? "file://"+encodeURI(ConfigService.data.wallpaper.byMonitor[root.modelData.name]).replace(/#/g,"%23").replace(/\?/g,"%3F") : ""
|
||||||
|
// 0..1 while a new wallpaper grows in from the centre over the old one.
|
||||||
|
property real progress:0
|
||||||
|
readonly property bool transitioning:incoming.source.toString()!==""
|
||||||
|
// The first wallpaper (and reduced motion) appears directly; later changes
|
||||||
|
// load into `incoming` and are revealed once decoded.
|
||||||
|
onTargetChanged:{
|
||||||
|
if(!shown.source.toString() || Theme.duration===0) {reveal.stop();incoming.source="";shown.source=target;}
|
||||||
|
else if(target===shown.source.toString()) {reveal.stop();incoming.source="";}
|
||||||
|
else {reveal.stop();progress=0;incoming.source=target;}
|
||||||
|
}
|
||||||
|
Component.onCompleted:shown.source=target
|
||||||
|
function settle() {
|
||||||
|
if(!reveal.running && shown.status===Image.Ready && shown.source.toString()===incoming.source.toString())incoming.source="";
|
||||||
|
}
|
||||||
Image {
|
Image {
|
||||||
|
id:shown
|
||||||
anchors.fill:parent
|
anchors.fill:parent
|
||||||
source:ConfigService.ready && ConfigService.data.wallpaper.byMonitor[root.modelData.name] ? "file://"+encodeURI(ConfigService.data.wallpaper.byMonitor[root.modelData.name]).replace(/#/g,"%23").replace(/\?/g,"%3F") : ""
|
|
||||||
sourceSize:Qt.size(parent.width,parent.height)
|
sourceSize:Qt.size(parent.width,parent.height)
|
||||||
asynchronous:true
|
asynchronous:true
|
||||||
retainWhileLoading:true
|
retainWhileLoading:true
|
||||||
fillMode:Image.PreserveAspectCrop
|
fillMode:Image.PreserveAspectCrop
|
||||||
|
// Drop the overlay only once the base layer shows the new image.
|
||||||
|
onStatusChanged:root.settle()
|
||||||
|
}
|
||||||
|
Image {
|
||||||
|
id:incoming
|
||||||
|
anchors.fill:parent
|
||||||
|
visible:false
|
||||||
|
sourceSize:Qt.size(parent.width,parent.height)
|
||||||
|
asynchronous:true
|
||||||
|
fillMode:Image.PreserveAspectCrop
|
||||||
|
onStatusChanged:if(status===Image.Ready && source.toString())reveal.restart()
|
||||||
|
}
|
||||||
|
Item {
|
||||||
|
id:revealMask
|
||||||
|
anchors.fill:parent
|
||||||
|
visible:false
|
||||||
|
layer.enabled:root.transitioning
|
||||||
|
Rectangle {
|
||||||
|
readonly property real reach:Math.hypot(root.width,root.height)*1.15
|
||||||
|
anchors.centerIn:parent
|
||||||
|
width:reach*root.progress;height:width;radius:width/2
|
||||||
|
color:"black"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MultiEffect {
|
||||||
|
anchors.fill:parent
|
||||||
|
visible:root.transitioning
|
||||||
|
source:incoming
|
||||||
|
// Settles from a slight zoom while the circle widens, like swww/awww "grow".
|
||||||
|
scale:1.06-0.06*root.progress
|
||||||
|
opacity:Math.min(1,root.progress*4)
|
||||||
|
maskEnabled:true
|
||||||
|
maskSource:revealMask
|
||||||
|
maskThresholdMin:0.5
|
||||||
|
maskSpreadAtMin:1
|
||||||
|
}
|
||||||
|
NumberAnimation {
|
||||||
|
id:reveal
|
||||||
|
target:root;property:"progress"
|
||||||
|
from:0;to:1
|
||||||
|
duration:1100
|
||||||
|
easing.type:Easing.InOutCubic
|
||||||
|
onFinished:{shown.source=incoming.source;Qt.callLater(root.settle);}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user