Wrap LockScreen in NLoader
This commit is contained in:
parent
622c34a551
commit
d688d04b77
2 changed files with 36 additions and 8 deletions
|
|
@ -12,8 +12,35 @@ import qs.Commons
|
|||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
WlSessionLock {
|
||||
NLoader {
|
||||
id: lockScreen
|
||||
// External API
|
||||
property bool locked: false
|
||||
// Internal loader control; keep content alive briefly after unlocking
|
||||
property bool _isLoadedInternal: false
|
||||
// Only load when explicitly requested (locked) or while waiting to safely unload
|
||||
isLoaded: _isLoadedInternal
|
||||
onLockedChanged: {
|
||||
if (locked) {
|
||||
_isLoadedInternal = true
|
||||
}
|
||||
}
|
||||
// Allow a small grace period after unlocking so the compositor releases the lock surfaces
|
||||
Timer {
|
||||
id: unloadAfterUnlockTimer
|
||||
interval: 250
|
||||
repeat: false
|
||||
onTriggered: lockScreen._isLoadedInternal = false
|
||||
}
|
||||
function scheduleUnloadAfterUnlock() {
|
||||
unloadAfterUnlockTimer.start()
|
||||
}
|
||||
content: Component {
|
||||
WlSessionLock {
|
||||
id: lock
|
||||
// Keep inner lock state in sync with wrapper
|
||||
locked: lockScreen.locked
|
||||
onLockedChanged: lockScreen.locked = locked
|
||||
|
||||
// Lockscreen is a different beast, needs a capital 'S' in 'Screen' to get the current screen
|
||||
readonly property real scaling: ScalingService.scale(Screen)
|
||||
|
|
@ -22,7 +49,7 @@ WlSessionLock {
|
|||
property bool authenticating: false
|
||||
property string password: ""
|
||||
property bool pamAvailable: typeof PamContext !== "undefined"
|
||||
locked: false
|
||||
|
||||
|
||||
function unlockAttempt() {
|
||||
Logger.log("LockScreen", "Unlock attempt started")
|
||||
|
|
@ -53,7 +80,10 @@ WlSessionLock {
|
|||
lock.authenticating = false
|
||||
if (result === PamResult.Success) {
|
||||
Logger.log("LockScreen", "Authentication successful, unlocking")
|
||||
// First release the Wayland session lock, then unload after a short delay
|
||||
lock.locked = false
|
||||
lockScreen.locked = false
|
||||
lockScreen.scheduleUnloadAfterUnlock()
|
||||
lock.password = ""
|
||||
lock.errorMessage = ""
|
||||
} else {
|
||||
|
|
@ -866,4 +896,7 @@ WlSessionLock {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ NPanel {
|
|||
Text {
|
||||
text: "Lock Screen"
|
||||
color: lockButtonArea.containsMouse ? Color.mOnTertiary : Color.mOnSurface
|
||||
font.pointSize: Style.fontSizeReduced * scaling
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.verticalCenterOffset: 1 * scaling
|
||||
|
|
@ -138,7 +137,6 @@ NPanel {
|
|||
Text {
|
||||
text: "Suspend"
|
||||
color: suspendButtonArea.containsMouse ? Color.mOnTertiary : Color.mOnSurface
|
||||
font.pointSize: Style.fontSizeReduced * scaling
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.verticalCenterOffset: 1 * scaling
|
||||
|
|
@ -191,7 +189,6 @@ NPanel {
|
|||
Text {
|
||||
text: "Reboot"
|
||||
color: rebootButtonArea.containsMouse ? Color.mOnTertiary : Color.mOnSurface
|
||||
font.pointSize: Style.fontSizeReduced * scaling
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.verticalCenterOffset: 1 * scaling
|
||||
|
|
@ -244,7 +241,6 @@ NPanel {
|
|||
Text {
|
||||
text: "Logout"
|
||||
color: logoutButtonArea.containsMouse ? Color.mOnTertiary : Color.mOnSurface
|
||||
font.pointSize: Style.fontSizeReduced * scaling
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.verticalCenterOffset: 1 * scaling
|
||||
|
|
@ -297,7 +293,6 @@ NPanel {
|
|||
Text {
|
||||
text: "Shutdown"
|
||||
color: shutdownButtonArea.containsMouse ? Color.mOnTertiary : Color.mOnSurface
|
||||
font.pointSize: Style.fontSizeReduced * scaling
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.verticalCenterOffset: 1 * scaling
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue