background: fix clock movement jumping abruptly

This commit is contained in:
end-4
2025-09-24 08:29:04 +02:00
parent 0498d7ea98
commit 6707487d3c
@@ -266,11 +266,7 @@ Variants {
horizontalCenter: undefined horizontalCenter: undefined
verticalCenter: undefined verticalCenter: undefined
leftMargin: bgRoot.movableXSpace + ((root.fixedClockPosition ? root.fixedClockX : bgRoot.clockX * bgRoot.effectiveWallpaperScale) - implicitWidth / 2) leftMargin: bgRoot.movableXSpace + ((root.fixedClockPosition ? root.fixedClockX : bgRoot.clockX * bgRoot.effectiveWallpaperScale) - implicitWidth / 2)
topMargin: { topMargin: bgRoot.movableYSpace + ((root.fixedClockPosition ? root.fixedClockY : bgRoot.clockY * bgRoot.effectiveWallpaperScale) - implicitHeight / 2)
if (bgRoot.shouldBlur)
return bgRoot.modelData.height / 3;
return bgRoot.movableYSpace + ((root.fixedClockPosition ? root.fixedClockY : bgRoot.clockY * bgRoot.effectiveWallpaperScale) - implicitHeight / 2);
}
Behavior on leftMargin { Behavior on leftMargin {
animation: Appearance.animation.elementMove.numberAnimation.createObject(this) animation: Appearance.animation.elementMove.numberAnimation.createObject(this)
} }
@@ -300,7 +296,6 @@ Variants {
} }
} }
sourceComponent: ColumnLayout { sourceComponent: ColumnLayout {
id: clock
spacing: 8 spacing: 8
Loader { Loader {
@@ -345,68 +340,71 @@ Variants {
active: visible active: visible
sourceComponent: CookieClock {} sourceComponent: CookieClock {}
} }
}
Item { Item {
Layout.alignment: { anchors {
if (bgRoot.textHorizontalAlignment === Text.AlignHCenter || root.clockStyle === "cookie") top: clockLoader.bottom
return Qt.AlignHCenter; topMargin: 8
return (bgRoot.textHorizontalAlignment === Text.AlignLeft ? Qt.AlignLeft : Qt.AlignRight) horizontalCenter: (bgRoot.textHorizontalAlignment === Text.AlignHCenter || root.clockStyle === "cookie") ? clockLoader.horizontalCenter : undefined
left: (bgRoot.textHorizontalAlignment === Text.AlignLeft) ? clockLoader.left : undefined
right: (bgRoot.textHorizontalAlignment === Text.AlignRight) ? clockLoader.right : undefined
leftMargin: -26
rightMargin: -26
}
implicitWidth: statusTextBg.implicitWidth
implicitHeight: statusTextBg.implicitHeight
StyledRectangularShadow {
target: statusTextBg
visible: statusTextBg.visible && root.clockStyle === "cookie"
opacity: statusTextBg.opacity
}
Rectangle {
id: statusTextBg
anchors.centerIn: parent
clip: true
opacity: (safetyStatusText.shown || lockStatusText.shown) ? 1 : 0
visible: opacity > 0
implicitHeight: statusTextRow.implicitHeight + 5 * 2
implicitWidth: statusTextRow.implicitWidth + 5 * 2
radius: Appearance.rounding.small
color: CF.ColorUtils.transparentize(Appearance.colors.colSecondaryContainer, root.clockStyle === "cookie" ? 0 : 1)
Behavior on implicitWidth {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
} }
Layout.leftMargin: -26 Behavior on implicitHeight {
Layout.rightMargin: -26 animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
implicitWidth: statusTextBg.implicitWidth }
implicitHeight: statusTextBg.implicitHeight Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
StyledRectangularShadow {
target: statusTextBg
visible: statusTextBg.visible && cookieClockLoader.active
opacity: statusTextBg.opacity
} }
Rectangle { RowLayout {
id: statusTextBg id: statusTextRow
clip: true anchors.centerIn: parent
opacity: (safetyStatusText.shown || lockStatusText.shown) ? 1 : 0 spacing: 14
visible: opacity > 0 Item {
implicitHeight: statusTextRow.implicitHeight + 5 * 2 Layout.fillWidth: bgRoot.textHorizontalAlignment !== Text.AlignLeft
implicitWidth: statusTextRow.implicitWidth + 5 * 2 implicitWidth: 1
radius: Appearance.rounding.small
color: CF.ColorUtils.transparentize(Appearance.colors.colSecondaryContainer, cookieClockLoader.active ? 0 : 1)
Behavior on implicitWidth {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
} }
Behavior on implicitHeight { ClockStatusText {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this) id: safetyStatusText
shown: bgRoot.wallpaperSafetyTriggered
statusIcon: "hide_image"
statusText: qsTr("Wallpaper safety enforced")
} }
Behavior on opacity { ClockStatusText {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) id: lockStatusText
shown: GlobalStates.screenLocked && Config.options.lock.showLockedText
statusIcon: "lock"
statusText: qsTr("Locked")
} }
Item {
RowLayout { Layout.fillWidth: bgRoot.textHorizontalAlignment !== Text.AlignRight
id: statusTextRow implicitWidth: 1
anchors.centerIn: parent
spacing: 14
Item {
Layout.fillWidth: bgRoot.textHorizontalAlignment !== Text.AlignLeft
implicitWidth: 1
}
ClockStatusText {
id: safetyStatusText
shown: bgRoot.wallpaperSafetyTriggered
statusIcon: "hide_image"
statusText: qsTr("Wallpaper safety enforced")
}
ClockStatusText {
id: lockStatusText
shown: GlobalStates.screenLocked && Config.options.lock.showLockedText
statusIcon: "lock"
statusText: qsTr("Locked")
}
Item {
Layout.fillWidth: bgRoot.textHorizontalAlignment !== Text.AlignRight
implicitWidth: 1
}
} }
} }
} }