85 lines
3.1 KiB
QML
85 lines
3.1 KiB
QML
import QtQuick
|
|
import QtQuick.Effects
|
|
import Quickshell
|
|
import Quickshell.Wayland
|
|
import "../services"
|
|
import "../theme"
|
|
// qmllint disable uncreatable-type
|
|
PanelWindow {
|
|
id:root
|
|
required property var modelData
|
|
screen:modelData
|
|
anchors {top:true;bottom:true;left:true;right:true}
|
|
color:Theme.surface
|
|
exclusionMode:ExclusionMode.Ignore
|
|
WlrLayershell.layer:WlrLayer.Background
|
|
WlrLayershell.namespace:"glassMxrph-wallpaper"
|
|
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 {
|
|
id:shown
|
|
anchors.fill:parent
|
|
sourceSize:Qt.size(parent.width,parent.height)
|
|
asynchronous:true
|
|
retainWhileLoading:true
|
|
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);}
|
|
}
|
|
}
|