chore: apply recommendations from clippy

This commit is contained in:
Cheong Lau 2025-10-04 10:51:18 +10:00 • committed by GitHub
parent cec55dafd7
commit 8e0f1c4a09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 720 additions and 824 deletions

View file

@ -65,15 +65,13 @@ impl App {
}
fn overflow_index(&self) -> Option<usize> {
let Some(max_major_axis_len) = self.core.applet.suggested_bounds.as_ref().map(|c| {
let max_major_axis_len = self.core.applet.suggested_bounds.as_ref().map(|c| {
// if we have a configure for width and height, we're in a overflow popup
match self.core.applet.anchor {
PanelAnchor::Top | PanelAnchor::Bottom => c.width as u32,
PanelAnchor::Left | PanelAnchor::Right => c.height as u32,
}
}) else {
return None;
};
})?;
let button_total_size =
self.core.applet.suggested_size(true).0 + self.core.applet.suggested_padding(true) * 2;
@ -111,7 +109,7 @@ impl App {
});
let theme = self.core.system_theme();
let cosmic = theme.cosmic();
let corners = cosmic.corner_radii.clone();
let corners = cosmic.corner_radii;
let pad = corners.radius_m[0];
self.core
@ -211,12 +209,12 @@ impl cosmic::Application for App {
self.resize_window()
}
status_notifier_watcher::Event::Error(err) => {
eprintln!("Status notifier error: {}", err);
eprintln!("Status notifier error: {err}");
Task::none()
}
},
Msg::TogglePopup(id) => {
self.open_menu = if self.open_menu != Some(id) {
self.open_menu = if self.open_menu.is_none() {
Some(id)
} else {
None
@ -232,15 +230,14 @@ impl cosmic::Application for App {
let i = self.menus.keys().position(|&i| i == id).unwrap();
let (i, parent) = self
.overflow_index()
.clone()
.and_then(|overflow_i| {
if overflow_i <= i {
Some(i - overflow_i).zip(self.overflow_popup.clone())
Some(i - overflow_i).zip(self.overflow_popup)
} else {
Some((i, self.core.main_window_id().unwrap()))
}
})
.unwrap_or_else(|| (0, self.core.main_window_id().unwrap()));
.unwrap_or((0, self.core.main_window_id().unwrap()));
let mut popup_settings = self
.core
@ -315,15 +312,14 @@ impl cosmic::Application for App {
let (i, parent) = self
.overflow_index()
.clone()
.and_then(|overflow_i| {
if overflow_i <= i {
Some(i - overflow_i).zip(self.overflow_popup.clone())
Some(i - overflow_i).zip(self.overflow_popup)
} else {
Some((i, self.core.main_window_id().unwrap()))
}
})
.unwrap_or_else(|| (0, self.core.main_window_id().unwrap()));
.unwrap_or((0, self.core.main_window_id().unwrap()));
let mut popup_settings = self
.core
@ -384,8 +380,7 @@ impl cosmic::Application for App {
}
self.overflow_popup = Some(popup_id);
let mut cmds = Vec::new();
cmds.push(get_popup(popup_settings));
let cmds = vec![get_popup(popup_settings)];
return Task::batch(cmds);
} else {
return Task::none();
@ -442,7 +437,7 @@ impl cosmic::Application for App {
subscriptions.push(status_notifier_watcher::subscription().map(Msg::StatusNotifier));
for (id, menu) in self.menus.iter() {
for (id, menu) in &self.menus {
subscriptions.push(menu.subscription().with(*id).map(Msg::StatusMenu));
}
subscriptions.push(activation_token_subscription(0).map(Msg::Token));
@ -513,7 +508,7 @@ impl cosmic::Application for App {
let theme = self.core.system_theme();
let cosmic = theme.cosmic();
let corners = cosmic.corner_radii.clone();
let corners = cosmic.corner_radii;
let pad = corners.radius_m[0];
match self.open_menu {
Some(id) => match self.menus.get(&id) {