chore: clippy

This commit is contained in:
Vukašin Vojinović 2026-04-16 19:18:11 +02:00 committed by Jacob Kauffmann
parent 96ce377ebf
commit eb55cd020f
12 changed files with 41 additions and 42 deletions

View file

@ -5,7 +5,7 @@ use cosmic::{
iced::stream,
surface,
theme::CosmicTheme,
widget::{dropdown, list, settings, text},
widget::{dropdown, settings, text},
};
pub use cosmic_comp_config::ZoomMovement;
use cosmic_config::CosmicConfigEntry;

View file

@ -12,7 +12,7 @@ use std::{
use cosmic::{
Apply, Element, Task,
cosmic_config::{self, ConfigGet, ConfigSet},
iced::{Length, stream},
iced::stream,
surface,
widget::{self, dropdown, settings, text},
};

View file

@ -4,7 +4,7 @@ use cosmic::cosmic_config::{Config, ConfigSet};
use cosmic::cosmic_theme::Spacing;
use cosmic::iced::core::{Color, Length};
use cosmic::widget::{
ColorPickerModel, color_picker::ColorPickerUpdate, container, flex_row, list, settings, text,
ColorPickerModel, color_picker::ColorPickerUpdate, container, flex_row, settings, text,
};
use cosmic::{Apply, Task};
use cosmic::{Element, widget};

View file

@ -6,8 +6,7 @@ use std::sync::Arc;
use cosmic::{
Apply, Element, Task,
config::{CosmicTk, FontConfig},
iced::core::text::Wrapping,
widget::{self, settings, svg},
widget,
};
use cosmic_config::ConfigSet;
@ -193,10 +192,11 @@ impl Model {
widget::list_column::with_capacity(families.len()),
|list, family| {
let selected = &**family == current_font;
list.add(
widget::list::button(selection_context_item(&**family, selected))
.on_press(callback(family.clone())),
)
list.add(selection_context_item(
family,
selected,
callback(family.clone()),
))
},
);
list.into()

View file

@ -22,8 +22,7 @@ use cosmic::dialog::file_chooser::{self, FileFilter};
use cosmic::iced::Subscription;
use cosmic::iced::core::{Alignment, Length};
use cosmic::widget::{
button, color_picker::ColorPickerUpdate, container, list, row, settings, space::horizontal,
text,
button, color_picker::ColorPickerUpdate, container, row, settings, space::horizontal, text,
};
use cosmic::{Apply, Element, Task, widget};
#[cfg(feature = "wayland")]

View file

@ -5,7 +5,7 @@ use cosmic::{
cosmic_theme::Density,
iced::{Alignment, Length},
surface,
widget::{button, container, dropdown, list, row, settings, slider, space, text},
widget::{button, container, dropdown, row, settings, slider, space, text},
};
use cosmic::Apply;
@ -290,7 +290,7 @@ pub(crate) fn configuration<P: page::Page<crate::pages::Message> + PanelPage>(
.find(|(_, v)| v.id == page.applets_page_id())
{
settings.add(crate::widget::go_next_item(
&*descriptions[applets_label],
&descriptions[applets_label],
crate::pages::Message::Page(panel_applets_entity),
))
} else {

View file

@ -4,7 +4,7 @@
use super::Message;
use cosmic::iced::Radius;
use cosmic::iced::core::Border;
use cosmic::iced::core::{self, Background, Color, Degrees, Length, gradient::Linear};
use cosmic::iced::core::{Background, Color, Degrees, Length, gradient::Linear};
use cosmic::iced::runtime::core::image::Handle as ImageHandle;
use cosmic::prelude::*;
use cosmic::widget::{Space, button, container};

View file

@ -3,7 +3,7 @@
use cosmic::{
Apply, Element,
iced::{Alignment, Length},
iced::Length,
surface,
widget::{self, settings},
};

View file

@ -6,9 +6,8 @@
use cosmic::{
Apply, Element,
cosmic_config::{self, ConfigGet, ConfigSet},
iced::Length,
surface,
widget::{self, settings, text},
widget::{self, settings},
};
use cosmic_comp_config::workspace::{Action, WorkspaceConfig, WorkspaceLayout, WorkspaceMode};
use cosmic_settings_page::Section;

View file

@ -335,10 +335,11 @@ impl Page {
for (id, timezone) in self.timezone_list.iter().enumerate() {
if search_input.is_empty() || timezone.to_lowercase().contains(search_input) {
list = list.add(
list::button(selection_context_item(timezone, Some(id) == self.timezone))
.on_press(Message::Timezone(id)),
);
list = list.add(selection_context_item(
timezone,
Some(id) == self.timezone,
Message::Timezone(id),
));
}
}
@ -471,7 +472,7 @@ fn timezone() -> Section<crate::pages::Message> {
.title(&section.title)
// Time zone select
.add(crate::widget::go_next_with_item(
&*section.descriptions[time_zone],
&section.descriptions[time_zone],
widget::text::body(
page.timezone
.map(|id| &*page.timezone_list[id])

View file

@ -375,17 +375,15 @@ impl Page {
.as_ref()
.is_some_and(|(_, locales)| locales.contains(&available_language.lang_code));
list = list.add(
list::button(selection_context_item(
&available_language.display_name,
is_installed,
))
.on_press(if is_installed {
list = list.add(selection_context_item(
&available_language.display_name,
is_installed,
if is_installed {
Message::RemoveLanguage(id)
} else {
Message::AddLanguage(id)
}),
)
},
))
}
}
@ -478,14 +476,15 @@ impl Page {
.as_ref()
.is_some_and(|l| l.lang_code == locale.lang_code);
list = list.add(
list::button(selection_context_item(&locale.region_name, is_selected))
.on_press_maybe(if is_selected {
None
} else {
Some(Message::SelectRegion(id))
}),
)
list = list.add(selection_context_item(
&locale.region_name,
is_selected,
if is_selected {
None
} else {
Some(Message::SelectRegion(id))
},
))
}
}

View file

@ -204,7 +204,7 @@ pub fn go_next_with_item<'a, Msg: 'static>(
description: &'a str,
item: impl Into<cosmic::Element<'a, Msg>>,
msg_opt: impl Into<Option<Msg>>,
) -> list::ListButton<'_, Msg> {
) -> list::ListButton<'a, Msg> {
settings::item_row(vec![
text::body(description).wrapping(Wrapping::Word).into(),
horizontal().into(),
@ -217,13 +217,13 @@ pub fn go_next_with_item<'a, Msg: 'static>(
])
.apply(list::button)
.on_press_maybe(msg_opt.into())
.into()
}
pub fn selection_context_item<'a, Msg: 'static>(
name: &'a str,
selected: bool,
) -> cosmic::Element<'a, Msg> {
msg_opt: impl Into<Option<Msg>>,
) -> list::ListButton<'a, Msg> {
let svg_accent = Rc::new(|theme: &cosmic::Theme| widget::svg::Style {
color: Some(theme.cosmic().accent_text_color().into()),
});
@ -248,5 +248,6 @@ pub fn selection_context_item<'a, Msg: 'static>(
horizontal().width(16.).into()
},
])
.into()
.apply(list::button)
.on_press_maybe(msg_opt.into())
}