make code more readable

This commit is contained in:
darksignal7
2025-10-05 17:10:59 +03:00
parent 0f7f7d997b
commit 7f8a5315c4
3 changed files with 99 additions and 107 deletions
@@ -49,6 +49,7 @@ Item {
property int clockSecond: 0 property int clockSecond: 0
// Loader to set root.clockSecond
Loader{ Loader{
active: Config.option.background.clock.cookie.secondDot active: Config.option.background.clock.cookie.secondDot
sourceComponent: Timer { sourceComponent: Timer {
@@ -95,22 +96,21 @@ Item {
sides: Config.options.background.clock.clockSides sides: Config.options.background.clock.clockSides
color: root.colBackground color: root.colBackground
waveAnimation: Config.options.background.clock.cookie.waveAnimation waveAnimation: Config.options.background.clock.cookie.waveAnimation
} }
// 12 dots around the cookie // Hour dots dial style
Repeater { Repeater {
model: 12 model: 12
Item { Item {
opacity: Config.options.background.clock.cookie.dialNumberStyle === "dots" ? 1.0 : 0 // Not using visible to allow smooth transition required property int index
opacity: Config.options.background.clock.cookie.dialNumberStyle === "dots" ? 1.0 : 0
rotation: 360 / 12 * index
anchors.fill: parent
Behavior on opacity { Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
required property int index
rotation: 360 / 12 * index
anchors.fill: parent
Rectangle { Rectangle {
anchors { anchors{
left: parent.left left: parent.left
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
leftMargin: Config.options.background.clock.cookie.dialNumberStyle === "dots" ? 10 : 50 leftMargin: Config.options.background.clock.cookie.dialNumberStyle === "dots" ? 10 : 50
@@ -135,13 +135,13 @@ Item {
Repeater { Repeater {
model: 12 model: 12
Item { Item {
opacity: Config.options.background.clock.cookie.centerGlow ? 1.0 : 0 // Not using visible to allow smooth transition required property int index
opacity: Config.options.background.clock.cookie.centerGlow ? 1.0 : 0
rotation: 360 / 12 * index
anchors.fill: parent
Behavior on opacity { Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
required property int index
rotation: 360 / 12 * index
anchors.fill: parent
Rectangle { Rectangle {
anchors { anchors {
left: parent.left left: parent.left
@@ -170,33 +170,28 @@ Item {
z: 1 z: 1
anchors.centerIn: cookie anchors.centerIn: cookie
spacing: -16 spacing: -16
// Numbers
Repeater { Repeater {
model: root.clockNumbers model: root.clockNumbers
delegate: StyledText { delegate: StyledText {
required property string modelData required property string modelData
opacity: Config.options.background.clock.cookie.timeIndicators ? 1.0 : 0 // Not using visible to allow smooth transition opacity: Config.options.background.clock.cookie.timeIndicators ? 1.0 : 0 // Not using visible to allow smooth transition
Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
anchors.horizontalCenter: parent?.horizontalCenter anchors.horizontalCenter: parent?.horizontalCenter
color: root.colOnBackground
text: modelData.padStart(2, "0")
font { font {
// A better way to do this? probably yes, do i know : no
// (changing size based on am/pm selected or not)
property real numberSizeWithoutGlow: modelData.match(/am|pm/i) ? 26 : 68 property real numberSizeWithoutGlow: modelData.match(/am|pm/i) ? 26 : 68
property real numberSizeWithGlow: modelData.match(/am|pm/i) ? 10 : 40 property real numberSizeWithGlow: modelData.match(/am|pm/i) ? 10 : 40
pixelSize: !Config.options.background.clock.cookie.timeIndicators ? 100 : // for open/close animation pixelSize: !Config.options.background.clock.cookie.timeIndicators ? 100 : // open/close animation
Config.options.background.clock.cookie.centerGlow ? numberSizeWithGlow : numberSizeWithoutGlow Config.options.background.clock.cookie.centerGlow ? numberSizeWithGlow : numberSizeWithoutGlow // changing size according to center glow
Behavior on pixelSize { Behavior on pixelSize {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this) animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
} }
family: Appearance.font.family.main family: Appearance.font.family.main
weight: Font.Bold weight: Font.Bold
} }
color: root.colOnBackground Behavior on opacity {
text: modelData.padStart(2, "0") animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
} }
} }
} }
@@ -210,16 +205,15 @@ Item {
Rectangle { Rectangle {
// fill // fill
opacity: Config.options.background.clock.cookie.hourHandStyle === "fill" ? 1.0 : 0 opacity: Config.options.background.clock.cookie.hourHandStyle === "fill" ? 1.0 : 0
Behavior on opacity {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
}
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
x: parent.width / 2 - hourHandWidth / 2 x: parent.width / 2 - hourHandWidth / 2
width: hourHandLength width: hourHandLength
height: hourHandWidth height: hourHandWidth
radius: hourHandWidth / 2 radius: hourHandWidth / 2
//color: Config.options.background.clock.cookie.hourHandStyle === "stroke" ? "transparent" : root.colHourHand
color : root.colHourHand color : root.colHourHand
Behavior on opacity {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
}
} }
Rectangle { Rectangle {
// border // border
@@ -238,54 +232,54 @@ Item {
Item { Item {
anchors.fill: parent anchors.fill: parent
z: Config.options.background.clock.cookie.minuteHandStyle === "thin" ? 1 : 3 z: Config.options.background.clock.cookie.minuteHandStyle === "thin" ? 1 : 3
rotation: -90 + (360 / 60) * root.clockMinute
Behavior on rotation{ Behavior on rotation{
animation: Appearance.animation.elementResize.numberAnimation.createObject(this) animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
} }
rotation: -90 + (360 / 60) * root.clockMinute
Rectangle { Rectangle {
Behavior on height {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
}
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
x: parent.width / 2 - minuteHandWidth / 2 x: parent.width / 2 - minuteHandWidth / 2
width: minuteHandLength width: minuteHandLength
height: minuteHandWidth height: minuteHandWidth
radius: minuteHandWidth / 2 radius: minuteHandWidth / 2
color: root.colMinuteHand color: root.colMinuteHand
Behavior on height {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
}
} }
} }
// Center dot // Center dot
Rectangle { Rectangle {
opacity: Config.options.background.clock.cookie.minuteHandStyle !== "bold" ? 1.0 : 0 // Not using visible to allow smooth transition
Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
z: 4 z: 4
opacity: Config.options.background.clock.cookie.minuteHandStyle !== "bold" ? 1.0 : 0
color: Config.options.background.clock.cookie.minuteHandStyle === "medium" ? root.colBackground : root.colMinuteHand color: Config.options.background.clock.cookie.minuteHandStyle === "medium" ? root.colBackground : root.colMinuteHand
anchors.centerIn: parent anchors.centerIn: parent
implicitWidth: centerDotSize implicitWidth: centerDotSize
implicitHeight: implicitWidth implicitHeight: implicitWidth
radius: implicitWidth / 2 radius: implicitWidth / 2
Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
} }
// Center glow // Center glow
Rectangle { Rectangle {
opacity: Config.options.background.clock.cookie.centerGlow ? 1.0 : 0 // Not using visible to allow smooth transition opacity: Config.options.background.clock.cookie.centerGlow ? 1.0 : 0
Behavior on opacity {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
}
Behavior on implicitWidth { // Not using two animations because it looks weird
ParallelAnimation {
NumberAnimation { properties: "implicitWidth,implicitHeight"; duration: 100; easing.type: Easing.InOutQuad }
}
}
z: 0 z: 0
color: root.colTimeIndicators color: root.colTimeIndicators
anchors.centerIn: parent anchors.centerIn: parent
implicitWidth: Config.options.background.clock.cookie.centerGlow ? centerGlowSize : centerGlowSize * 1.75 implicitWidth: Config.options.background.clock.cookie.centerGlow ? centerGlowSize : centerGlowSize * 1.75
implicitHeight: implicitWidth implicitHeight: implicitWidth
radius: implicitWidth / 2 radius: implicitWidth / 2
Behavior on opacity {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
}
Behavior on implicitWidth { // Not using two animations (one for width and one for height) because it looks weird
ParallelAnimation {
NumberAnimation { properties: "implicitWidth,implicitHeight"; duration: 100; easing.type: Easing.InOutQuad }
}
}
} }
@@ -294,16 +288,19 @@ Item {
id: secondHand id: secondHand
z: Config.options.background.clock.cookie.secondHandStyle === "line" ? 2 : 3 z: Config.options.background.clock.cookie.secondHandStyle === "line" ? 2 : 3
opacity: Config.options.background.clock.cookie.secondHandStyle === "dot" || Config.options.background.clock.cookie.secondHandStyle === "line" ? 1.0 : 0 // Not using visible to allow smooth transition opacity: Config.options.background.clock.cookie.secondHandStyle === "dot" || Config.options.background.clock.cookie.secondHandStyle === "line" ? 1.0 : 0 // Not using visible to allow smooth transition
rotation: (360 / 60 * clockSecond) + 90 // +90 degrees to align with minute hand
anchors.fill: parent
Behavior on opacity { Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
Behavior on rotation{ Behavior on rotation{
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
rotation: (360 / 60 * clockSecond) + 90 // +90 degrees to align with minute hand
anchors.fill: parent
Rectangle { Rectangle {
implicitWidth: Config.options.background.clock.cookie.secondHandStyle === "dot" ? root.secondDotSize : root.secondsHandLength
implicitHeight: Config.options.background.clock.cookie.secondHandStyle === "dot" ? implicitWidth : root.secondsHandWidth
radius: Config.options.background.clock.cookie.secondHandStyle === "dot" ? implicitWidth / 2 : root.secondsHandWidth / 2
color: colSeconds
Behavior on implicitHeight { Behavior on implicitHeight {
animation: Appearance.animation.elementResize.numberAnimation.createObject(this) animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
} }
@@ -315,10 +312,6 @@ Item {
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
leftMargin: 10 leftMargin: 10
} }
implicitWidth: Config.options.background.clock.cookie.secondHandStyle === "dot" ? root.secondDotSize : root.secondsHandLength
implicitHeight: Config.options.background.clock.cookie.secondHandStyle === "dot" ? implicitWidth : root.secondsHandWidth
radius: Config.options.background.clock.cookie.secondHandStyle === "dot" ? implicitWidth / 2 : root.secondsHandWidth / 2
color: colSeconds
} }
} }
@@ -329,7 +322,6 @@ Item {
height: cookie.height height: cookie.height
rotation: secondHand.rotation + 45 // +45 degrees to align with minute hand rotation: secondHand.rotation + 45 // +45 degrees to align with minute hand
opacity: Config.options.background.clock.cookie.dateStyle === "rotating" ? 1.0 : 0 opacity: Config.options.background.clock.cookie.dateStyle === "rotating" ? 1.0 : 0
Behavior on opacity { Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
@@ -367,17 +359,16 @@ Item {
z: 1 z: 1
implicitWidth: 45 implicitWidth: 45
implicitHeight: Config.options.background.clock.cookie.dateStyle === "square" ? 30 : 0 implicitHeight: Config.options.background.clock.cookie.dateStyle === "square" ? 30 : 0
Behavior on implicitHeight{ color: root.colOnBackground
animation: Appearance.animation.elementResize.numberAnimation.createObject(this) radius: Appearance.rounding.small
}
opacity: 1.0
anchors{ anchors{
verticalCenter: cookie.verticalCenter verticalCenter: cookie.verticalCenter
right: cookie.right right: cookie.right
rightMargin: 10 rightMargin: 10
} }
color: root.colOnBackground Behavior on implicitHeight{
radius: Appearance.rounding.small // LOOK animation: Appearance.animation.elementResize.numberAnimation.createObject(this)
}
StyledText{ StyledText{
opacity: Config.options.background.clock.cookie.dateStyle === "square" ? 1.0 : 0 opacity: Config.options.background.clock.cookie.dateStyle === "square" ? 1.0 : 0
Behavior on opacity{ Behavior on opacity{
@@ -398,14 +389,17 @@ Item {
Repeater { Repeater {
model: 4 model: 4
Item { Item {
opacity: Config.options.background.clock.cookie.dialNumberStyle === "numbers" ? 1.0 : 0 // Not using visible to allow smooth transition required property int index
opacity: Config.options.background.clock.cookie.dialNumberStyle === "numbers" ? 1.0 : 0
rotation: 360 / 4 * index
anchors.fill: parent
Behavior on opacity { Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
required property int index
rotation: 360 / 4 * index
anchors.fill: parent
Rectangle { Rectangle {
color: "transparent"
implicitWidth: root.hourNumberSize
implicitHeight: implicitWidth
anchors { anchors {
left: parent.left left: parent.left
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
@@ -414,14 +408,12 @@ Item {
Behavior on anchors.leftMargin{ Behavior on anchors.leftMargin{
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
implicitWidth: root.hourNumberSize
implicitHeight: implicitWidth
color: "transparent"
StyledText{ StyledText{
color: root.colOnBackground color: root.colOnBackground
anchors.centerIn: parent anchors.centerIn: parent
text: index === 0 ? "9" : index === 1 ? "12" : index === 2 ? "3" : "6" text: index === 0 ? "9" :
index === 1 ? "12" :
index === 2 ? "3" : "6"
rotation: index % 2 === 0 ? index * 90 : -index * 90 //A better way can be found to show texts on right angle rotation: index % 2 === 0 ? index * 90 : -index * 90 //A better way can be found to show texts on right angle
font { font {
family: Appearance.font.family.reading family: Appearance.font.family.reading
@@ -437,14 +429,18 @@ Item {
Repeater { Repeater {
model: 12 model: 12
Item { Item {
required property int index
rotation: 360 / 12 * index
anchors.fill: parent
opacity: Config.options.background.clock.cookie.dialNumberStyle === "full" ? 1.0 : 0 opacity: Config.options.background.clock.cookie.dialNumberStyle === "full" ? 1.0 : 0
Behavior on opacity { Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
required property int index
rotation: 360 / 12 * index
anchors.fill: parent
Rectangle { Rectangle {
implicitWidth: root.hourLineSize * 3.5
implicitHeight: root.hourLineSize
radius: implicitWidth / 2
color: root.colOnBackground
anchors { anchors {
left: parent.left left: parent.left
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
@@ -453,11 +449,6 @@ Item {
Behavior on anchors.leftMargin{ Behavior on anchors.leftMargin{
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
implicitWidth: root.hourLineSize * 3.5
implicitHeight: root.hourLineSize
radius: implicitWidth / 2
color: root.colOnBackground
opacity: 1.0
} }
} }
} }
@@ -465,14 +456,19 @@ Item {
Repeater { Repeater {
model: 60 model: 60
Item { Item {
required property int index
rotation: 360 / 60 * index
anchors.fill: parent
opacity: Config.options.background.clock.cookie.dialNumberStyle === "full" ? 1.0 : 0 opacity: Config.options.background.clock.cookie.dialNumberStyle === "full" ? 1.0 : 0
Behavior on opacity { Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
required property int index
rotation: 360 / 60 * index
anchors.fill: parent
Rectangle { Rectangle {
implicitWidth: root.minuteLineSize * 3.5
implicitHeight: root.minuteLineSize
radius: implicitWidth / 2
color: root.colOnBackground
opacity: 0.5
anchors { anchors {
left: parent.left left: parent.left
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
@@ -481,11 +477,6 @@ Item {
Behavior on anchors.leftMargin{ Behavior on anchors.leftMargin{
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
implicitWidth: root.minuteLineSize * 3.5
implicitHeight: root.minuteLineSize
radius: implicitWidth / 2
color: root.colOnBackground
opacity: 0.5
} }
} }
} }
@@ -131,11 +131,11 @@ Singleton {
property real scale: 1 property real scale: 1
property int clockSides: 12 property int clockSides: 12
property JsonObject cookie: JsonObject { property JsonObject cookie: JsonObject {
property string dialNumberStyle: "dots" // Options: "dots" , "numbers", "full" , "none" property string dialNumberStyle: "dots" // Options: "dots" , "numbers", "full" , "none"
property string hourHandStyle: "fill" // Options: "fill", "stroke" property string hourHandStyle: "fill" // Options: "fill", "stroke"
property string minuteHandStyle: "medium" // Options: "medium", "bold" property string minuteHandStyle: "medium" // Options: "medium", "bold"
property string secondHandStyle: "dot" // Options: "dot", "line" , "none" property string secondHandStyle: "dot" // Options: "dot", "line" , "none"
property string dateStyle: "rotating" // Options: "rotating", "square", "none" property string dateStyle: "rotating" // Options: "rotating", "square", "none"
property bool timeIndicators: true property bool timeIndicators: true
property bool centerGlow: true property bool centerGlow: true
property bool dateInClock: true property bool dateInClock: true
@@ -205,28 +205,28 @@ ContentPage {
} }
ContentSubsection { ContentSubsection {
enabled: Config.options.background.clock.style === "cookie" enabled: Config.options.background.clock.style === "cookie"
visible: Config.options.background.clock.style === "cookie" visible: Config.options.background.clock.style === "cookie"
title: Translation.tr("Hour hand style") title: Translation.tr("Hour hand style")
ConfigSelectionArray { ConfigSelectionArray {
currentValue: Config.options.background.clock.cookie.hourHandStyle currentValue: Config.options.background.clock.cookie.hourHandStyle
onSelected: newValue => { onSelected: newValue => {
Config.options.background.clock.cookie.hourHandStyle = newValue; Config.options.background.clock.cookie.hourHandStyle = newValue;
}
options: [
{
displayName: Translation.tr("Fill"),
icon: "stroke_full",
value: "fill"
},
{
displayName: Translation.tr("Stroke"),
icon: "stroke_partial",
value: "stroke"
}
]
} }
options: [
{
displayName: Translation.tr("Fill"),
icon: "stroke_full",
value: "fill"
},
{
displayName: Translation.tr("Stroke"),
icon: "stroke_partial",
value: "stroke"
}
]
} }
}
ConfigSpinBox { ConfigSpinBox {
enabled: Config.options.background.clock.style === "cookie" enabled: Config.options.background.clock.style === "cookie"
@@ -241,6 +241,7 @@ ContentPage {
Config.options.background.clock.clockSides = value; Config.options.background.clock.clockSides = value;
} }
} }
ConfigSwitch { ConfigSwitch {
enabled: Config.options.background.clock.style === "cookie" enabled: Config.options.background.clock.style === "cookie"
visible: Config.options.background.clock.style === "cookie" visible: Config.options.background.clock.style === "cookie"