diff options
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/Lockscreen.qml')
| -rw-r--r-- | accounts/gkleen@sif/shell/quickshell/Lockscreen.qml | 222 |
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 | |||
| 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 QtQml |
| 6 | import QtQuick.Effects | ||
| 7 | import QtQuick.Layouts | ||
| 8 | import QtQuick | ||
| 9 | import QtQuick.Controls | ||
| 10 | import QtQuick.Controls.Fusion | ||
| 11 | import qs.Services | ||
| 12 | // import QtQml.Models | ||
| 13 | 6 | ||
| 14 | Scope { | 7 | Scope { |
| 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 | } |
