69 lines
1.4 KiB
QML
69 lines
1.4 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Wayland
|
|
import "../services" as S
|
|
|
|
Scope {
|
|
id: root
|
|
|
|
WlSessionLock {
|
|
id: _lock
|
|
|
|
LockSurface {
|
|
lock: _lock
|
|
auth: _auth
|
|
}
|
|
}
|
|
|
|
LockAuth {
|
|
id: _auth
|
|
lock: _lock
|
|
}
|
|
|
|
// Capture screenshots before locking, with timeout for security
|
|
Timer {
|
|
id: _lockTimeout
|
|
interval: 150
|
|
onTriggered: _lock.locked = true
|
|
}
|
|
|
|
Connections {
|
|
target: S.LockService
|
|
|
|
function onLockRequested() {
|
|
if (!S.LockService.enabled || _lock.locked)
|
|
return;
|
|
S.ScreenshotService.capture(Quickshell.screens.length);
|
|
_lockTimeout.start();
|
|
}
|
|
|
|
function onUnlockRequested() {
|
|
if (_lock.locked)
|
|
_lock.locked = false;
|
|
}
|
|
|
|
function onSessionLocked() {
|
|
if (S.LockService.enabled && !_lock.locked)
|
|
_lock.locked = true;
|
|
}
|
|
}
|
|
|
|
Connections {
|
|
target: S.ScreenshotService
|
|
|
|
function onCaptureComplete() {
|
|
if (_lockTimeout.running) {
|
|
_lockTimeout.stop();
|
|
_lock.locked = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
Connections {
|
|
target: _lock
|
|
|
|
function onLockStateChanged() {
|
|
S.LockService.setLockedHint(_lock.locked);
|
|
}
|
|
}
|
|
}
|