From fe9e7106f1c2d81603fd78f805490ee92ecce062 Mon Sep 17 00:00:00 2001 From: Vyn Date: Wed, 25 Jun 2025 10:43:56 +0200 Subject: [PATCH] Add Tasks and Calendar SVG icons + Fix ToggleButton --- components/Svg.slint | 3 ++- components/ToggleButton.slint | 27 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/components/Svg.slint b/components/Svg.slint index 1b8b813..bebfd7f 100644 --- a/components/Svg.slint +++ b/components/Svg.slint @@ -11,5 +11,6 @@ export global Svg { out property pen: "M3 17.46v3.04c0 .28.22.5.5.5h3.04c.13 0 .26-.05.35-.15L17.81 9.94l-3.75-3.75L3.15 17.1q-.15.15-.15.36M20.71 7.04a.996.996 0 0 0 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83l3.75 3.75z"; out property visible: "M2.933 3.491C4.056 2.681 5.456 2 7 2s2.944.682 4.067 1.491c1.128.812 2.02 1.784 2.56 2.437l.005.005c.241.3.368.681.368 1.067s-.127.766-.368 1.067l-.005.005c-.54.653-1.432 1.625-2.56 2.437C9.944 11.32 8.544 12 7 12s-2.944-.682-4.067-1.49C1.805 9.696.913 8.724.373 8.071l-.005-.005A1.7 1.7 0 0 1 0 7c0-.386.127-.766.368-1.067l.005-.005c.54-.653 1.432-1.625 2.56-2.437M7 9.25a2.25 2.25 0 1 0 0-4.5a2.25 2.25 0 0 0 0 4.5"; out property not-visible: "M.264 1.324a.75.75 0 0 1 1.06-1.06l2.629 2.628C4.86 2.393 5.893 2.04 7 2.04c1.532 0 2.92.677 4.035 1.48c1.118.805 2.003 1.769 2.539 2.417l.004.005c.24.298.366.675.366 1.058s-.126.76-.366 1.058l-.004.006a14.5 14.5 0 0 1-2.249 2.2l2.411 2.412a.75.75 0 0 1-1.06 1.06zm8.753 6.633a2.232 2.232 0 0 0-2.974-2.974zm-8.59-2.02c.319-.387.762-.885 1.305-1.395l7.104 7.104A5.7 5.7 0 0 1 7 11.96c-1.532 0-2.92-.676-4.035-1.479C1.847 9.675.962 8.711.426 8.064l-.004-.006A1.7 1.7 0 0 1 .056 7c0-.383.126-.76.366-1.058l.004-.005Z"; - + out property tasks: "M9 18H20M9 12H20M9 6H20M4 17.5H5V18.5H4V17.5ZM4 11.5H5V12.5H4V11.5ZM4 5.5V6.5H5V5.5H4Z"; + out property calendar: "M20 9H4M7 3V5M17 3V5M6 21H18C19.1046 21 20 20.1046 20 19V7C20 5.89543 19.1046 5 18 5H6C4.89543 5 4 5.89543 4 7V19C4 20.1046 4.89543 21 6 21Z"; } diff --git a/components/ToggleButton.slint b/components/ToggleButton.slint index 5669ac8..abf212c 100644 --- a/components/ToggleButton.slint +++ b/components/ToggleButton.slint @@ -6,8 +6,13 @@ export component ToggleButton inherits Rectangle { in property text <=> text-component.text; in property text-color <=> text-component.color; in property text-alignment <=> text-component.horizontal-alignment; + in property icon-svg; + in property icon-size: 1rem; + in property icon-colorize: Palette.foreground; + in property icon-svg-stroke-width: 1px; in property active: false; callback clicked; + callback right-clicked; background: root.active ? Palette.control-background @@ -20,10 +25,29 @@ export component ToggleButton inherits Rectangle { clicked => { root.clicked(); } + pointer-event(e) => { + if (e.button == PointerEventButton.right && e.kind == PointerEventKind.up) { + root.right-clicked(); + } + } } HorizontalLayout { - alignment: space-between; + alignment: start; + + //spacing: 16px; + if icon-svg != "" : VerticalLayout { + alignment: center; + padding-left: 8px; + padding-right: 8px; + Path { + commands: root.icon-svg; + stroke: icon-colorize; + stroke-width: icon-svg-stroke-width; + width: icon-size; + height: icon-size; + } + } VerticalLayout { padding: 8px; padding-top: 4px; @@ -32,6 +56,5 @@ export component ToggleButton inherits Rectangle { horizontal-alignment: center; } } - @children } }