Coverage Report

Created: 2026-07-21 00:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
super-stt-cosmic-applet/src/ui/sections/settings/section.rs
Line
Count
Source
1
// SPDX-License-Identifier: GPL-3.0-only
2
use cosmic::{
3
    Apply, Element,
4
    applet::padded_control,
5
    iced::{
6
        Alignment, Length,
7
        widget::{column, row, slider},
8
    },
9
    theme,
10
    widget::{
11
        Space, divider, segmented_button::SingleSelectModel, segmented_control, text, toggler,
12
    },
13
};
14
15
use crate::{
16
    app::Message,
17
    config::AppletConfig,
18
    models::state::IsOpen,
19
    ui::sections::settings::components::visualization_theme::{
20
        create_visualization_color_selector, create_visualization_theme_selector,
21
        create_working_animation_selector,
22
    },
23
};
24
25
0
pub fn create_applet_settings_section<'a>(
26
0
    config: &AppletConfig,
27
0
    is_open: &IsOpen,
28
0
    icon_alignment_model: &'a SingleSelectModel,
29
0
    theme_selector_model: &'a SingleSelectModel,
30
0
    selected_theme_for_config: bool,
31
0
) -> Element<'a, Message> {
32
0
    let spacing = theme::active().cosmic().spacing;
33
34
0
    let mut settings_column = column![
35
        // Show visualizations toggle
36
0
        padded_control(
37
0
            row![
38
0
                text::body("Show Visualization"),
39
0
                Space::new().width(Length::Fill),
40
0
                toggler(config.ui.show_visualization).on_toggle(Message::SetShowVisualizations)
41
            ]
42
0
            .spacing(spacing.space_xs)
43
0
            .align_y(Alignment::Center),
44
        ),
45
    ]
46
0
    .spacing(spacing.space_xs)
47
0
    .width(Length::Fill);
48
49
    // Visualization size slide (only show if the visualization is enabled)
50
0
    if config.ui.show_visualization {
51
0
        // Width slider
52
0
        settings_column = settings_column.push(
53
0
            column![
54
0
                padded_control(
55
0
                    column![
56
0
                        text::body("Visualization Size"),
57
0
                        row![
58
0
                            text::caption(format!("{}px", config.ui.applet_width)),
59
0
                            slider(60..=300, config.ui.applet_width, Message::SetAppletWidth)
60
0
                                .width(Length::Fill)
61
0
                        ]
62
0
                        .spacing(spacing.space_xs)
63
0
                        .align_y(Alignment::Center),
64
0
                    ]
65
0
                    .spacing(spacing.space_xxs)
66
0
                    .apply(Element::from)
67
0
                ),
68
0
                create_visualization_theme_selector(&config.visualization.theme, is_open),
69
0
                create_working_animation_selector(config.visualization.working_animation, is_open),
70
0
                create_visualization_color_selector(
71
0
                    &config.visualization.colors,
72
0
                    is_open,
73
0
                    theme_selector_model,
74
0
                    selected_theme_for_config
75
0
                )
76
0
            ]
77
0
            .spacing(spacing.space_xxs)
78
0
            .apply(Element::from),
79
0
        );
80
0
    }
81
82
0
    settings_column = settings_column.push(
83
0
        padded_control(divider::horizontal::default())
84
0
            .padding([0, spacing.space_s])
85
0
            .apply(Element::from),
86
    );
87
88
0
    settings_column = settings_column.push(
89
        // Show icon toggle
90
0
        padded_control(
91
0
            row![
92
0
                text::body("Show Icon"),
93
0
                Space::new().width(Length::Fill),
94
0
                toggler(config.ui.show_icon).on_toggle(Message::SetShowIcon)
95
            ]
96
0
            .spacing(spacing.space_xs)
97
0
            .align_y(Alignment::Center),
98
        ),
99
    );
100
101
    // Icon alignment selector (only show if icon is enabled)
102
0
    if config.ui.show_icon {
103
0
        settings_column = settings_column.push(
104
0
            padded_control(
105
0
                column![
106
0
                    text::body("Icon Position"),
107
0
                    segmented_control::horizontal(icon_alignment_model)
108
0
                        .on_activate(Message::SetIconAlignmentEntity)
109
0
                ]
110
0
                .spacing(spacing.space_xxs)
111
0
                .apply(Element::from),
112
0
            )
113
0
            .apply(Element::from),
114
0
        );
115
0
    }
116
117
0
    settings_column.apply(Element::from)
118
0
}