perf, pedantic, nursery, and unwrap_used clippy fixes
This commit is contained in:
parent
a186d3bec4
commit
3fe77c93e2
15 changed files with 195 additions and 207 deletions
|
|
@ -133,13 +133,13 @@ impl<'a> Library {
|
|||
if kind != LibraryKind::Song {
|
||||
error!("Not editing a song item");
|
||||
return Action::None;
|
||||
};
|
||||
}
|
||||
|
||||
match self
|
||||
.song_library
|
||||
.update_item(song.clone(), index)
|
||||
{
|
||||
Ok(_) => {
|
||||
Ok(()) => {
|
||||
return Action::Task(
|
||||
Task::future(self.db.acquire()).and_then(
|
||||
move |conn| update_in_db(&song, conn),
|
||||
|
|
@ -162,13 +162,13 @@ impl<'a> Library {
|
|||
if kind != LibraryKind::Image {
|
||||
error!("Not editing a image item");
|
||||
return Action::None;
|
||||
};
|
||||
}
|
||||
|
||||
match self
|
||||
.image_library
|
||||
.update_item(image.clone(), index)
|
||||
{
|
||||
Ok(_) => {
|
||||
Ok(()) => {
|
||||
return Action::Task(
|
||||
Task::future(self.db.acquire()).and_then(
|
||||
move |conn| {
|
||||
|
|
@ -196,13 +196,13 @@ impl<'a> Library {
|
|||
if kind != LibraryKind::Video {
|
||||
error!("Not editing a video item");
|
||||
return Action::None;
|
||||
};
|
||||
}
|
||||
|
||||
match self
|
||||
.video_library
|
||||
.update_item(video.clone(), index)
|
||||
{
|
||||
Ok(_) => {
|
||||
Ok(()) => {
|
||||
return Action::Task(
|
||||
Task::future(self.db.acquire()).and_then(
|
||||
move |conn| {
|
||||
|
|
@ -230,13 +230,13 @@ impl<'a> Library {
|
|||
if kind != LibraryKind::Presentation {
|
||||
error!("Not editing a presentation item");
|
||||
return Action::None;
|
||||
};
|
||||
}
|
||||
|
||||
match self
|
||||
.presentation_library
|
||||
.update_item(presentation.clone(), index)
|
||||
{
|
||||
Ok(_) => return Action::Task(
|
||||
Ok(()) => return Action::Task(
|
||||
Task::future(self.db.acquire()).and_then(
|
||||
move |conn| {
|
||||
Task::perform(
|
||||
|
|
@ -254,7 +254,7 @@ impl<'a> Library {
|
|||
}
|
||||
Message::PresentationChanged => (),
|
||||
Message::Error(_) => (),
|
||||
};
|
||||
}
|
||||
Action::None
|
||||
}
|
||||
|
||||
|
|
@ -315,7 +315,7 @@ impl<'a> Library {
|
|||
textm!("Presentations").align_y(Vertical::Center),
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
let item_count = model.items.len();
|
||||
row = row.push(horizontal_space());
|
||||
row = row
|
||||
|
|
@ -373,7 +373,7 @@ impl<'a> Library {
|
|||
let service_item = item.to_service_item();
|
||||
let visual_item = self
|
||||
.single_item(index, item, model)
|
||||
.map(|_| Message::None);
|
||||
.map(|()| Message::None);
|
||||
DndSource::<Message, ServiceItem>::new(
|
||||
mouse_area(visual_item)
|
||||
.on_drag(Message::DragItem(service_item.clone()))
|
||||
|
|
@ -418,7 +418,7 @@ impl<'a> Library {
|
|||
)
|
||||
}})
|
||||
.drag_content(move || {
|
||||
service_item.to_owned()
|
||||
service_item.clone()
|
||||
})
|
||||
.into()
|
||||
},
|
||||
|
|
@ -573,14 +573,14 @@ impl<'a> Library {
|
|||
.items
|
||||
.iter()
|
||||
.filter(|song| song.title.to_lowercase().contains(&query))
|
||||
.map(|song| song.to_service_item())
|
||||
.map(super::super::core::content::Content::to_service_item)
|
||||
.collect();
|
||||
let videos: Vec<ServiceItem> = self
|
||||
.video_library
|
||||
.items
|
||||
.iter()
|
||||
.filter(|vid| vid.title.to_lowercase().contains(&query))
|
||||
.map(|vid| vid.to_service_item())
|
||||
.map(super::super::core::content::Content::to_service_item)
|
||||
.collect();
|
||||
let images: Vec<ServiceItem> = self
|
||||
.image_library
|
||||
|
|
@ -589,14 +589,14 @@ impl<'a> Library {
|
|||
.filter(|image| {
|
||||
image.title.to_lowercase().contains(&query)
|
||||
})
|
||||
.map(|image| image.to_service_item())
|
||||
.map(super::super::core::content::Content::to_service_item)
|
||||
.collect();
|
||||
let presentations: Vec<ServiceItem> = self
|
||||
.presentation_library
|
||||
.items
|
||||
.iter()
|
||||
.filter(|pres| pres.title.to_lowercase().contains(&query))
|
||||
.map(|pres| pres.to_service_item())
|
||||
.map(super::super::core::content::Content::to_service_item)
|
||||
.collect();
|
||||
items.extend(videos);
|
||||
items.extend(images);
|
||||
|
|
@ -656,7 +656,7 @@ fn update_in_db(
|
|||
Task::perform(
|
||||
update_song_in_db(song.to_owned(), conn).map(
|
||||
move |r| match r {
|
||||
Ok(_) => {
|
||||
Ok(()) => {
|
||||
warn!(
|
||||
"Should have updated song: {:?}",
|
||||
song_title
|
||||
|
|
@ -667,7 +667,7 @@ fn update_in_db(
|
|||
}
|
||||
},
|
||||
),
|
||||
|_| Message::SongChanged,
|
||||
|()| Message::SongChanged,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ impl Presenter {
|
|||
absolute_slide_index: 0,
|
||||
total_slides,
|
||||
video,
|
||||
audio: items[0].slides[0].audio().clone(),
|
||||
audio: items[0].slides[0].audio(),
|
||||
service: items,
|
||||
video_position: 0.0,
|
||||
hovered_slide: None,
|
||||
|
|
@ -221,8 +221,7 @@ impl Presenter {
|
|||
let offset = AbsoluteOffset {
|
||||
x: {
|
||||
if self.current_slide_index > 2 {
|
||||
self.current_slide_index as f32 * 187.5
|
||||
- 187.5
|
||||
(self.current_slide_index as f32).mul_add(187.5, -187.5)
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
|
|
@ -256,7 +255,7 @@ impl Presenter {
|
|||
?current_audio,
|
||||
"audio needs to change"
|
||||
);
|
||||
self.audio = Some(new_audio.clone());
|
||||
self.audio = Some(new_audio);
|
||||
tasks.push(self.start_audio());
|
||||
}
|
||||
Some(current_audio) => {
|
||||
|
|
@ -271,10 +270,10 @@ impl Presenter {
|
|||
?new_audio,
|
||||
"could not find audio, need to change"
|
||||
);
|
||||
self.audio = Some(new_audio.clone());
|
||||
self.audio = Some(new_audio);
|
||||
tasks.push(self.start_audio());
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
self.audio = None;
|
||||
self.update(Message::EndAudio);
|
||||
|
|
@ -326,7 +325,7 @@ impl Presenter {
|
|||
std::time::Duration::from_secs_f32(position),
|
||||
);
|
||||
match video.seek(position, false) {
|
||||
Ok(_) => debug!(
|
||||
Ok(()) => debug!(
|
||||
"Video position changed: {:?}",
|
||||
position
|
||||
),
|
||||
|
|
@ -355,7 +354,7 @@ impl Presenter {
|
|||
install_ctx
|
||||
.set_desktop_id(&format!("{}.desktop", "org.chriscochrun.lumina"));
|
||||
let install_detail = missing_plugin.installer_detail();
|
||||
println!("installing plugins: {}", install_detail);
|
||||
println!("installing plugins: {install_detail}");
|
||||
let status = gst_pbutils::missing_plugins::install_plugins_sync(
|
||||
&[&install_detail],
|
||||
Some(&install_ctx),
|
||||
|
|
@ -391,7 +390,7 @@ impl Presenter {
|
|||
Message::Error(error) => {
|
||||
error!(error);
|
||||
}
|
||||
};
|
||||
}
|
||||
Action::None
|
||||
}
|
||||
|
||||
|
|
@ -641,7 +640,7 @@ impl Presenter {
|
|||
v.set_looping(
|
||||
self.current_slide.video_loop(),
|
||||
);
|
||||
self.video = Some(v)
|
||||
self.video = Some(v);
|
||||
}
|
||||
Err(e) => {
|
||||
error!(
|
||||
|
|
@ -664,7 +663,7 @@ impl Presenter {
|
|||
let audio = audio.clone();
|
||||
Task::perform(
|
||||
start_audio(Arc::clone(&self.sink.1), audio),
|
||||
|_| Message::None,
|
||||
|()| Message::None,
|
||||
)
|
||||
} else {
|
||||
debug!(?self.audio, "Apparently this doesn't exist");
|
||||
|
|
|
|||
|
|
@ -54,10 +54,10 @@ struct EditorProgram {
|
|||
}
|
||||
|
||||
impl SlideEditor {
|
||||
pub fn view<'a>(
|
||||
&'a self,
|
||||
pub fn view(
|
||||
&self,
|
||||
font: Font,
|
||||
) -> cosmic::Element<'a, SlideWidget> {
|
||||
) -> cosmic::Element<'_, SlideWidget> {
|
||||
container(
|
||||
widget::canvas(&self.program)
|
||||
.height(Length::Fill)
|
||||
|
|
@ -122,10 +122,10 @@ impl<'a> Program<SlideWidget, cosmic::Theme, cosmic::Renderer>
|
|||
match event {
|
||||
canvas::Event::Mouse(event) => match event {
|
||||
cosmic::iced::mouse::Event::CursorEntered => {
|
||||
debug!("cursor entered")
|
||||
debug!("cursor entered");
|
||||
}
|
||||
cosmic::iced::mouse::Event::CursorLeft => {
|
||||
debug!("cursor left")
|
||||
debug!("cursor left");
|
||||
}
|
||||
cosmic::iced::mouse::Event::CursorMoved {
|
||||
position,
|
||||
|
|
@ -140,7 +140,7 @@ impl<'a> Program<SlideWidget, cosmic::Theme, cosmic::Renderer>
|
|||
}
|
||||
cosmic::iced::mouse::Event::ButtonPressed(button) => {
|
||||
// self.mouse_button_pressed = Some(button);
|
||||
debug!(?button, "mouse button pressed")
|
||||
debug!(?button, "mouse button pressed");
|
||||
}
|
||||
cosmic::iced::mouse::Event::ButtonReleased(
|
||||
button,
|
||||
|
|
|
|||
|
|
@ -140,11 +140,11 @@ impl SongEditor {
|
|||
self.song = Some(song.clone());
|
||||
self.title = song.title;
|
||||
if let Some(font) = song.font {
|
||||
self.font = font
|
||||
};
|
||||
self.font = font;
|
||||
}
|
||||
if let Some(font_size) = song.font_size {
|
||||
self.font_size = font_size as usize
|
||||
};
|
||||
self.font_size = font_size as usize;
|
||||
}
|
||||
if let Some(verse_order) = song.verse_order {
|
||||
self.verse_order = verse_order
|
||||
.into_iter()
|
||||
|
|
@ -155,18 +155,18 @@ impl SongEditor {
|
|||
.collect();
|
||||
}
|
||||
if let Some(author) = song.author {
|
||||
self.author = author
|
||||
};
|
||||
self.author = author;
|
||||
}
|
||||
if let Some(audio) = song.audio {
|
||||
self.audio = audio
|
||||
};
|
||||
self.audio = audio;
|
||||
}
|
||||
if let Some(ccli) = song.ccli {
|
||||
self.ccli = ccli
|
||||
};
|
||||
self.ccli = ccli;
|
||||
}
|
||||
if let Some(lyrics) = song.lyrics {
|
||||
self.lyrics =
|
||||
text_editor::Content::with_text(&lyrics)
|
||||
};
|
||||
text_editor::Content::with_text(&lyrics);
|
||||
}
|
||||
self.background_video(&song.background);
|
||||
self.background = song.background;
|
||||
}
|
||||
|
|
@ -212,8 +212,8 @@ impl SongEditor {
|
|||
self.verse_order = verse_order.clone();
|
||||
if let Some(mut song) = self.song.clone() {
|
||||
let verse_order = verse_order
|
||||
.split(" ")
|
||||
.map(|s| s.to_owned())
|
||||
.split(' ')
|
||||
.map(std::borrow::ToOwned::to_owned)
|
||||
.collect();
|
||||
song.verse_order = Some(verse_order);
|
||||
return self.update_song(song);
|
||||
|
|
@ -245,7 +245,7 @@ impl SongEditor {
|
|||
debug!(?path);
|
||||
if let Some(mut song) = self.song.clone() {
|
||||
let background =
|
||||
Background::try_from(path.clone()).ok();
|
||||
Background::try_from(path).ok();
|
||||
self.background_video(&background);
|
||||
song.background = background;
|
||||
return self.update_song(song);
|
||||
|
|
@ -416,7 +416,7 @@ order",
|
|||
.into()
|
||||
}
|
||||
|
||||
pub fn editing(&self) -> bool {
|
||||
pub const fn editing(&self) -> bool {
|
||||
self.editing
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,15 +121,15 @@ impl From<&str> for Font {
|
|||
}
|
||||
|
||||
impl Font {
|
||||
pub fn get_name(&self) -> String {
|
||||
#[must_use] pub fn get_name(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
|
||||
pub fn get_weight(&self) -> Weight {
|
||||
#[must_use] pub const fn get_weight(&self) -> Weight {
|
||||
self.weight
|
||||
}
|
||||
|
||||
pub fn get_style(&self) -> Style {
|
||||
#[must_use] pub const fn get_style(&self) -> Style {
|
||||
self.style
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ impl Font {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn size(mut self, size: u8) -> Self {
|
||||
#[must_use] pub const fn size(mut self, size: u8) -> Self {
|
||||
self.size = size;
|
||||
self
|
||||
}
|
||||
|
|
@ -161,12 +161,12 @@ impl Hash for Color {
|
|||
}
|
||||
|
||||
impl Color {
|
||||
pub fn from_hex_str(color: impl AsRef<str>) -> Color {
|
||||
pub fn from_hex_str(color: impl AsRef<str>) -> Self {
|
||||
match Rgb::from_hex_str(color.as_ref()) {
|
||||
Ok(rgb) => Color(rgb),
|
||||
Ok(rgb) => Self(rgb),
|
||||
Err(e) => {
|
||||
error!("error in making color from hex_str: {:?}", e);
|
||||
Color::default()
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -236,7 +236,7 @@ impl TextSvg {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn alignment(mut self, alignment: TextAlignment) -> Self {
|
||||
pub const fn alignment(mut self, alignment: TextAlignment) -> Self {
|
||||
self.alignment = alignment;
|
||||
self
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ impl TextSvg {
|
|||
shadow.spread,
|
||||
shadow.color)
|
||||
} else {
|
||||
"".into()
|
||||
String::new()
|
||||
};
|
||||
let stroke = if let Some(stroke) = &self.stroke {
|
||||
format!(
|
||||
|
|
@ -263,17 +263,17 @@ impl TextSvg {
|
|||
stroke.color, stroke.size
|
||||
)
|
||||
} else {
|
||||
"".into()
|
||||
String::new()
|
||||
};
|
||||
let size = Size::new(1920.0, 1080.0);
|
||||
let font_size = self.font.size as f32;
|
||||
let font_size = f32::from(self.font.size);
|
||||
let total_lines = self.text.lines().count();
|
||||
let half_lines = (total_lines / 2) as f32;
|
||||
let middle_position = size.height / 2.0;
|
||||
let line_spacing = 10.0;
|
||||
let text_and_line_spacing = font_size + line_spacing;
|
||||
let starting_y_position =
|
||||
middle_position - (half_lines * text_and_line_spacing);
|
||||
half_lines.mul_add(-text_and_line_spacing, middle_position);
|
||||
|
||||
let text_pieces: Vec<String> = self
|
||||
.text
|
||||
|
|
@ -282,8 +282,7 @@ impl TextSvg {
|
|||
.map(|(index, text)| {
|
||||
format!(
|
||||
"<tspan x=\"50%\" y=\"{}\">{}</tspan>",
|
||||
starting_y_position
|
||||
+ (index as f32 * text_and_line_spacing),
|
||||
(index as f32).mul_add(text_and_line_spacing, starting_y_position),
|
||||
text
|
||||
)
|
||||
})
|
||||
|
|
@ -350,7 +349,7 @@ impl TextSvg {
|
|||
self.text
|
||||
.lines()
|
||||
.enumerate()
|
||||
.map(|(i, t)| format!("<tspan x=\"50%\">{}</tspan>", t))
|
||||
.map(|(i, t)| format!("<tspan x=\"50%\">{t}</tspan>"))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
|
@ -391,7 +390,7 @@ pub fn text_svg_generator(
|
|||
.shadow(shadow(2, 2, 5, "#000000"))
|
||||
.stroke(stroke(3, "#000"))
|
||||
.font(
|
||||
Font::from(slide.font().clone())
|
||||
Font::from(slide.font())
|
||||
.size(slide.font_size().try_into().unwrap()),
|
||||
)
|
||||
.fontdb(Arc::clone(&fontdb))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue