diff --git a/src/main.rs b/src/main.rs index 9e2a6ce..d84c7d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -157,7 +157,7 @@ impl cosmic::Application for App { input: Self::Flags, ) -> (Self, Task) { debug!("init"); - let mut nav_model = nav_bar::Model::default(); + let nav_model = nav_bar::Model::default(); let mut windows = vec![]; @@ -308,7 +308,6 @@ impl cosmic::Application for App { let tooltip = tooltip(button, text::body(item.kind.to_string()), TPosition::Right); - let dragged_item = &self.library_dragged_item; dnd_destination(tooltip, vec!["application/service-item".into()]) .data_received_for::( move |item| { if let Some(item) = item { @@ -600,10 +599,10 @@ impl cosmic::Application for App { } Message::Present(message) => { // debug!(?message); - if self.presentation_open { - if let Some(video) = &mut self.presenter.video { - video.set_muted(false); - } + if self.presentation_open + && let Some(video) = &mut self.presenter.video + { + video.set_muted(false); } match self.presenter.update(message) { presenter::Action::Task(task) => task.map(|m| { @@ -888,21 +887,21 @@ impl cosmic::Application for App { // debug!(?action); // debug!(?service_item); - if let Some(library) = &self.library { - if let Some((lib, item)) = library.dragged_item { - // match lib { - // core::model::LibraryKind::Song => , - // core::model::LibraryKind::Video => todo!(), - // core::model::LibraryKind::Image => todo!(), - // core::model::LibraryKind::Presentation => todo!(), - // } - let item = library.get_song(item).unwrap(); - let item = ServiceItem::from(item); - self.nav_model - .insert() - .text(item.title.clone()) - .data(item); - } + if let Some(library) = &self.library + && let Some((lib, item)) = library.dragged_item + { + // match lib { + // core::model::LibraryKind::Song => , + // core::model::LibraryKind::Video => todo!(), + // core::model::LibraryKind::Image => todo!(), + // core::model::LibraryKind::Presentation => todo!(), + // } + let item = library.get_song(item).unwrap(); + let item = ServiceItem::from(item); + self.nav_model + .insert() + .text(item.title.clone()) + .data(item); } Task::none() } @@ -933,15 +932,14 @@ impl cosmic::Application for App { .iter() .enumerate() .find(|(id, _)| index == *id) + && let Some(slide) = item.slides.first() { - if let Some(slide) = item.slides.first() { - self.current_item = (index, 0); - self.presenter.update( - presenter::Message::SlideChange( - slide.clone(), - ), - ); - } + self.current_item = (index, 0); + self.presenter.update( + presenter::Message::SlideChange( + slide.clone(), + ), + ); } Task::none() } diff --git a/src/ui/library.rs b/src/ui/library.rs index ed81f04..56b47f6 100644 --- a/src/ui/library.rs +++ b/src/ui/library.rs @@ -1,5 +1,3 @@ -use std::rc::Rc; - use cosmic::{ iced::{ alignment::Vertical, clipboard::dnd::DndAction, @@ -394,7 +392,7 @@ impl<'a> Library { ) .action(DndAction::Copy) .drag_icon({ - let model = model.kind.clone(); + let model = model.kind; move |i| { let state = State::None; let icon = match model { diff --git a/src/ui/presenter.rs b/src/ui/presenter.rs index ad82797..779e964 100644 --- a/src/ui/presenter.rs +++ b/src/ui/presenter.rs @@ -9,20 +9,17 @@ use cosmic::{ Background, Border, Color, ContentFit, Font, Length, Shadow, Vector, }, - iced_core::text::Span, iced_widget::{ rich_text, scrollable::{ scroll_to, AbsoluteOffset, Direction, Scrollbar, }, - span, stack, - text::Rich, - vertical_rule, + span, stack, vertical_rule, }, prelude::*, widget::{ - container, horizontal_space, image, mouse_area, responsive, - scrollable, text, Column, Container, Id, Row, Space, + container, image, mouse_area, responsive, scrollable, text, + Column, Container, Id, Row, Space, }, Task, }; @@ -32,11 +29,7 @@ use tracing::{debug, error, info, warn}; use url::Url; use crate::{ - core::{ - service_items::{Service, ServiceItem}, - slide::Slide, - }, - ui::text_svg::{self, Font as SvgFont}, + core::{service_items::ServiceItem, slide::Slide}, // ui::widgets::slide_text, BackgroundKind, }; diff --git a/src/ui/song_editor.rs b/src/ui/song_editor.rs index c2932db..b175e3d 100644 --- a/src/ui/song_editor.rs +++ b/src/ui/song_editor.rs @@ -7,12 +7,11 @@ use cosmic::{ Font, Length, }, iced_wgpu::graphics::text::cosmic_text::fontdb, - iced_widget::{row, stack}, + iced_widget::row, theme, widget::{ - button, column, combo_box, container, dropdown, - horizontal_space, icon, scrollable, svg::Handle, text, - text_editor, text_input, Svg, + button, column, combo_box, container, horizontal_space, icon, + scrollable, text, text_editor, text_input, }, Element, Task, }; @@ -179,11 +178,11 @@ impl SongEditor { .filter(|f| f.1 == font) .map(|f| f.0) .next(); - if let Some(id) = font_id { - if let Some(face) = self.font_db.face(id) { - self.font = face.post_script_name.clone(); - // self.current_font = Font::from(face); - } + if let Some(id) = font_id + && let Some(face) = self.font_db.face(id) + { + self.font = face.post_script_name.clone(); + // self.current_font = Font::from(face); } self.font = font.clone(); @@ -425,16 +424,16 @@ order", } fn background_video(&mut self, background: &Option) { - if let Some(background) = background { - if background.kind == BackgroundKind::Video { - let video = - Video::try_from(background).ok().map(|mut v| { - v.set_looping(true); - v - }); - debug!(?video); - self.video = video; - } + if let Some(background) = background + && background.kind == BackgroundKind::Video + { + let video = + Video::try_from(background).ok().map(|mut v| { + v.set_looping(true); + v + }); + debug!(?video); + self.video = video; } } } diff --git a/src/ui/text_svg.rs b/src/ui/text_svg.rs index d690198..cbfd280 100644 --- a/src/ui/text_svg.rs +++ b/src/ui/text_svg.rs @@ -10,7 +10,7 @@ use cosmic::{ Length, Size, }, prelude::*, - widget::{container, lazy, responsive, svg::Handle, Svg}, + widget::{container, svg::Handle, Svg}, }; use tracing::error; @@ -330,7 +330,7 @@ mod test { #[test] fn test_text_spans() { - let mut text = TextSvg::new(); + let mut text = TextSvg::new("yes"); text.text = "This is multiline text."