diff --git a/src/core/mod.rs b/src/core/mod.rs index 3717028..4c6c1dc 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -1,4 +1,3 @@ -pub mod song_search; pub mod content; pub mod file; pub mod images; @@ -9,6 +8,7 @@ pub mod service_items; pub mod settings; pub mod slide; pub mod slide_actions; +pub mod song_search; pub mod songs; pub mod thumbnail; pub mod videos; diff --git a/src/core/presentations.rs b/src/core/presentations.rs index 303c39e..0303f84 100644 --- a/src/core/presentations.rs +++ b/src/core/presentations.rs @@ -334,8 +334,7 @@ impl Model { presentation.ending_index, ) { PresKind::Pdf { - starting_index: starting_index - as i32, + starting_index: starting_index as i32, ending_index: ending_index as i32, } } else { diff --git a/src/core/settings.rs b/src/core/settings.rs index b7be951..9b64ea1 100644 --- a/src/core/settings.rs +++ b/src/core/settings.rs @@ -63,9 +63,8 @@ impl Default for Settings { Eq, PartialEq, Serialize, + Default, )] -#[derive(Default)] pub struct PersistentState { pub recent_files: VecDeque, } - diff --git a/src/core/songs.rs b/src/core/songs.rs index 2842c53..8d6ada1 100644 --- a/src/core/songs.rs +++ b/src/core/songs.rs @@ -7,7 +7,7 @@ use crisp::types::{Keyword, Symbol, Value}; use miette::{IntoDiagnostic, Result, miette}; use serde::{Deserialize, Serialize}; use sqlx::{ - Acquire, FromRow, Row, Sqlite, SqliteConnection, SqlitePool, + FromRow, Row, Sqlite, SqliteConnection, SqlitePool, pool::PoolConnection, query, sqlite::SqliteRow, }; use tracing::{debug, error}; @@ -58,7 +58,7 @@ pub enum VerseName { } impl VerseName { - #[must_use] + #[must_use] pub fn get_name(&self) -> String { match self { Self::Verse { number, .. } => { @@ -129,7 +129,7 @@ impl AsMimeTypes for VerseName { fn as_bytes( &self, - mime_type: &str, + _mime_type: &str, ) -> Option> { let ron = ron::ser::to_string(self).ok()?; Some(Cow::from(ron.into_bytes())) @@ -143,7 +143,7 @@ impl Default for VerseName { } impl From<&Song> for Value { - fn from(value: &Song) -> Self { + fn from(_value: &Song) -> Self { Self::List(vec![Self::Symbol(Symbol("song".into()))]) } } @@ -373,7 +373,7 @@ fn lyrics_to_verse( pub fn lisp_to_song(list: Vec) -> Song { const DEFAULT_SONG_ID: i32 = 0; - const DEFAULT_SONG_LOCATION: usize = 0; + // const DEFAULT_SONG_LOCATION: usize = 0; let id = if let Some(key_pos) = list .iter() @@ -717,16 +717,14 @@ pub async fn update_song_in_db( } impl Song { - #[must_use] + #[must_use] pub fn get_lyric(&self, verse: &VerseName) -> Option { - self.verse_map - .as_ref() - .and_then(|verse_map| { - verse_map - .get(verse) - .cloned() - .map(|lyric| lyric.trim_end().to_string()) - }) + self.verse_map.as_ref().and_then(|verse_map| { + verse_map + .get(verse) + .cloned() + .map(|lyric| lyric.trim_end().to_string()) + }) } pub fn set_lyrics>( @@ -815,9 +813,10 @@ impl Song { ) { self.set_lyrics(&verse, lyric); if let Some(verses) = self.verses.as_mut() - && let Some(old_verse) = verses.get_mut(index) { - *old_verse = verse; - } + && let Some(old_verse) = verses.get_mut(index) + { + *old_verse = verse; + } if let Some(verses) = &self.verses { let mut new_lyrics = String::new(); diff --git a/src/main.rs b/src/main.rs index 64b799e..1065e06 100644 --- a/src/main.rs +++ b/src/main.rs @@ -707,16 +707,13 @@ impl cosmic::Application for App { fn dialog(&self) -> Option> { let cosmic::cosmic_theme::Spacing { - space_none, - space_xxxs, space_xxs, - space_xs, space_s, - space_m, space_l, space_xl, space_xxl, space_xxxl, + .. } = cosmic::theme::spacing(); if self.searching { let items: Vec> = self @@ -1052,7 +1049,7 @@ impl cosmic::Application for App { let slide_index = self.current_item.1; let item_index = self.current_item.0; let mut tasks = vec![]; - if let Some(item) = + if let Some(_item) = self.service.get(item_index) { if slide_index != 0 { diff --git a/src/ui/image_editor.rs b/src/ui/image_editor.rs index cde78df..785f73a 100644 --- a/src/ui/image_editor.rs +++ b/src/ui/image_editor.rs @@ -38,7 +38,7 @@ pub enum Message { } impl ImageEditor { - #[must_use] + #[must_use] pub fn new() -> Self { Self { image: None, @@ -93,7 +93,7 @@ impl ImageEditor { Action::None } - #[must_use] + #[must_use] pub fn view(&self) -> Element { let container = if let Some(pic) = &self.image { let image = widget::image(pic.path.clone()); @@ -132,7 +132,7 @@ impl ImageEditor { .into() } - #[must_use] + #[must_use] pub const fn editing(&self) -> bool { self.editing } diff --git a/src/ui/library.rs b/src/ui/library.rs index 3ec4a85..5eb126d 100644 --- a/src/ui/library.rs +++ b/src/ui/library.rs @@ -132,7 +132,7 @@ impl<'a> Library { } } - #[must_use] + #[must_use] pub fn get_song(&self, index: i32) -> Option<&Song> { self.song_library.get_item(index) } @@ -813,7 +813,7 @@ impl<'a> Library { Action::None } - #[must_use] + #[must_use] pub fn view(&self) -> Element { let cosmic::cosmic_theme::Spacing { space_s, .. } = cosmic::theme::spacing(); @@ -1263,17 +1263,17 @@ impl<'a> Library { items.into_iter().map(|item| item.1).collect() } - #[must_use] + #[must_use] pub fn get_video(&self, index: i32) -> Option<&Video> { self.video_library.get_item(index) } - #[must_use] + #[must_use] pub fn get_image(&self, index: i32) -> Option<&Image> { self.image_library.get_item(index) } - #[must_use] + #[must_use] pub fn get_presentation( &self, index: i32, @@ -1281,7 +1281,10 @@ impl<'a> Library { self.presentation_library.get_item(index) } - pub const fn set_modifiers(&mut self, modifiers: Option) { + pub const fn set_modifiers( + &mut self, + modifiers: Option, + ) { self.modifiers_pressed = modifiers; } diff --git a/src/ui/presentation_editor.rs b/src/ui/presentation_editor.rs index 7dac4a1..e19b337 100644 --- a/src/ui/presentation_editor.rs +++ b/src/ui/presentation_editor.rs @@ -80,7 +80,7 @@ impl menu::Action for MenuAction { } impl PresentationEditor { - #[must_use] + #[must_use] pub const fn new() -> Self { Self { presentation: None, @@ -205,9 +205,9 @@ impl PresentationEditor { if let Some(presentation) = self.presentation.as_ref() && let PresKind::Pdf { ending_index, .. } = presentation.kind - { - last_index = ending_index; - } + { + last_index = ending_index; + } if next_index > last_index { return Action::None; @@ -248,9 +248,9 @@ impl PresentationEditor { if let Some(presentation) = self.presentation.as_ref() && let PresKind::Pdf { starting_index, .. } = presentation.kind - { - first_index = starting_index; - } + { + first_index = starting_index; + } if previous_index < first_index { return Action::None; diff --git a/src/ui/presenter.rs b/src/ui/presenter.rs index 1aad467..03c2385 100644 --- a/src/ui/presenter.rs +++ b/src/ui/presenter.rs @@ -271,7 +271,9 @@ impl Presenter { let audio = items .first() .and_then(|item| { - item.slides.first().map(super::super::core::slide::Slide::audio) + item.slides + .first() + .map(super::super::core::slide::Slide::audio) }) .flatten(); @@ -984,28 +986,28 @@ impl Presenter { if let Some(map) = &self.slide_action_map && let Some(actions) = map.get(&(item_index, slide_index)) - { - for action in actions { - match action { - slide_actions::Action::Obs { action } => { - debug!("found obs slide actions"); - if let Some(obs) = &self.obs_client { - let obs = Arc::clone(obs); - let action = action.to_owned(); - let task = Task::perform( - async move { action.run(obs).await }, - |res| { - debug!(?res); - Message::None - }, - ); - tasks.push(task); - } + { + for action in actions { + match action { + slide_actions::Action::Obs { action } => { + debug!("found obs slide actions"); + if let Some(obs) = &self.obs_client { + let obs = Arc::clone(obs); + let action = action.to_owned(); + let task = Task::perform( + async move { action.run(obs).await }, + |res| { + debug!(?res); + Message::None + }, + ); + tasks.push(task); } - slide_actions::Action::Other => todo!(), } + slide_actions::Action::Other => todo!(), } } + } Task::batch(tasks) } } diff --git a/src/ui/service.rs b/src/ui/service.rs index d196a89..b18de54 100644 --- a/src/ui/service.rs +++ b/src/ui/service.rs @@ -17,7 +17,7 @@ use tracing::debug; use crate::core::service_items::ServiceItem; -#[must_use] +#[must_use] pub const fn service( service: &Vec, ) -> Service<'_, Message> { @@ -35,7 +35,7 @@ pub struct Service<'a, Message> { } impl<'a, Message: Clone + 'static> Service<'a, Message> { - #[must_use] + #[must_use] pub const fn new(service: &'a Vec) -> Self { Self { service, diff --git a/src/ui/video_editor.rs b/src/ui/video_editor.rs index 2bc5d13..c1941bf 100644 --- a/src/ui/video_editor.rs +++ b/src/ui/video_editor.rs @@ -44,7 +44,7 @@ pub enum Message { } impl VideoEditor { - #[must_use] + #[must_use] pub fn new() -> Self { Self { video: None, diff --git a/src/ui/widgets/draggable/column.rs b/src/ui/widgets/draggable/column.rs index 367c165..c7b9695 100644 --- a/src/ui/widgets/draggable/column.rs +++ b/src/ui/widgets/draggable/column.rs @@ -101,13 +101,13 @@ where Theme: Catalog, { /// Creates an empty [`Column`]. - #[must_use] + #[must_use] pub fn new() -> Self { Self::from_vec(Vec::new()) } /// Creates a [`Column`] with the given capacity. - #[must_use] + #[must_use] pub fn with_capacity(capacity: usize) -> Self { Self::from_vec(Vec::with_capacity(capacity)) } @@ -130,7 +130,7 @@ where /// /// If any of the children have a [`Length::Fill`] strategy, you will need to /// call [`Column::width`] or [`Column::height`] accordingly. - #[must_use] + #[must_use] pub fn from_vec( children: Vec>, ) -> Self { @@ -896,7 +896,7 @@ impl Catalog for cosmic::Theme { } } -#[must_use] +#[must_use] pub fn default(theme: &Theme) -> Style { Style { scale: 1.05, diff --git a/src/ui/widgets/draggable/row.rs b/src/ui/widgets/draggable/row.rs index b614cfc..597def2 100644 --- a/src/ui/widgets/draggable/row.rs +++ b/src/ui/widgets/draggable/row.rs @@ -95,13 +95,13 @@ where Theme: Catalog, { /// Creates an empty [`Row`]. - #[must_use] + #[must_use] pub fn new() -> Self { Self::from_vec(Vec::new()) } /// Creates a [`Row`] with the given capacity. - #[must_use] + #[must_use] pub fn with_capacity(capacity: usize) -> Self { Self::from_vec(Vec::with_capacity(capacity)) } @@ -124,7 +124,7 @@ where /// /// If any of the children have a [`Length::Fill`] strategy, you will need to /// call [`Row::width`] or [`Row::height`] accordingly. - #[must_use] + #[must_use] pub fn from_vec( children: Vec>, ) -> Self { @@ -257,7 +257,9 @@ where /// Turns the [`Row`] into a [`Wrapping`] row. /// /// The original alignment of the [`Row`] is preserved per row wrapped. - pub const fn wrap(self) -> Wrapping<'a, Message, Theme, Renderer> { + pub const fn wrap( + self, + ) -> Wrapping<'a, Message, Theme, Renderer> { Wrapping { row: self } } @@ -314,8 +316,7 @@ where } } -impl Default - for Row<'_, Message, Theme, Renderer> +impl Default for Row<'_, Message, Theme, Renderer> where Renderer: renderer::Renderer, Theme: Catalog, @@ -1044,7 +1045,7 @@ impl Catalog for cosmic::Theme { } } -#[must_use] +#[must_use] pub fn default(theme: &cosmic::Theme) -> Style { Style { scale: 1.05, diff --git a/src/ui/widgets/verse_editor.rs b/src/ui/widgets/verse_editor.rs index 82f24a8..c40308d 100644 --- a/src/ui/widgets/verse_editor.rs +++ b/src/ui/widgets/verse_editor.rs @@ -27,7 +27,7 @@ pub enum Action { } impl VerseEditor { - #[must_use] + #[must_use] pub fn new(verse: VerseName, lyric: String) -> Self { Self { verse_name: verse, @@ -50,16 +50,7 @@ impl VerseEditor { pub fn view(&self) -> Element { let cosmic::cosmic_theme::Spacing { - space_none, - space_xxxs, - space_xxs, - space_xs, - space_s, - space_m, - space_l, - space_xl, - space_xxl, - space_xxxl, + space_s, space_m, .. } = theme::spacing(); let verse_title =