Coverage Report

Created: 2026-09-05 23:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
super-stt-app/src/ui/icons.rs
Line
Count
Source
1
// SPDX-License-Identifier: GPL-3.0-only
2
3
//! Phosphor icons (regular weight) embedded for the settings UI.
4
//!
5
//! Source: <https://github.com/phosphor-icons/core> — SVGs use `currentColor`,
6
//! so they pick up the active theme via the symbolic flag.
7
8
use cosmic::iced::Length;
9
use cosmic::iced::widget::svg;
10
use cosmic::widget::icon::{self, Icon};
11
12
pub const GEAR: &[u8] = include_bytes!("../../resources/icons/phosphor/gear.svg");
13
pub const MICROPHONE: &[u8] = include_bytes!("../../resources/icons/phosphor/microphone.svg");
14
pub const KEYBOARD: &[u8] = include_bytes!("../../resources/icons/phosphor/keyboard.svg");
15
pub const BRAIN: &[u8] = include_bytes!("../../resources/icons/phosphor/brain.svg");
16
pub const PLUG: &[u8] = include_bytes!("../../resources/icons/phosphor/plug.svg");
17
pub const WARNING: &[u8] = include_bytes!("../../resources/icons/phosphor/warning.svg");
18
pub const CPU: &[u8] = include_bytes!("../../resources/icons/phosphor/cpu.svg");
19
pub const GRAPHICS_CARD: &[u8] = include_bytes!("../../resources/icons/phosphor/graphics-card.svg");
20
pub const CLOUD: &[u8] = include_bytes!("../../resources/icons/phosphor/cloud.svg");
21
pub const DOTS_THREE_VERTICAL: &[u8] =
22
    include_bytes!("../../resources/icons/phosphor/dots-three-vertical.svg");
23
pub const ARROWS_CLOCKWISE: &[u8] =
24
    include_bytes!("../../resources/icons/phosphor/arrows-clockwise.svg");
25
pub const PLAY: &[u8] = include_bytes!("../../resources/icons/phosphor/play.svg");
26
pub const STOP: &[u8] = include_bytes!("../../resources/icons/phosphor/stop.svg");
27
pub const GIT_BRANCH: &[u8] = include_bytes!("../../resources/icons/phosphor/git-branch.svg");
28
pub const BOOKS: &[u8] = include_bytes!("../../resources/icons/phosphor/books.svg");
29
pub const X: &[u8] = include_bytes!("../../resources/icons/phosphor/x.svg");
30
31
/// The Super STT app logo, full-color artwork. Not a Phosphor glyph, so it
32
/// lives at the app resources root rather than the phosphor set; shown beside
33
/// the app name in the window header.
34
pub const APP_LOGO: &[u8] = include_bytes!("../../resources/super-stt-icon.svg");
35
36
/// Build a themable [`Icon`] from one of the embedded Phosphor SVGs.
37
0
pub fn phosphor(bytes: &'static [u8]) -> Icon {
38
0
    icon::from_svg_bytes(bytes).symbolic(true).icon()
39
0
}
40
41
/// The symbolic [`Handle`](icon::Handle) for one of the embedded Phosphor SVGs,
42
/// for widgets that take a handle directly (e.g. `button::icon`).
43
0
pub fn phosphor_handle(bytes: &'static [u8]) -> icon::Handle {
44
0
    icon::from_svg_bytes(bytes).symbolic(true)
45
0
}
46
47
/// Shared builder for a fixed-size symbolic Phosphor [`Svg`](cosmic::widget::Svg)
48
/// tinted by a caller-supplied [`Svg`](cosmic::theme::Svg) color class. The
49
/// plain [`Icon`] wrapper hides the `svg::Style::color` knob that does the
50
/// tinting, so the tinted variants return the bare `Svg` widget instead.
51
0
fn tinted_svg(
52
0
    bytes: &'static [u8],
53
0
    size: f32,
54
0
    class: cosmic::theme::Svg,
55
0
) -> cosmic::widget::Svg<'static, cosmic::Theme> {
56
0
    cosmic::widget::Svg::<cosmic::Theme>::new(svg::Handle::from_memory(bytes))
57
0
        .symbolic(true)
58
0
        .class(class)
59
0
        .width(Length::Fixed(size))
60
0
        .height(Length::Fixed(size))
61
0
}
62
63
/// A Phosphor icon tinted with the theme's *destructive* (red) color — used
64
/// for unmet-requirement warnings inside a backend card.
65
0
pub fn phosphor_destructive(
66
0
    bytes: &'static [u8],
67
0
    size: f32,
68
0
) -> cosmic::widget::Svg<'static, cosmic::Theme> {
69
0
    tinted_svg(
70
0
        bytes,
71
0
        size,
72
0
        cosmic::theme::Svg::custom(|t| svg::Style {
73
0
            color: Some(t.cosmic().destructive.base.into()),
74
0
        }),
75
    )
76
0
}
77
78
/// A Phosphor icon tinted with the theme's *warning* (yellow) color — used
79
/// for the advisory "model may not fit in GPU memory" warning.
80
0
pub fn phosphor_warning(
81
0
    bytes: &'static [u8],
82
0
    size: f32,
83
0
) -> cosmic::widget::Svg<'static, cosmic::Theme> {
84
0
    tinted_svg(
85
0
        bytes,
86
0
        size,
87
0
        cosmic::theme::Svg::custom(|t| svg::Style {
88
0
            color: Some(t.cosmic().warning.base.into()),
89
0
        }),
90
    )
91
0
}
92
93
/// A Phosphor icon tinted with an explicit `color` the caller resolves from
94
/// the active theme. Used by the backend-capability chips, whose tone
95
/// (accent / neutral) is chosen at view-build time.
96
0
pub fn phosphor_tinted(
97
0
    bytes: &'static [u8],
98
0
    size: f32,
99
0
    color: cosmic::iced::Color,
100
0
) -> cosmic::widget::Svg<'static, cosmic::Theme> {
101
0
    tinted_svg(
102
0
        bytes,
103
0
        size,
104
0
        cosmic::theme::Svg::custom(move |_| svg::Style { color: Some(color) }),
105
    )
106
0
}
107
108
/// The Super STT logo ([`APP_LOGO`]) rendered at `size` px in its own colors.
109
///
110
/// The artwork is multi-color, so it is deliberately neither marked symbolic
111
/// nor given a tinting class: an explicit `svg::Style::color` is applied to the
112
/// whole image regardless of the symbolic flag, which would flatten the logo to
113
/// a single-color silhouette.
114
0
pub fn app_logo(size: f32) -> cosmic::widget::Svg<'static, cosmic::Theme> {
115
0
    cosmic::widget::Svg::<cosmic::Theme>::new(svg::Handle::from_memory(APP_LOGO))
116
0
        .width(Length::Fixed(size))
117
0
        .height(Length::Fixed(size))
118
0
}