some clippy stuff
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
Chris Cochrun 2026-02-12 15:48:43 -06:00
parent 28d09120e0
commit 2ca91dbc44
5 changed files with 61 additions and 68 deletions

View file

@ -80,7 +80,7 @@ pub enum VerseName {
}
impl VerseName {
#[must_use]
#[must_use]
pub fn from_string(name: String) -> Self {
match name.as_str() {
"Verse" => Self::Verse { number: 1 },
@ -97,7 +97,7 @@ impl VerseName {
}
}
#[must_use]
#[must_use]
pub fn all_names() -> Vec<String> {
vec![
"Verse".into(),
@ -113,7 +113,7 @@ impl VerseName {
]
}
#[must_use]
#[must_use]
pub fn next(&self) -> Self {
match self {
Self::Verse { number } => {
@ -289,15 +289,13 @@ impl ServiceTrait for Song {
let slides: Vec<Slide> = lyrics
.iter()
.filter_map(|l| {
let font =
Font::default()
.name(
self.font
.clone()
.unwrap_or_else(|| "Calibri".into()),
)
.size(self.font_size.unwrap_or(100)
as u8);
let font = Font::default()
.name(
self.font
.clone()
.unwrap_or_else(|| "Calibri".into()),
)
.size(self.font_size.unwrap_or(100) as u8);
let stroke_size =
self.stroke_size.unwrap_or_default();
let stroke: Stroke = stroke(
@ -901,18 +899,21 @@ pub async fn update_song_in_db(
});
let lyrics = ron::ser::to_string(&lyrics).into_diagnostic()?;
let (vertical_alignment, horizontal_alignment) = item
.text_alignment.map_or_else(|| ("center", "center"), |ta| match ta {
TextAlignment::TopLeft => ("top", "left"),
TextAlignment::TopCenter => ("top", "center"),
TextAlignment::TopRight => ("top", "right"),
TextAlignment::MiddleLeft => ("center", "left"),
TextAlignment::MiddleCenter => ("center", "center"),
TextAlignment::MiddleRight => ("center", "right"),
TextAlignment::BottomLeft => ("bottom", "left"),
TextAlignment::BottomCenter => ("bottom", "center"),
TextAlignment::BottomRight => ("bottom", "right"),
});
let (vertical_alignment, horizontal_alignment) =
item.text_alignment.map_or_else(
|| ("center", "center"),
|ta| match ta {
TextAlignment::TopLeft => ("top", "left"),
TextAlignment::TopCenter => ("top", "center"),
TextAlignment::TopRight => ("top", "right"),
TextAlignment::MiddleLeft => ("center", "left"),
TextAlignment::MiddleCenter => ("center", "center"),
TextAlignment::MiddleRight => ("center", "right"),
TextAlignment::BottomLeft => ("bottom", "left"),
TextAlignment::BottomCenter => ("bottom", "center"),
TextAlignment::BottomRight => ("bottom", "right"),
},
);
let stroke_size = item.stroke_size.unwrap_or_default();
let shadow_size = item.shadow_size.unwrap_or_default();
@ -966,7 +967,6 @@ pub async fn update_song_in_db(
impl Song {
#[must_use]
pub fn get_lyric(&self, verse: &VerseName) -> Option<String> {
self.verse_map.as_ref().and_then(|verse_map| {
verse_map.get(verse).cloned().map(|lyric| {
lyric.trim().trim_end_matches('\n').to_string()
@ -1184,7 +1184,7 @@ impl Song {
}
}
#[must_use]
#[must_use]
pub fn get_next_verse_name(&self) -> VerseName {
if let Some(verse_names) = &self.verses {
let verses: Vec<&VerseName> = verse_names

View file

@ -1512,14 +1512,15 @@ impl cosmic::Application for App {
}
Message::Save => {
let service = self.service.clone();
let file = self.file.clone();
let file1 = self.file.clone();
let file2 = self.file.clone();
Task::perform(
file::save(service, file.clone()),
async move { file::save(service, file1) },
move |res| match res {
Ok(()) => {
tracing::info!(
"saving file to: {:?}",
file
file2
);
cosmic::Action::None
}

View file

@ -23,9 +23,8 @@ use cosmic::{
},
prelude::*,
widget::{
Container, Id, Row, Space, container,
context_menu, image, menu, mouse_area, responsive,
scrollable, text,
Container, Id, Row, Space, container, context_menu, image,
menu, mouse_area, responsive, scrollable, text,
},
};
use iced_video_player::{Position, Video, VideoPlayer, gst_pbutils};

View file

@ -478,8 +478,7 @@ impl SongEditor {
) => {
if let Some(mut song) = self.song.clone()
{
let old_verse_name =
verse.verse_name;
let old_verse_name = verse.verse_name;
let verse_name = song
.verse_name_from_str(
@ -530,9 +529,9 @@ impl SongEditor {
inner_verse.verse_name
== verse
})
{
verses.remove(verse);
}
{
verses.remove(verse);
}
return Action::Task(
self.update_song(song),
);
@ -1148,10 +1147,8 @@ impl SongEditor {
))
};
let selected_font = self
.song
.as_ref()
.and_then(|song| song.font.as_ref());
let selected_font =
self.song.as_ref().and_then(|song| song.font.as_ref());
let font_selector = tooltip(
stack![
@ -1183,10 +1180,10 @@ impl SongEditor {
)
.gap(10);
let selected_font_size = self
.song
.as_ref()
.and_then(|song| song.font_size.map(|size| size.to_string()));
let selected_font_size =
self.song.as_ref().and_then(|song| {
song.font_size.map(|size| size.to_string())
});
let font_size = tooltip(
stack![
@ -1361,11 +1358,9 @@ impl SongEditor {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10", "11", "12", "13", "14", "15",
],
self.song
.as_ref()
.and_then(|song| {
song.shadow_size.map(|size| size as usize)
}),
self.song.as_ref().and_then(|song| {
song.shadow_size.map(|size| size as usize)
}),
|i| Message::UpdateShadowSize(i as u16),
)
.gap(5.0);
@ -1376,11 +1371,9 @@ impl SongEditor {
"10", "11", "12", "13", "14", "15", "16", "17", "18",
"19", "20",
],
self.song
.as_ref()
.and_then(|song| {
song.shadow_offset.map(|offset| offset.0 as usize)
}),
self.song.as_ref().and_then(|song| {
song.shadow_offset.map(|offset| offset.0 as usize)
}),
|i| Message::UpdateShadowOffsetX(i as i16),
)
.gap(5.0);
@ -1391,11 +1384,9 @@ impl SongEditor {
"10", "11", "12", "13", "14", "15", "16", "17", "18",
"19", "20",
],
self.song
.as_ref()
.and_then(|song| {
song.shadow_offset.map(|offset| offset.1 as usize)
}),
self.song.as_ref().and_then(|song| {
song.shadow_offset.map(|offset| offset.1 as usize)
}),
|i| Message::UpdateShadowOffsetY(i as i16),
)
.gap(5.0);

View file

@ -175,7 +175,7 @@ impl Hash for Color {
}
impl Color {
#[must_use]
#[must_use]
pub fn to_css_hex_string(&self) -> String {
format!("#{:x}", self.0.into_format::<u8>())
}
@ -334,15 +334,18 @@ impl TextSvg {
("end", position, x_width_padded.as_str())
}
TextAlignment::BottomLeft => {
let position = (total_lines as f32).mul_add(-text_and_line_spacing, size.height);
let position = (total_lines as f32)
.mul_add(-text_and_line_spacing, size.height);
("start", position, "10")
}
TextAlignment::BottomCenter => {
let position = (total_lines as f32).mul_add(-text_and_line_spacing, size.height);
let position = (total_lines as f32)
.mul_add(-text_and_line_spacing, size.height);
("middle", position, center_y.as_str())
}
TextAlignment::BottomRight => {
let position = (total_lines as f32).mul_add(-text_and_line_spacing, size.height);
let position = (total_lines as f32)
.mul_add(-text_and_line_spacing, size.height);
("end", position, x_width_padded.as_str())
}
};
@ -439,10 +442,9 @@ impl TextSvg {
resvg::render(&resvg_tree, transform, &mut pixmap.as_mut());
// debug!("rendered");
if cache
&& let Err(e) = pixmap.save_png(&path) {
error!(?e, "Couldn't save a copy of the text");
}
if cache && let Err(e) = pixmap.save_png(&path) {
error!(?e, "Couldn't save a copy of the text");
}
// debug!("saved");
// let handle = Handle::from_path(path);