cargo clippy fix
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
Chris Cochrun 2025-09-15 11:04:49 -05:00
parent 191dd0255d
commit 2413b96791
9 changed files with 45 additions and 70 deletions

View file

@ -1,13 +1,13 @@
use cosmic::widget::image::Handle; use cosmic::widget::image::Handle;
use crisp::types::{Keyword, Symbol, Value}; use crisp::types::{Keyword, Symbol, Value};
use miette::{IntoDiagnostic, Result}; use miette::{IntoDiagnostic, Result};
use mupdf::{Colorspace, Document, Matrix, Page}; use mupdf::{Colorspace, Document, Matrix};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sqlx::{ use sqlx::{
pool::PoolConnection, prelude::FromRow, query, sqlite::SqliteRow, pool::PoolConnection, prelude::FromRow, query, sqlite::SqliteRow,
Row, Sqlite, SqliteConnection, SqlitePool, Row, Sqlite, SqliteConnection, SqlitePool,
}; };
use std::{path::PathBuf, sync::Arc}; use std::path::PathBuf;
use tracing::{debug, error}; use tracing::{debug, error};
use crate::{Background, Slide, SlideBuilder, TextAlignment}; use crate::{Background, Slide, SlideBuilder, TextAlignment};

View file

@ -1,12 +1,10 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::ops::Deref; use std::ops::Deref;
use std::sync::{Arc, Mutex};
use cosmic::iced::clipboard::mime::{AllowedMimeTypes, AsMimeTypes}; use cosmic::iced::clipboard::mime::{AllowedMimeTypes, AsMimeTypes};
use crisp::types::{Keyword, Symbol, Value}; use crisp::types::{Keyword, Symbol, Value};
use miette::{IntoDiagnostic, Result}; use miette::{IntoDiagnostic, Result};
use resvg::usvg::fontdb;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracing::{debug, error}; use tracing::{debug, error};
@ -260,7 +258,7 @@ impl From<&Song> for ServiceItem {
kind: ServiceItemKind::Song(song.clone()), kind: ServiceItemKind::Song(song.clone()),
database_id: song.id, database_id: song.id,
title: song.title.clone(), title: song.title.clone(),
slides: slides.into(), slides: slides,
..Default::default() ..Default::default()
} }
} else { } else {
@ -281,7 +279,7 @@ impl From<&Video> for ServiceItem {
kind: ServiceItemKind::Video(video.clone()), kind: ServiceItemKind::Video(video.clone()),
database_id: video.id, database_id: video.id,
title: video.title.clone(), title: video.title.clone(),
slides: slides.into(), slides: slides,
..Default::default() ..Default::default()
} }
} else { } else {
@ -302,7 +300,7 @@ impl From<&Image> for ServiceItem {
kind: ServiceItemKind::Image(image.clone()), kind: ServiceItemKind::Image(image.clone()),
database_id: image.id, database_id: image.id,
title: image.title.clone(), title: image.title.clone(),
slides: slides.into(), slides: slides,
..Default::default() ..Default::default()
} }
} else { } else {
@ -325,7 +323,7 @@ impl From<&Presentation> for ServiceItem {
), ),
database_id: presentation.id, database_id: presentation.id,
title: presentation.title.clone(), title: presentation.title.clone(),
slides: slides.into(), slides: slides,
..Default::default() ..Default::default()
}, },
Err(e) => { Err(e) => {

View file

@ -3,19 +3,14 @@ use cosmic::widget::image::Handle;
use crisp::types::{Keyword, Symbol, Value}; use crisp::types::{Keyword, Symbol, Value};
use iced_video_player::Video; use iced_video_player::Video;
use miette::{miette, Result}; use miette::{miette, Result};
use resvg::usvg::fontdb;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{ use std::{
fmt::Display, fmt::Display,
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::Arc,
}; };
use tracing::error; use tracing::error;
use crate::ui::{ use crate::ui::text_svg::TextSvg;
pdf::PdfViewer,
text_svg::{self, TextSvg},
};
use super::songs::Song; use super::songs::Song;
@ -310,7 +305,7 @@ impl Slide {
} }
pub fn text_alignment(&self) -> TextAlignment { pub fn text_alignment(&self) -> TextAlignment {
self.text_alignment.clone() self.text_alignment
} }
pub fn font_size(&self) -> i32 { pub fn font_size(&self) -> i32 {

View file

@ -7,7 +7,7 @@ use cosmic::app::{Core, Settings, Task};
use cosmic::iced::alignment::Vertical; use cosmic::iced::alignment::Vertical;
use cosmic::iced::keyboard::{Key, Modifiers}; use cosmic::iced::keyboard::{Key, Modifiers};
use cosmic::iced::window::{Mode, Position}; use cosmic::iced::window::{Mode, Position};
use cosmic::iced::{self, event, window, Color, Length, Point}; use cosmic::iced::{self, event, window, Length, Point};
use cosmic::iced_futures::Subscription; use cosmic::iced_futures::Subscription;
use cosmic::iced_widget::{column, row, stack}; use cosmic::iced_widget::{column, row, stack};
use cosmic::theme; use cosmic::theme;
@ -40,7 +40,7 @@ use ui::song_editor::{self, SongEditor};
use ui::EditorMode; use ui::EditorMode;
use crate::core::kinds::ServiceItemKind; use crate::core::kinds::ServiceItemKind;
use crate::ui::text_svg::{self, shadow, stroke, TextSvg}; use crate::ui::text_svg::{self};
pub mod core; pub mod core;
pub mod lisp; pub mod lisp;
@ -985,7 +985,7 @@ impl cosmic::Application for App {
} }
Message::Search(query) => { Message::Search(query) => {
self.search_query = query.clone(); self.search_query = query.clone();
return self.search(query); self.search(query)
} }
Message::UpdateSearchResults(items) => { Message::UpdateSearchResults(items) => {
self.search_results = items; self.search_results = items;
@ -1206,14 +1206,14 @@ where
fn search(&self, query: String) -> Task<Message> { fn search(&self, query: String) -> Task<Message> {
if let Some(library) = self.library.clone() { if let Some(library) = self.library.clone() {
return Task::perform( Task::perform(
async move { library.search_items(query).await }, async move { library.search_items(query).await },
|items| { |items| {
cosmic::Action::App(Message::UpdateSearchResults( cosmic::Action::App(Message::UpdateSearchResults(
items, items,
)) ))
}, },
); )
} else { } else {
Task::none() Task::none()
} }
@ -1378,7 +1378,7 @@ where
.data_received_for::<ServiceItem>(|item| { .data_received_for::<ServiceItem>(|item| {
item.map_or_else( item.map_or_else(
|| Message::None, || Message::None,
|item| Message::AppendServiceItem(item), Message::AppendServiceItem,
) )
}) })
.on_finish( .on_finish(
@ -1396,7 +1396,7 @@ where
] ]
.padding(10) .padding(10)
.spacing(10); .spacing(10);
let mut container = Container::new(column) let container = Container::new(column)
// .height(Length::Fill) // .height(Length::Fill)
.style(nav_bar_style); .style(nav_bar_style);

View file

@ -264,7 +264,8 @@ impl<'a> Library {
let video_library = self.library_item(&self.video_library); let video_library = self.library_item(&self.video_library);
let presentation_library = let presentation_library =
self.library_item(&self.presentation_library); self.library_item(&self.presentation_library);
let column = column![
column![
text::heading("Library").center().width(Length::Fill), text::heading("Library").center().width(Length::Fill),
cosmic::iced::widget::horizontal_rule(1), cosmic::iced::widget::horizontal_rule(1),
song_library, song_library,
@ -275,8 +276,7 @@ impl<'a> Library {
.height(Length::Fill) .height(Length::Fill)
.padding(10) .padding(10)
.spacing(10) .spacing(10)
.into(); .into()
column
} }
pub fn library_item<T>( pub fn library_item<T>(
@ -481,8 +481,7 @@ impl<'a> Library {
.accent_text_color() .accent_text_color()
.into() .into()
} }
} else { } else if let Some((library, selected)) = self.selected_item
if let Some((library, selected)) = self.selected_item
{ {
if model.kind == library if model.kind == library
&& selected == index as i32 && selected == index as i32
@ -499,7 +498,6 @@ impl<'a> Library {
.cosmic() .cosmic()
.destructive_text_color() .destructive_text_color()
.into() .into()
}
}; };
text::body(elide_text(item.subtext(), size.width)) text::body(elide_text(item.subtext(), size.width))
.center() .center()
@ -529,8 +527,7 @@ impl<'a> Library {
&& selected == index as i32 && selected == index as i32
{ {
t.cosmic().accent.selected.into() t.cosmic().accent.selected.into()
} else { } else if let Some((library, hovered)) =
if let Some((library, hovered)) =
self.hovered_item self.hovered_item
{ {
if model.kind == library if model.kind == library
@ -543,7 +540,6 @@ impl<'a> Library {
} else { } else {
t.cosmic().button.base.into() t.cosmic().button.base.into()
} }
}
} else if let Some((library, hovered)) = } else if let Some((library, hovered)) =
self.hovered_item self.hovered_item
{ {

View file

@ -3,23 +3,18 @@ use std::{fs::File, io::BufReader, path::PathBuf, sync::Arc};
use cosmic::{ use cosmic::{
iced::{ iced::{
alignment::Horizontal,
border,
font::{Family, Stretch, Style, Weight}, font::{Family, Stretch, Style, Weight},
Background, Border, Color, ContentFit, Font, Length, Shadow, Background, Border, Color, ContentFit, Font, Length, Shadow,
Vector, Vector,
}, },
iced_widget::{ iced_widget::{
rich_text,
scrollable::{ scrollable::{
scroll_to, AbsoluteOffset, Direction, Scrollbar, scroll_to, AbsoluteOffset, Direction, Scrollbar,
}, }, stack, vertical_rule,
span, stack, vertical_rule,
}, },
prelude::*, prelude::*,
widget::{ widget::{
container, image, mouse_area, responsive, scrollable, text, container, image, mouse_area, responsive, scrollable, text, Container, Id, Row, Space,
Column, Container, Id, Image, Row, Space,
}, },
Task, Task,
}; };
@ -33,8 +28,6 @@ use crate::{
BackgroundKind, BackgroundKind,
}; };
use crate::ui::pdf::PdfViewer;
const REFERENCE_WIDTH: f32 = 1920.0; const REFERENCE_WIDTH: f32 = 1920.0;
const REFERENCE_HEIGHT: f32 = 1080.0; const REFERENCE_HEIGHT: f32 = 1080.0;
@ -448,7 +441,7 @@ impl Presenter {
); );
let container = slide_view( let container = slide_view(
&slide, slide,
&self.video, &self.video,
font, font,
true, true,
@ -799,13 +792,11 @@ pub(crate) fn slide_view<'a>(
.center_x(width) .center_x(width)
.center_y(size.height) .center_y(size.height)
.clip(true) .clip(true)
.into()
} else { } else {
Container::new(Space::new(0.0, 0.0)) Container::new(Space::new(0.0, 0.0))
.center_x(width) .center_x(width)
.center_y(size.height) .center_y(size.height)
.clip(true) .clip(true)
.into()
} }
} }
BackgroundKind::Html => todo!(), BackgroundKind::Html => todo!(),

