summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2025-09-05 23:31:35 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2025-09-05 23:31:35 +0200
commit14d4d05acc235ab7033316d16530783c90e95faa (patch)
tree2a6e0953cd5f4e4419274178c8a44a34456ab32c /accounts/gkleen@sif/shell/quickshell/Lockscreen.qml
parent02dbc3d9260fa1137e8ebc99ad439fc555d81fd2 (diff)
downloadnixos-14d4d05acc235ab7033316d16530783c90e95faa.tar
nixos-14d4d05acc235ab7033316d16530783c90e95faa.tar.gz
nixos-14d4d05acc235ab7033316d16530783c90e95faa.tar.bz2
nixos-14d4d05acc235ab7033316d16530783c90e95faa.tar.xz
nixos-14d4d05acc235ab7033316d16530783c90e95faa.zip
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/Lockscreen.qml')
-rw-r--r--accounts/gkleen@sif/shell/quickshell/Lockscreen.qml222
1 files changed, 20 insertions, 202 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml b/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml
index 7cb1cc67..cc82a275 100644
--- a/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml
+++ b/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml
@@ -2,14 +2,7 @@ import Quickshell
2import Quickshell.Wayland 2import Quickshell.Wayland
3import Quickshell.Io 3import Quickshell.Io
4import Quickshell.Services.Pam 4import Quickshell.Services.Pam
5import Quickshell.Widgets 5import QtQml
6import QtQuick.Effects
7import QtQuick.Layouts
8import QtQuick
9import QtQuick.Controls
10import QtQuick.Controls.Fusion
11import qs.Services
12// import QtQml.Models
13 6
14Scope { 7Scope {
15 id: lockscreen 8 id: lockscreen
@@ -53,205 +46,30 @@ Scope {
53 WlSessionLockSurface { 46 WlSessionLockSurface {
54 id: lockSurface 47 id: lockSurface
55 48
56 color: "#000000" 49 color: "black"
57 50
58 Item { 51 LockSurface {
59 id: background 52 id: surfaceContent
60 53
61 anchors.fill: parent 54 onResponse: responseText => pam.respond(responseText)
62 55 onAuthRunningChanged: {
63 property Img current: one 56 if (authRunning)
64 property string source: selector.selected 57 pam.start();
65
66 WallpaperSelector {
67 id: selector
68 seed: lockSurface.screen?.name || ""
69 }
70
71 onSourceChanged: {
72 if (!source)
73 current = null;
74 else if (current === one)
75 two.update()
76 else
77 one.update()
78 }
79
80 Img { id: one }
81 Img { id: two }
82
83 component Img: Item {
84 id: img
85
86 property string source
87
88 function update() {
89 source = background.source || ""
90 }
91
92 anchors.fill: parent
93
94 Image {
95 id: imageSource
96
97 source: img.source
98 sourceSize: Qt.size(parent.width, parent.height)
99 fillMode: Image.PreserveAspectCrop
100 smooth: true
101 visible: false
102 asynchronous: true
103 cache: false
104
105 onStatusChanged: {
106 if (status === Image.Ready) {
107 background.current = img
108 }
109 }
110 }
111
112 MultiEffect {
113 id: imageEffect
114
115 source: imageSource
116 anchors.fill: parent
117 blurEnabled: true
118 blur: 1
119 blurMax: 64
120 blurMultiplier: 2
121
122 opacity: 0
123
124 states: State {
125 name: "visible"
126 when: background.current === img
127
128 PropertyChanges {
129 imageEffect.opacity: 1
130 }
131 StateChangeScript {
132 name: "unloadOther"
133 script: {
134 if (img === one)
135 two.source = ""
136 if (img === two)
137 one.source = ""
138 }
139 }
140 }
141
142 transitions: Transition {
143 SequentialAnimation {
144 NumberAnimation {
145 target: imageEffect
146 properties: "opacity"
147 duration: 5000
148 easing.type: Easing.OutCubic
149 }
150 ScriptAction {
151 scriptName: "unloadOther"
152 }
153 }
154 }
155 }
156 }
157 }
158
159 Item {
160 anchors {
161 top: lockSurface.top
162 left: lockSurface.left
163 right: lockSurface.right
164 }
165
166 implicitWidth: lockSurface.width
167 implicitHeight: 21
168
169 Rectangle {
170 anchors.fill: parent
171 color: Qt.rgba(0, 0, 0, 0.75)
172 } 58 }
173 59 Connections {
174 Clock { 60 target: pam
175 anchors.centerIn: parent 61 function onMessagesChanged() { surfaceContent.messages = pam.messages; }
176 calendarPopup: false 62 function onResponseRequiredChanged() { surfaceContent.responseRequired = pam.responseRequired; }
63 function onActiveChanged() { surfaceContent.authRunning = pam.active; }
177 } 64 }
178 } 65 onCurrentTextChanged: lockscreen.currentText = currentText
179 66 Connections {
180 WrapperRectangle { 67 target: lockscreen
181 id: unlockUi 68 function onCurrentTextChanged() { surfaceContent.currentText = lockscreen.currentText; }
182
183 Keys.onPressed: event => {
184 if (!pam.active) {
185 event.accepted = true;
186 pam.start();
187 }
188 } 69 }
189 focus: !passwordBox.visible 70 Connections {
190 71 target: lockSurface
191 visible: pam.active 72 function onScreenChanged() { surfaceContent.screen = lockSurface.screen; }
192
193 color: Qt.rgba(0, 0, 0, 0.75)
194 margin: 8
195
196 anchors.centerIn: parent
197
198 ColumnLayout {
199 spacing: 4
200
201 BusyIndicator {
202 visible: running
203 running: !Array.from(pam.messages).length && !pam.responseRequired
204 }
205
206 Repeater {
207 model: pam.messages
208
209 Text {
210 required property var modelData
211
212 font.pointSize: 10
213 font.family: "Fira Sans"
214 color: modelData.error ? "#f28a21" : "#ffffff"
215
216 text: modelData.text
217
218 Layout.fillWidth: true
219 horizontalAlignment: Text.AlignHCenter
220 }
221 }
222
223 TextField {
224 id: passwordBox
225
226 visible: pam.responseRequired
227 echoMode: pam.responseVisible ? TextInput.Normal : TextInput.Password
228 inputMethodHints: Qt.ImhSensitiveData
229
230 onTextChanged: lockscreen.currentText = passwordBox.text
231 onAccepted: {
232 passwordBox.readOnly = true;
233 pam.respond(lockscreen.currentText);
234 }
235
236 Connections {
237 target: lockscreen
238 function onCurrentTextChanged() {
239 passwordBox.text = lockscreen.currentText
240 }
241 }
242 Connections {
243 target: pam
244 function onResponseRequiredChanged() {
245 if (pam.responseRequired)
246 passwordBox.readOnly = false;
247 passwordBox.focus = true;
248 passwordBox.selectAll();
249 }
250 }
251
252 Layout.topMargin: 4
253 Layout.fillWidth: true
254 }
255 } 73 }
256 } 74 }
257 } 75 }