fix clippy warnings

This commit is contained in:
Samuel Onoja committed 2026-10-01 13:24:21 +01:00
1 parent 7b88083020
commit bdc3ba435f
39 files changed
+825 -688

No files matched your search

+3 -11
View File
@@ -6,7 +6,7 @@ use super::bar::status_icon;
use super::controls::status_summary;
use super::{Menu, MenuRows, MenuStyle};
use crate::status::Action;
use crate::{FereseShell, Message, color_with_opacity, text};
use crate::{FereseShell, Message, text};
const DEVICE_LIST_HEIGHT: f32 = 180.0;
@@ -15,12 +15,7 @@ fn device_list_height(count: usize) -> Option<f32> {
}
pub(super) fn view<'a>(shell: &'a FereseShell, mut rows: MenuRows<'a>, style: MenuStyle) -> MenuRows<'a> {
let MenuStyle {
theme,
primary,
muted,
opacity: p,
} = style;
let MenuStyle { muted, .. } = style;
if let Some(b) = &shell.status.bluetooth {
rows = rows.push(status_summary(
status_icon(Menu::Bluetooth, &shell.status).0,
@@ -36,10 +31,7 @@ pub(super) fn view<'a>(shell: &'a FereseShell, mut rows: MenuRows<'a>, style: Me
} else {
"Your connected devices"
},
primary,
muted,
color_with_opacity(theme.accent, p),
p,
style,
b.enabled,
Some((b.enabled, Action::Bluetooth(!b.enabled))),
));
+9 -5
View File
@@ -3,19 +3,23 @@ use cosmic::widget::{button, column, container, row, slider};
use cosmic::{Element, theme};
use crate::status::Action;
use crate::{Message, ShellTheme, accented_icon, color, motion, shell_font, text};
use crate::{Message, ShellTheme, accented_icon, color, color_with_opacity, motion, shell_font, text};
pub(super) fn status_summary<'a>(
source: &'static [u8],
title: &'a str,
subtitle: &'a str,
primary: Color,
muted: Color,
accent: Color,
opacity: f32,
style: super::MenuStyle,
enabled: bool,
toggle: Option<(bool, Action)>,
) -> Element<'a, cosmic::Action<Message>> {
let super::MenuStyle {
theme,
primary,
muted,
opacity,
} = style;
let accent = color_with_opacity(theme.accent, opacity);
let badge_color = if enabled { accent } else { primary };
let badge = container(accented_icon(source, 22, primary, accent))
.width(32)
+3 -9
View File
@@ -5,14 +5,11 @@ use super::bar::status_icon;
use super::controls::{level_meter, shell_switch, status_summary};
use super::{Menu, MenuRows, MenuStyle};
use crate::status::Action;
use crate::{FereseShell, color_with_opacity, text};
use crate::{FereseShell, text};
pub(super) fn view<'a>(shell: &'a FereseShell, mut rows: MenuRows<'a>, style: MenuStyle) -> MenuRows<'a> {
let MenuStyle {
theme,
primary,
muted,
opacity: p,
primary, opacity: p, ..
} = style;
if let Some(n) = &shell.status.network {
let connected = n.enabled && n.connection.is_some();
@@ -30,10 +27,7 @@ pub(super) fn view<'a>(shell: &'a FereseShell, mut rows: MenuRows<'a>, style: Me
} else {
"Wireless connections are paused"
},
primary,
muted,
color_with_opacity(theme.accent, p),
p,
style,
n.enabled,
None,
));
+15 -15
View File
@@ -178,21 +178,6 @@ fn connection_control<'a>(
container(tile).width(Length::FillPortion(1)).into()
}
#[cfg(test)]
mod tests {
#[test]
fn connection_captions_fit_one_short_line() {
assert_eq!(super::connection_caption("88%"), "88%");
assert_eq!(super::connection_caption("Flow84@Lofree"), "Flow84@Lofr…");
assert_eq!(super::connection_caption("123456789012"), "123456789012");
assert_eq!(super::connection_caption("My very long headphones"), "My very lon…");
assert_eq!(super::connection_caption(" Device\n name "), "Device name");
let caption = super::connection_caption("耳機耳機耳機耳機耳機耳機耳機");
assert_eq!(caption.chars().count(), 12);
assert!(caption.ends_with('…'));
}
}
pub(super) fn heading<'a>(
shell: &'a FereseShell,
mut heading: super::MenuHeading<'a>,
@@ -229,3 +214,18 @@ pub(super) fn heading<'a>(
}
heading
}
#[cfg(test)]
mod tests {
#[test]
fn connection_captions_fit_one_short_line() {
assert_eq!(super::connection_caption("88%"), "88%");
assert_eq!(super::connection_caption("Flow84@Lofree"), "Flow84@Lofr…");
assert_eq!(super::connection_caption("123456789012"), "123456789012");
assert_eq!(super::connection_caption("My very long headphones"), "My very lon…");
assert_eq!(super::connection_caption(" Device\n name "), "Device name");
let caption = super::connection_caption("耳機耳機耳機耳機耳機耳機耳機");
assert_eq!(caption.chars().count(), 12);
assert!(caption.ends_with('…'));
}
}