Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/greeter/greeterproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions src/greeter/greeterproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
////////////////////
Expand Down
38 changes: 23 additions & 15 deletions src/plugins/lockscreen/qml/LockView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -175,6 +161,28 @@ FocusScope {
}
}

Component.onCompleted: {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥是默认传递true?不应该根据GreeterProxy里保存的状态来吗?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LockView的创建分为两种场景:一种是在treeland刚启动的时候,另一种是在output被(重新)添加的时候。tty切换是第二种场景。如果在这里直接读取GreeterProxy的状态的话,会在第一种场景下报错,可能是QML组件的创建和引用的顺序的问题。这里这样写实际上会在两种场景下都表现正确,因为这两种情况都会立即显示锁屏,而我们目前没有第三种情况,算是代码侵入性小但不治本的一种方法qwq

如果您希望的话我去研究一下GreeterProxy的初始化时序问题,换一种方式改?

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)
}
Expand Down
Loading