From 389e02cf4ef6476d9bcbaa52f512916fae88d77e Mon Sep 17 00:00:00 2001 From: April & May & June Date: Tue, 3 Mar 2026 21:19:44 +0800 Subject: [PATCH] fix: lockscreen not shown after switch back from tty The LockView.qml (in fact the whole lockscreen component in Greeter.qml) is re-created after switch back from tty, as the output is exactly being removed and re-added once. So that we cannot use property listener for displaying lockscreen as usual. This will work as intended. --- src/greeter/greeterproxy.cpp | 8 ++++++ src/greeter/greeterproxy.h | 9 ++++++ src/plugins/lockscreen/qml/LockView.qml | 38 +++++++++++++++---------- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/greeter/greeterproxy.cpp b/src/greeter/greeterproxy.cpp index 44915c9d2..7b9134656 100644 --- a/src/greeter/greeterproxy.cpp +++ b/src/greeter/greeterproxy.cpp @@ -134,6 +134,14 @@ void GreeterProxy::setShowShutdownView(bool show) { } } +void GreeterProxy::setShowAnimation(bool show) +{ + if (m_showAnimation != show) { + m_showAnimation = show; + Q_EMIT showAnimationChanged(show); + } +} + void GreeterProxy::setLock(bool isLocked) { if (isLocked && !m_isLocked) { diff --git a/src/greeter/greeterproxy.h b/src/greeter/greeterproxy.h index e628e0a51..05740b7f9 100644 --- a/src/greeter/greeterproxy.h +++ b/src/greeter/greeterproxy.h @@ -136,6 +136,15 @@ class GreeterProxy */ void setShowShutdownView(bool show); + /** + * @brief Set whether to show animation + * + * Use in C++ only + * + * @param show true to show animation, false to disable animation + */ + void setShowAnimation(bool show); + //////////////////// // Public methods // //////////////////// diff --git a/src/plugins/lockscreen/qml/LockView.qml b/src/plugins/lockscreen/qml/LockView.qml index c5dfe85e0..133223912 100644 --- a/src/plugins/lockscreen/qml/LockView.qml +++ b/src/plugins/lockscreen/qml/LockView.qml @@ -151,21 +151,7 @@ FocusScope { Connections { target: GreeterProxy function onLockChanged(isLocked) { - if (isLocked) { - root.forceActiveFocus() - root.visible = true - root.state = LoginAnimation.Show - leftAnimation.item.start({x: root.x - quickAction.width, y: quickAction.y}, {x: quickAction.x, y: quickAction.y}) - logoAnimation.item.start({x: root.x - logo.width, y: logo.y}, {x: logo.x, y: logo.y}) - rightAnimation.item.start({x: root.width + userInput.width, y: userInput.y}, {x: userInput.x, y: userInput.y}) - bottomAnimation.item.start({x: controlAction.x, y: controlAction.y + controlAction.height}, {x: controlAction.x, y: controlAction.y}) - } else { - root.state = LoginAnimation.Hide - leftAnimation.item.start({x: quickAction.x, y: quickAction.y}, {x: root.x - quickAction.width, y: quickAction.y}) - logoAnimation.item.start({x: logo.x, y: logo.y}, {x: root.x - logo.width, y: logo.y}) - rightAnimation.item.start({x: userInput.x, y: userInput.y}, {x: root.width + userInput.width, y: userInput.y}) - bottomAnimation.item.start({x: controlAction.x, y: controlAction.y}, {x: controlAction.x, y: controlAction.y + controlAction.height}) - } + root.applyLockState(isLocked) } } @@ -175,6 +161,28 @@ FocusScope { } } + Component.onCompleted: { + root.applyLockState(true) + } + + function applyLockState(isLocked) { + if (isLocked) { + root.forceActiveFocus() + root.visible = true + root.state = LoginAnimation.Show + leftAnimation.item.start({x: root.x - quickAction.width, y: quickAction.y}, {x: quickAction.x, y: quickAction.y}) + logoAnimation.item.start({x: root.x - logo.width, y: logo.y}, {x: logo.x, y: logo.y}) + rightAnimation.item.start({x: root.width + userInput.width, y: userInput.y}, {x: userInput.x, y: userInput.y}) + bottomAnimation.item.start({x: controlAction.x, y: controlAction.y + controlAction.height}, {x: controlAction.x, y: controlAction.y}) + } else { + root.state = LoginAnimation.Hide + leftAnimation.item.start({x: quickAction.x, y: quickAction.y}, {x: root.x - quickAction.width, y: quickAction.y}) + logoAnimation.item.start({x: logo.x, y: logo.y}, {x: root.x - logo.width, y: logo.y}) + rightAnimation.item.start({x: userInput.x, y: userInput.y}, {x: root.width + userInput.width, y: userInput.y}) + bottomAnimation.item.start({x: controlAction.x, y: controlAction.y}, {x: controlAction.x, y: controlAction.y + controlAction.height}) + } + } + function showUserView() { root.animationPlayFinished.connect(root.__showUserList) }