chore: clippy fixes

This commit is contained in:
Michael Aaron Murphy 2024-02-19 13:12:30 +01:00 • committed by Michael Murphy
parent 02ff3e6445
commit 644997823e
7 changed files with 29 additions and 44 deletions

View file

@ -10,7 +10,7 @@ use cosmic::cosmic_theme::palette::{FromColor, Hsv, Srgb, Srgba};
use cosmic::cosmic_theme::{CornerRadii, Theme, ThemeBuilder, ThemeMode}; use cosmic::cosmic_theme::{CornerRadii, Theme, ThemeBuilder, ThemeMode};
use cosmic::iced::wayland::actions::window::SctkWindowSettings; use cosmic::iced::wayland::actions::window::SctkWindowSettings;
use cosmic::iced::window; use cosmic::iced::window;
use cosmic::iced_core::{alignment, layout, Alignment, Color, Length}; use cosmic::iced_core::{alignment, layout, Color, Length};
use cosmic::iced_sctk::commands::window::{close_window, get_window}; use cosmic::iced_sctk::commands::window::{close_window, get_window};
use cosmic::iced_widget::scrollable; use cosmic::iced_widget::scrollable;
use cosmic::widget::icon::{from_name, icon}; use cosmic::widget::icon::{from_name, icon};
@ -300,7 +300,7 @@ impl Page {
*self = Self::from((self.theme_mode_config.clone(), self.theme_mode)); *self = Self::from((self.theme_mode_config.clone(), self.theme_mode));
let theme_builder = self.theme_builder.clone(); let theme_builder = self.theme_builder.clone();
Command::perform(async {}, |_| { Command::perform(async {}, |()| {
crate::Message::SetTheme(cosmic::theme::Theme::custom(Arc::new( crate::Message::SetTheme(cosmic::theme::Theme::custom(Arc::new(
// TODO set the values of the theme builder // TODO set the values of the theme builder
theme_builder.build(), theme_builder.build(),
@ -312,7 +312,6 @@ impl Page {
if let Some(config) = self.theme_mode_config.as_ref() { if let Some(config) = self.theme_mode_config.as_ref() {
_ = config.set::<bool>("auto_switch", enabled); _ = config.set::<bool>("auto_switch", enabled);
} }
if !enabled {}
Command::none() Command::none()
} }
Message::AccentWindowHint(u) => { Message::AccentWindowHint(u) => {
@ -419,7 +418,7 @@ impl Page {
let cmd = match &u { let cmd = match &u {
ColorPickerUpdate::AppliedColor | ColorPickerUpdate::Reset => { ColorPickerUpdate::AppliedColor | ColorPickerUpdate::Reset => {
theme_builder_needs_update = true; theme_builder_needs_update = true;
Command::perform(async {}, |_| crate::app::Message::CloseContextDrawer) Command::perform(async {}, |()| crate::app::Message::CloseContextDrawer)
} }
ColorPickerUpdate::ActionFinished => { ColorPickerUpdate::ActionFinished => {
theme_builder_needs_update = true; theme_builder_needs_update = true;
@ -429,9 +428,9 @@ impl Page {
Command::none() Command::none()
} }
ColorPickerUpdate::Cancel => { ColorPickerUpdate::Cancel => {
Command::perform(async {}, |_| crate::app::Message::CloseContextDrawer) Command::perform(async {}, |()| crate::app::Message::CloseContextDrawer)
} }
ColorPickerUpdate::ToggleColorPicker => Command::perform(async {}, |_| { ColorPickerUpdate::ToggleColorPicker => Command::perform(async {}, |()| {
crate::app::Message::OpenContextDrawer(fl!("container-background").into()) crate::app::Message::OpenContextDrawer(fl!("container-background").into())
}), }),
_ => Command::none(), _ => Command::none(),
@ -591,7 +590,7 @@ impl Page {
Message::Entered => { Message::Entered => {
*self = Self::default(); *self = Self::default();
let theme_builder = self.theme_builder.clone(); let theme_builder = self.theme_builder.clone();
Command::perform(async {}, |_| { Command::perform(async {}, |()| {
crate::Message::SetTheme(cosmic::theme::Theme::custom(Arc::new( crate::Message::SetTheme(cosmic::theme::Theme::custom(Arc::new(
// TODO set the values of the theme builder // TODO set the values of the theme builder
theme_builder.build(), theme_builder.build(),
@ -600,7 +599,7 @@ impl Page {
// Load the current theme builders and mode // Load the current theme builders and mode
// Set the theme for the application to match the current mode instead of the system theme? // Set the theme for the application to match the current mode instead of the system theme?
} }
Message::Left => Command::perform(async {}, |_| { Message::Left => Command::perform(async {}, |()| {
app::Message::SetTheme(cosmic::theme::system_preference()) app::Message::SetTheme(cosmic::theme::system_preference())
}), }),
Message::PaletteAccent(c) => { Message::PaletteAccent(c) => {
@ -631,7 +630,7 @@ impl Page {
} }
*self = Self::from((self.theme_mode_config.clone(), self.theme_mode)); *self = Self::from((self.theme_mode_config.clone(), self.theme_mode));
Command::perform(async {}, |_| { Command::perform(async {}, |()| {
crate::Message::SetTheme(cosmic::theme::Theme::custom(Arc::new(new_theme))) crate::Message::SetTheme(cosmic::theme::Theme::custom(Arc::new(new_theme)))
}) })
} }
@ -639,7 +638,7 @@ impl Page {
async { async {
SelectedFiles::open_file() SelectedFiles::open_file()
.modal(true) .modal(true)
.filter(FileFilter::glob(FileFilter::new("ron").into(), "*.ron")) .filter(FileFilter::glob(FileFilter::new("ron"), "*.ron"))
.send() .send()
.await? .await?
.response() .response()
@ -688,7 +687,7 @@ impl Page {
) )
} }
Message::ImportFile(f) => { Message::ImportFile(f) => {
let Some(f) = f.uris().get(0) else { let Some(f) = f.uris().first() else {
return Command::none(); return Command::none();
}; };
if f.scheme() != "file" { if f.scheme() != "file" {
@ -715,7 +714,7 @@ impl Page {
) )
} }
Message::ExportFile(f) => { Message::ExportFile(f) => {
let Some(f) = f.uris().get(0) else { let Some(f) = f.uris().first() else {
return Command::none(); return Command::none();
}; };
if f.scheme() != "file" { if f.scheme() != "file" {
@ -775,7 +774,7 @@ impl Page {
} }
*self = Self::from((self.theme_mode_config.clone(), self.theme_mode)); *self = Self::from((self.theme_mode_config.clone(), self.theme_mode));
Command::perform(async {}, |_| { Command::perform(async {}, |()| {
crate::Message::SetTheme(cosmic::theme::Theme::custom(Arc::new(new_theme))) crate::Message::SetTheme(cosmic::theme::Theme::custom(Arc::new(new_theme)))
}) })
} }
@ -811,7 +810,7 @@ impl Page {
); );
_ = self.accent_window_hint.update::<app::Message>( _ = self.accent_window_hint.update::<app::Message>(
ColorPickerUpdate::ActiveColor(Hsv::from_color(window_hint)), ColorPickerUpdate::ActiveColor(Hsv::from_color(window_hint)),
) );
}; };
Command::none() Command::none()
} }
@ -859,7 +858,7 @@ impl Page {
let theme_builder = self.theme_builder.clone(); let theme_builder = self.theme_builder.clone();
ret = Command::batch(vec![ ret = Command::batch(vec![
ret, ret,
Command::perform(async {}, |_| { Command::perform(async {}, |()| {
crate::Message::SetTheme(cosmic::theme::Theme::custom(Arc::new( crate::Message::SetTheme(cosmic::theme::Theme::custom(Arc::new(
theme_builder.build(), theme_builder.build(),
))) )))
@ -969,7 +968,7 @@ impl page::Page<crate::pages::Message> for Page {
} }
fn on_leave(&mut self) -> Command<crate::pages::Message> { fn on_leave(&mut self) -> Command<crate::pages::Message> {
Command::perform(async {}, |_| { Command::perform(async {}, |()| {
crate::pages::Message::Appearance(Message::Left) crate::pages::Message::Appearance(Message::Left)
}) })
} }

View file

@ -434,13 +434,7 @@ impl Page {
list.retain(|id| id != &to_remove); list.retain(|id| id != &to_remove);
self.save(); self.save();
} }
Message::DetailStart(_) => { Message::DetailStart(_) | Message::DetailCenter(_) | Message::DetailEnd(_) => {
// TODO ask design team
}
Message::DetailCenter(_) => {
// TODO ask design team
}
Message::DetailEnd(_) => {
// TODO ask design team // TODO ask design team
} }
Message::Cancel => { Message::Cancel => {

View file

@ -32,8 +32,8 @@ pub struct PageInner {
impl Default for PageInner { impl Default for PageInner {
fn default() -> Self { fn default() -> Self {
Self { Self {
config_helper: Default::default(), config_helper: Option::default(),
panel_config: Default::default(), panel_config: Option::default(),
outputs: vec![fl!("all")], outputs: vec![fl!("all")],
anchors: vec![ anchors: vec![
Anchor(PanelAnchor::Left).to_string(), Anchor(PanelAnchor::Left).to_string(),
@ -46,8 +46,8 @@ impl Default for PageInner {
Appearance::Light.to_string(), Appearance::Light.to_string(),
Appearance::Dark.to_string(), Appearance::Dark.to_string(),
], ],
container_config: Default::default(), container_config: Option::default(),
outputs_map: Default::default(), outputs_map: HashMap::default(),
} }
} }
} }
@ -282,10 +282,10 @@ pub struct Anchor(PanelAnchor);
impl ToString for Anchor { impl ToString for Anchor {
fn to_string(&self) -> String { fn to_string(&self) -> String {
match self.0 { match self.0 {
PanelAnchor::Top => fl!("panel-top").into(), PanelAnchor::Top => fl!("panel-top"),
PanelAnchor::Bottom => fl!("panel-bottom").into(), PanelAnchor::Bottom => fl!("panel-bottom"),
PanelAnchor::Left => fl!("panel-left").into(), PanelAnchor::Left => fl!("panel-left"),
PanelAnchor::Right => fl!("panel-right").into(), PanelAnchor::Right => fl!("panel-right"),
} }
} }
} }
@ -349,7 +349,7 @@ impl PageInner {
#[allow(clippy::too_many_lines)] #[allow(clippy::too_many_lines)]
pub fn update(&mut self, message: Message) { pub fn update(&mut self, message: Message) {
let helper = self.config_helper.as_ref().unwrap(); let helper = self.config_helper.as_ref().unwrap();
let Some(mut panel_config) = self.panel_config.as_mut() else { let Some(panel_config) = self.panel_config.as_mut() else {
return; return;
}; };
@ -384,7 +384,7 @@ impl PageInner {
if i == 0 { if i == 0 {
panel_config.output = CosmicPanelOuput::All; panel_config.output = CosmicPanelOuput::All;
} else { } else {
panel_config.output = CosmicPanelOuput::Name(self.outputs[i].clone()) panel_config.output = CosmicPanelOuput::Name(self.outputs[i].clone());
} }
} }
Message::AnchorGap(enabled) => { Message::AnchorGap(enabled) => {

View file

@ -46,7 +46,6 @@ use cosmic_settings_wallpaper::{self as wallpaper, Entry, ScalingMode};
use image::imageops::FilterType::Lanczos3; use image::imageops::FilterType::Lanczos3;
use image::{ImageBuffer, Rgba}; use image::{ImageBuffer, Rgba};
use slotmap::{DefaultKey, SecondaryMap, SlotMap}; use slotmap::{DefaultKey, SecondaryMap, SlotMap};
use std::borrow::Cow;
const ZOOM: usize = 0; const ZOOM: usize = 0;
const FIT: usize = 1; const FIT: usize = 1;

View file

@ -17,7 +17,6 @@ use cosmic::{command, Command, Element};
use cosmic_randr_shell::{List, Output, OutputKey, Transform}; use cosmic_randr_shell::{List, Output, OutputKey, Transform};
use cosmic_settings_page::{self as page, section, Section}; use cosmic_settings_page::{self as page, section, Section};
use slotmap::{Key, SlotMap}; use slotmap::{Key, SlotMap};
use std::borrow::Cow;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::{process::ExitStatus, sync::Arc}; use std::{process::ExitStatus, sync::Arc};

View file

@ -29,13 +29,7 @@ impl page::AutoBind<crate::pages::Message> for Page {}
fn shortcuts() -> Section<crate::pages::Message> { fn shortcuts() -> Section<crate::pages::Message> {
Section::default() Section::default()
.descriptions(vec![]) .descriptions(vec![])
.view::<Page>(|binder, _page, section| { .view::<Page>(|_binder, _page, section| {
let _descriptions = &section.descriptions;
let _input = binder
.page::<super::super::Page>()
.expect("input page not found");
// TODO need something more custom // TODO need something more custom
/* /*
settings::view_section(&section.title) settings::view_section(&section.title)

View file

@ -129,7 +129,7 @@ pub fn hardware_model(bump: &Bump, hardware_model: &mut String) {
None => name, None => name,
}; };
strcat!(&mut *hardware_model, " " name); let _str = strcat!(&mut *hardware_model, " " name);
} }
let buffer = &mut bumpalo::collections::Vec::new_in(bump); let buffer = &mut bumpalo::collections::Vec::new_in(bump);
@ -137,7 +137,7 @@ pub fn hardware_model(bump: &Bump, hardware_model: &mut String) {
version = version.trim(); version = version.trim();
if !version.is_empty() && !VERSION_IGNORING_PRODUCTS.contains(&name) { if !version.is_empty() && !VERSION_IGNORING_PRODUCTS.contains(&name) {
strcat!(hardware_model, " (" version.trim() ")"); let _str = strcat!(hardware_model, " (" version.trim() ")");
} }
} }
} }