diff options
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/Lockscreen.qml')
-rw-r--r-- | accounts/gkleen@sif/shell/quickshell/Lockscreen.qml | 235 |
1 files changed, 33 insertions, 202 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml b/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml index 7cb1cc67..8e739359 100644 --- a/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml +++ b/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml | |||
@@ -2,14 +2,10 @@ import Quickshell | |||
2 | import Quickshell.Wayland | 2 | import Quickshell.Wayland |
3 | import Quickshell.Io | 3 | import Quickshell.Io |
4 | import Quickshell.Services.Pam | 4 | import Quickshell.Services.Pam |
5 | import Quickshell.Widgets | 5 | import Quickshell.Services.Mpris |
6 | import QtQuick.Effects | 6 | import Custom as Custom |
7 | import QtQuick.Layouts | ||
8 | import QtQuick | ||
9 | import QtQuick.Controls | ||
10 | import QtQuick.Controls.Fusion | ||
11 | import qs.Services | 7 | import qs.Services |
12 | // import QtQml.Models | 8 | import QtQml |
13 | 9 | ||
14 | Scope { | 10 | Scope { |
15 | id: lockscreen | 11 | id: lockscreen |
@@ -45,213 +41,48 @@ Scope { | |||
45 | WlSessionLock { | 41 | WlSessionLock { |
46 | id: lock | 42 | id: lock |
47 | 43 | ||
48 | onLockedChanged: { | 44 | onLockStateChanged: { |
49 | if (!locked && pam.active) | 45 | if (!locked && pam.active) |
50 | pam.abort(); | 46 | pam.abort(); |
47 | |||
48 | if (locked) { | ||
49 | Custom.KeePassXC.lockAllDatabases(); | ||
50 | Array.from(Mpris.players.values).forEach(player => { | ||
51 | if (player.canPause && player.isPlaying) | ||
52 | player.pause(); | ||
53 | }); | ||
54 | // Custom.Systemd.stopUserUnit("gpg-agent.service", "replace"); | ||
55 | GpgAgent.reloadAgent(); | ||
56 | } | ||
51 | } | 57 | } |
52 | 58 | ||
53 | WlSessionLockSurface { | 59 | WlSessionLockSurface { |
54 | id: lockSurface | 60 | id: lockSurface |
55 | 61 | ||
56 | color: "#000000" | 62 | color: "black" |
57 | |||
58 | Item { | ||
59 | id: background | ||
60 | |||
61 | anchors.fill: parent | ||
62 | |||
63 | property Img current: one | ||
64 | property string source: selector.selected | ||
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 | 63 | ||
166 | implicitWidth: lockSurface.width | 64 | LockSurface { |
167 | implicitHeight: 21 | 65 | id: surfaceContent |
168 | 66 | ||
169 | Rectangle { | 67 | onResponse: responseText => pam.respond(responseText) |
170 | anchors.fill: parent | 68 | onAuthRunningChanged: { |
171 | color: Qt.rgba(0, 0, 0, 0.75) | 69 | if (authRunning) |
70 | pam.start(); | ||
172 | } | 71 | } |
173 | 72 | Connections { | |
174 | Clock { | 73 | target: pam |
175 | anchors.centerIn: parent | 74 | function onMessagesChanged() { surfaceContent.messages = pam.messages; } |
176 | calendarPopup: false | 75 | function onResponseRequiredChanged() { surfaceContent.responseRequired = pam.responseRequired; } |
76 | function onActiveChanged() { surfaceContent.authRunning = pam.active; } | ||
177 | } | 77 | } |
178 | } | 78 | onCurrentTextChanged: lockscreen.currentText = currentText |
179 | 79 | Connections { | |
180 | WrapperRectangle { | 80 | target: lockscreen |
181 | id: unlockUi | 81 | function onCurrentTextChanged() { surfaceContent.currentText = lockscreen.currentText; } |
182 | |||
183 | Keys.onPressed: event => { | ||
184 | if (!pam.active) { | ||
185 | event.accepted = true; | ||
186 | pam.start(); | ||
187 | } | ||
188 | } | 82 | } |
189 | focus: !passwordBox.visible | 83 | Connections { |
190 | 84 | target: lockSurface | |
191 | visible: pam.active | 85 | 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 | } | 86 | } |
256 | } | 87 | } |
257 | } | 88 | } |