blob: 4f85a900539db0b0178285f38eb3a792bfa10402 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
 | import QtQuick
import Quickshell
import qs.Services
Item {
  id: root
  anchors.fill: parent
  required property string screen
  property Img current: one
  property string source: selector.selected
  WallpaperSelector {
    id: selector
    seed: screen
  }
  onSourceChanged: {
    if (!source)
      current = null;
    else if (current === one)
      two.update()
    else
      one.update()
  }
  Img { id: one }
  Img { id: two }
  component Img: Image {
    id: img
    function update() {
      source = root.source || ""
    }
    anchors.fill: parent
    fillMode: Image.PreserveAspectCrop
    smooth: true
    asynchronous: true
    cache: false
    opacity: 0
    onStatusChanged: {
      if (status === Image.Ready) {
	root.current = this
      }
    }
    states: State {
      name: "visible"
      when: root.current === img
      PropertyChanges {
	img.opacity: 1
      }
      StateChangeScript {
        name: "unloadOther"
	script: {
	  if (img === one)
	    two.source = ""
	  if (img === two)
	    one.source = ""
	}
      }
    }
    transitions: Transition {
      SequentialAnimation {
	NumberAnimation {
	  target: img
	  properties: "opacity"
	  duration: {
	    if (img === one && two.source == "" || img === two && one.source == "")
	      return 0;
	    return 5000;
	  }
	  easing.type: Easing.OutCubic
	}
        ScriptAction {
	  scriptName: "unloadOther"
	}
      }
    }
  }
}
 |