From 403b11c2d785a47a34722c4ca927a31766894d30 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Fri, 28 Jun 2024 23:25:50 -0400 Subject: [PATCH] lockscreen: Fix clock getting animated right after load Restores a fix for https://invent.kde.org/plasma/plasma-mobile/-/issues/381 The pw notifications model right at load appears to say there are notifications at load, but then fixes itself once the component finishes loading. --- shell/contents/lockscreen/LockScreenContent.qml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/shell/contents/lockscreen/LockScreenContent.qml b/shell/contents/lockscreen/LockScreenContent.qml index 5c479567..51825e92 100644 --- a/shell/contents/lockscreen/LockScreenContent.qml +++ b/shell/contents/lockscreen/LockScreenContent.qml @@ -29,13 +29,16 @@ Item { visible: root.isVertical spacing: 0 - // center clock when no notifications are shown, otherwise move the clock upward - anchors.topMargin: !root.notificationsShown ? Math.round(root.fullHeight / 2 - (verticalLayout.implicitHeight / 2)) : Kirigami.Units.gridUnit * 5 + // Center clock when no notifications are shown, otherwise move the clock upward + anchors.topMargin: root.notificationsShown ? Kirigami.Units.gridUnit * 5 : Math.round(root.fullHeight / 2 - (verticalLayout.implicitHeight / 2)) anchors.bottomMargin: Kirigami.Units.gridUnit anchors.fill: parent - // animate + // Animate clock centering change when notifications come in Behavior on anchors.topMargin { + id: topMarginAnim + enabled: false + NumberAnimation { duration: Kirigami.Units.veryLongDuration easing.type: Easing.InOutExpo @@ -46,6 +49,13 @@ Item { LayoutItemProxy { target: notificationComponent } } + // HACK: don't animate top margin at beginning, while notification model figures itself out + Timer { + running: true + repeat: false + onTriggered: topMarginAnim.enabled = true + } + // Horizontal layout (landscape on smaller devices) Item { id: horizontalLayout