put time column in loader, use fewer Behaviors

This commit is contained in:
end-4
2025-10-11 11:47:36 +02:00
parent 872e0762b6
commit 1e7e3a84c6
2 changed files with 23 additions and 20 deletions
@@ -78,6 +78,7 @@ Item {
color: root.colOnBackground color: root.colOnBackground
} }
// Stupid extra hour marks in the middle
FadeLoader { FadeLoader {
id: hourMarksLoader id: hourMarksLoader
anchors.centerIn: parent anchors.centerIn: parent
@@ -90,12 +91,21 @@ Item {
} }
// Number column in the middle // Number column in the middle
TimeColumn { FadeLoader {
id: timeColumnLoader
anchors.centerIn: parent anchors.centerIn: parent
color: root.colOnBackground shown: Config.options.background.clock.cookie.timeIndicators
clockNumbers: root.clockNumbers scale: 1.4 - 0.4 * timeColumnLoader.shown
Behavior on scale {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
}
sourceComponent: TimeColumn {
color: root.colOnBackground
}
} }
// Hour hand // Hour hand
HourHand { HourHand {
anchors.fill: parent anchors.fill: parent
@@ -10,11 +10,11 @@ import QtQuick.Layouts
ColumnLayout { ColumnLayout {
id: root id: root
required property list<string> clockNumbers property list<string> clockNumbers: DateTime.time.split(/[: ]/)
property bool isEnabled: Config.options.background.clock.cookie.timeIndicators property bool isEnabled: Config.options.background.clock.cookie.timeIndicators
property color color: Appearance.colors.colOnSecondaryContainer property color color: Appearance.colors.colOnSecondaryContainer
z: 0 property bool hourMarksEnabled: Config.options.background.clock.cookie.hourMarks
spacing: -16 spacing: -16
Repeater { Repeater {
@@ -22,31 +22,24 @@ ColumnLayout {
delegate: StyledText { delegate: StyledText {
required property string modelData required property string modelData
property bool hourMarksEnabled: Config.options.background.clock.cookie.hourMarks
property bool isAmPm: !modelData.match(/\d{2}/i) property bool isAmPm: !modelData.match(/\d{2}/i)
property real numberSizeWithoutGlow: isAmPm ? 26 : 68 property real numberSizeWithoutGlow: isAmPm ? 26 : 68
property real numberSizeWithGlow: isAmPm ? 20 : 40 property real numberSizeWithGlow: isAmPm ? 20 : 40
property real numberSize: root.isEnabled ? (hourMarksEnabled ? numberSizeWithGlow : numberSizeWithoutGlow) : 100 // open/close animation property real numberSize: root.hourMarksEnabled ? numberSizeWithGlow : numberSizeWithoutGlow
anchors.horizontalCenter: root.horizontalCenter anchors.horizontalCenter: root.horizontalCenter
visible: opacity > 0
color: root.color color: root.color
opacity: root.isEnabled ? 1.0 : 0
Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
text: modelData.padStart(2, "0")
font { font {
family: Appearance.font.family.expressive family: Appearance.font.family.expressive
weight: Font.Bold weight: Font.Bold
pixelSize: numberSize pixelSize: numberSize
Behavior on pixelSize {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
}
} }
Behavior on numberSize {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
}
text: modelData.padStart(2, "0")
} }
} }
} }