blob: 18698725677ea67bfe1ab5c28098e6167b17c5e9 (
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
 | import Quickshell.Widgets
import QtQuick.Effects
import QtQuick.Layouts
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Fusion
import qs.Services
import QtQml
Item {
  id: lockSurface
  property var screen
  property list<var> messages: []
  property bool responseRequired: false
  property bool responseVisible: false
  property string currentText: ""
  property bool authRunning: false
  signal response(string responseText)
  anchors.fill: parent
  Item {
    id: background
    anchors.fill: parent
    property Img current: one
    property string source: selector.selected
    WallpaperSelector {
      id: selector
      seed: lockSurface.screen?.name || ""
    }
    onSourceChanged: {
      if (!source)
	current = null;
      else if (current === one)
	two.update()
      else
	one.update()
    }
    Img { id: one }
    Img { id: two }
    component Img: Item {
      id: img
      property string source
      function update() {
	source = background.source || ""
      }
      anchors.fill: parent
      Image {
	id: imageSource
	source: img.source
	sourceSize: Qt.size(parent.width, parent.height)
	fillMode: Image.PreserveAspectCrop
	smooth: true
	visible: false
	asynchronous: true
	cache: false
	onStatusChanged: {
	  if (status === Image.Ready) {
	    background.current = img
	  }
	}
      }
      MultiEffect {
	id: imageEffect
	source: imageSource
	anchors.fill: parent
	blurEnabled: true
	blur: 1
	blurMax: 64
	blurMultiplier: 2
	opacity: 0
	states: State {
	  name: "visible"
	  when: background.current === img
	  PropertyChanges {
	    imageEffect.opacity: 1
	  }
	  StateChangeScript {
	    name: "unloadOther"
	    script: {
	      if (img === one)
		two.source = ""
	      if (img === two)
		one.source = ""
	    }
	  }
	}
	transitions: Transition {
	  SequentialAnimation {
	    NumberAnimation {
	      target: imageEffect
	      properties: "opacity"
	      duration: 5000
	      easing.type: Easing.OutCubic
	    }
	    ScriptAction {
	      scriptName: "unloadOther"
	    }
	  }
	}
      }
    }
  }
  Item {
    anchors {
      top: lockSurface.top
      left: lockSurface.left
      right: lockSurface.right
    }
    implicitWidth: lockSurface.width
    implicitHeight: 21
    Rectangle {
      anchors.fill: parent
      color: Qt.rgba(0, 0, 0, 0.75)
    }
    Clock {
      anchors.centerIn: parent
      calendarPopup: false
    }
  }
  WrapperRectangle {
    id: unlockUi
    Keys.onPressed: event => {
      if (!lockSurface.authRunning) {
	event.accepted = true;
	lockSurface.authRunning = true;
      }
    }
    focus: !passwordBox.visible
    visible: lockSurface.authRunning
    color: Qt.rgba(0, 0, 0, 0.75)
    margin: 8
    anchors.centerIn: parent
    ColumnLayout {
      spacing: 4
      BusyIndicator {
	visible: running
	running: !Array.from(lockSurface.messages).length && !lockSurface.responseRequired
      }
      Repeater {
	model: lockSurface.messages
	Text {
	  required property var modelData
	  font.pointSize: 10
	  font.family: "Fira Sans"
	  color: modelData.error ? "#f28a21" : "#ffffff"
	  text: String(modelData.text).trim()
	  Layout.fillWidth: true
	  horizontalAlignment: Text.AlignHCenter
	}
      }
      TextField {
	id: passwordBox
	visible: lockSurface.responseRequired
	echoMode: lockSurface.responseVisible ? TextInput.Normal : TextInput.Password
	inputMethodHints: Qt.ImhSensitiveData
	onTextChanged: lockSurface.currentText = passwordBox.text
	onAccepted: {
	  passwordBox.readOnly = true;
	  lockSurface.response(lockSurface.currentText);
	}
	Connections {
	  target: lockSurface
	  function onCurrentTextChanged() {
	    passwordBox.text = lockSurface.currentText
	  }
	}
	Connections {
	  target: lockSurface
	  function onResponseRequiredChanged() {
	    if (lockSurface.responseRequired)
	      passwordBox.readOnly = false;
	      passwordBox.focus = true;
	      passwordBox.selectAll();
	  }
	}
	Layout.topMargin: 4
	Layout.fillWidth: true
      }
    }
  }
}
 |