View file

@ -2,11 +2,10 @@ use std::{io, path::PathBuf};
use cosmic::{ use cosmic::{
iced::{Color, Font, Length, Size}, iced::{Color, Font, Length, Size},
prelude::*,
widget::{ widget::{
self, self,
canvas::{self, Program, Stroke}, canvas::{self, Program, Stroke},
container, Canvas, container,
}, },
Renderer, Renderer,
}; };

View file

@ -10,8 +10,7 @@ use cosmic::{
iced_widget::row, iced_widget::row,
theme, theme,
widget::{ widget::{
button, column, combo_box, container, horizontal_space, icon, button, column, combo_box, container, horizontal_space, icon, text, text_editor, text_input,
scrollable, text, text_editor, text_input,
}, },
Element, Task, Element, Task,
}; };
@ -21,11 +20,10 @@ use tracing::{debug, error};
use crate::{ use crate::{
core::{service_items::ServiceTrait, songs::Song}, core::{service_items::ServiceTrait, songs::Song},
ui::slide_editor::{self, SlideEditor}, ui::slide_editor::SlideEditor,
Background, BackgroundKind, Background, BackgroundKind,
}; };
use super::presenter::slide_view;
#[derive(Debug)] #[derive(Debug)]
pub struct SongEditor { pub struct SongEditor {
@ -329,7 +327,6 @@ impl SongEditor {
self.slide_state self.slide_state
.view(Font::with_name("Quicksand Bold")) .view(Font::with_name("Quicksand Bold"))
.map(|_s| Message::None) .map(|_s| Message::None)
.into()
} }
fn left_column(&self) -> Element<Message> { fn left_column(&self) -> Element<Message> {

View file

@ -1,7 +1,6 @@
use std::{ use std::{
fmt::Display, fmt::Display,
hash::{Hash, Hasher}, hash::{Hash, Hasher},
io::Read,
path::PathBuf, path::PathBuf,
sync::Arc, sync::Arc,
}; };
@ -13,7 +12,7 @@ use cosmic::{
ContentFit, Length, Size, ContentFit, Length, Size,
}, },
prelude::*, prelude::*,
widget::{container, image::Handle, Image}, widget::{image::Handle, Image},
}; };
use rapidhash::v3::rapidhash_v3; use rapidhash::v3::rapidhash_v3;
use resvg::{ use resvg::{
@ -312,7 +311,7 @@ impl TextSvg {
debug!("text string built..."); debug!("text string built...");
let resvg_tree = Tree::from_data( let resvg_tree = Tree::from_data(
&final_svg.as_bytes(), final_svg.as_bytes(),
&resvg::usvg::Options { &resvg::usvg::Options {
fontdb: Arc::clone(&self.fontdb), fontdb: Arc::clone(&self.fontdb),
..Default::default() ..Default::default()
@ -385,7 +384,7 @@ pub fn text_svg_generator(
slide: &mut crate::core::slide::Slide, slide: &mut crate::core::slide::Slide,
fontdb: Arc<fontdb::Database>, fontdb: Arc<fontdb::Database>,
) { ) {
if slide.text().len() > 0 { if !slide.text().is_empty() {
let text_svg = TextSvg::new(slide.text()) let text_svg = TextSvg::new(slide.text())
.alignment(slide.text_alignment()) .alignment(slide.text_alignment())
.fill("#fff") .fill("#fff")