little fix
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -2752,7 +2752,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "my-clock"
|
name = "my-clock"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"embed-resource",
|
"embed-resource",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "my-clock"
|
name = "my-clock"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
20
src/main.rs
20
src/main.rs
@@ -3,7 +3,7 @@ use chrono::{Local, Timelike};
|
|||||||
|
|
||||||
slint::slint! {
|
slint::slint! {
|
||||||
export component AppWindow inherits Window {
|
export component AppWindow inherits Window {
|
||||||
title: "Modern Clock";
|
title: "时钟";
|
||||||
icon: @image-url("../assets/icon.png");
|
icon: @image-url("../assets/icon.png");
|
||||||
no-frame: true;
|
no-frame: true;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
@@ -57,7 +57,7 @@ slint::slint! {
|
|||||||
height: 30px;
|
height: 30px;
|
||||||
background: t_theme.has-hover ? #333 : transparent;
|
background: t_theme.has-hover ? #333 : transparent;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
Text { text: root.is_dark_mode ? "亮色模式" : "幽蓝模式"; color: #ddd; font-size: 14px; }
|
Text { text: root.is_dark_mode ? "亮色主题" : "暗色主题"; color: #ddd; font-size: 14px; }
|
||||||
t_theme := TouchArea { clicked => { root.is_dark_mode = !root.is_dark_mode; menu_popup.close(); } }
|
t_theme := TouchArea { clicked => { root.is_dark_mode = !root.is_dark_mode; menu_popup.close(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,15 +142,19 @@ slint::slint! {
|
|||||||
@radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 80%);
|
@radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 80%);
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 12 : Path {
|
for i in 60 : Path {
|
||||||
viewbox-width: 100; viewbox-height: 100;
|
viewbox-width: 100; viewbox-height: 100;
|
||||||
width: 100%; height: 100%;
|
width: 100%; height: 100%;
|
||||||
stroke: root.is_dark_mode ? rgba(200, 220, 255, 0.5) : rgba(0, 0, 0, 0.5);
|
property <bool> is_hour: (Math.mod(i, 5) == 0);
|
||||||
stroke-width: 2px;
|
stroke: root.is_dark_mode ?
|
||||||
property <float> angle: i * 30;
|
(is_hour ? rgba(200, 220, 255, 0.5) : rgba(200, 220, 255, 0.25)) :
|
||||||
|
(is_hour ? rgba(0, 0, 0, 0.5) : rgba(0, 0, 0, 0.25));
|
||||||
|
stroke-width: is_hour ? 2px : 1px;
|
||||||
|
property <float> angle: i * 6;
|
||||||
|
property <float> start_r: is_hour ? 42 : 45;
|
||||||
MoveTo {
|
MoveTo {
|
||||||
x: 50 + Math.sin(parent.angle * 1deg) * 42;
|
x: 50 + Math.sin(parent.angle * 1deg) * parent.start_r;
|
||||||
y: 50 - Math.cos(parent.angle * 1deg) * 42;
|
y: 50 - Math.cos(parent.angle * 1deg) * parent.start_r;
|
||||||
}
|
}
|
||||||
LineTo {
|
LineTo {
|
||||||
x: 50 + Math.sin(parent.angle * 1deg) * 47;
|
x: 50 + Math.sin(parent.angle * 1deg) * 47;
|
||||||
|
|||||||
Reference in New Issue
Block a user