add date to clock

This commit is contained in:
darksignal7
2025-10-05 01:55:39 +03:00
parent 9726f0f586
commit c643d26bce
3 changed files with 57 additions and 2 deletions
@@ -252,6 +252,7 @@ Item {
// Second hand/ dot
Item {
id: secondHand
z: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
Behavior on opacity {
@@ -281,7 +282,43 @@ Item {
}
}
// Date
Canvas {
width: cookie.width
height: cookie.height
rotation: secondHand.rotation + 45 // +45 degrees to align with minute hand
opacity: Config.options.background.clock.cookie.dateInClock ? 1.0 : 0
Behavior on opacity {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
}
onPaint: {
var ctx = getContext("2d");
ctx.clearRect(0,0,width,height);
ctx.font = "700 30px gabarito";
var text = DateTime.date.substring(0,3) + " " + DateTime.date.substring(4,7);
var radius = 78;
var angleStep = Math.PI / 2.35 / text.length;
for (var i=0; i<text.length; i++) {
var angle = i * angleStep - Math.PI/2;
var x = width/2 + radius * Math.cos(angle);
var y = height/2 + radius * Math.sin(angle);
ctx.save();
ctx.translate(x,y);
ctx.rotate(angle + Math.PI/2);
if (i >= 3)
ctx.fillStyle = root.colOnBackground;
else
ctx.fillStyle = Appearance.colors.colSecondaryHover;
ctx.fillText(text[i], 0, 0);
ctx.restore();
}
}
}
// Hour Indicator numbers
Repeater {
@@ -136,6 +136,7 @@ Singleton {
property string secondHandStyle: "dot" // Options: "dot", "line" , "none"
property bool timeIndicators: true
property bool centerGlow: true
property bool dateInClock: true
property bool waveAnimation: true
}
@@ -84,6 +84,9 @@ ContentPage {
if (newValue === "numbers") {
Config.options.background.clock.cookie.timeIndicators = false;
}
if (newValue != "none"){
Config.options.background.clock.cookie.dateInClock = false;
}
}
options: [
{
@@ -214,7 +217,21 @@ ContentPage {
text: "Can't be turned on when using 'Numbers' dial style for aesthetic reasons"
}
}
ConfigSwitch {
enabled: Config.options.background.clock.style === "cookie" && Config.options.background.clock.cookie.dialNumberStyle === "none"
buttonIcon: "farsight_digital"
text: Translation.tr("Date inside clock")
checked: Config.options.background.clock.cookie.dateInClock
onEnabledChanged: {
checked = Config.options.background.clock.cookie.dateInClock
}
onCheckedChanged: {
Config.options.background.clock.cookie.dateInClock = checked;
}
StyledToolTip {
text: "Can only be turned on when not using any dial style for aesthetic reasons"
}
}
}