diff --git a/src/core/videos.rs b/src/core/videos.rs index 528088d..3215cd4 100644 --- a/src/core/videos.rs +++ b/src/core/videos.rs @@ -37,9 +37,10 @@ impl From<&Video> for Value { impl From for Video { fn from(value: PathBuf) -> Self { - let title: String = value.file_name().map_or_else(|| "Video".into(), |filename| { - filename.to_str().unwrap_or("Video").into() - }); + let title: String = value.file_name().map_or_else( + || "Video".into(), + |filename| filename.to_str().unwrap_or("Video").into(), + ); Self { title, path: value, diff --git a/src/main.rs b/src/main.rs index 1799207..2191949 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1340,7 +1340,11 @@ impl cosmic::Application for App { let column = column![ row![ - library.width(Length::FillPortion(1)), + if self.library_open { + library.width(Length::FillPortion(1)) + } else { + container(Space::new(0, 0)) + }, main_area.width(Length::FillPortion(4)) ], preview_bar diff --git a/src/ui/library.rs b/src/ui/library.rs index ff5d64f..2137e26 100644 --- a/src/ui/library.rs +++ b/src/ui/library.rs @@ -76,7 +76,7 @@ pub enum Action { #[derive(Clone, Debug)] pub(crate) enum Message { - AddItem(LibraryKind), + AddItem, DeleteItem((LibraryKind, i32)), OpenItem(Option<(LibraryKind, i32)>), HoverLibrary(Option), @@ -128,24 +128,6 @@ impl<'a> Library { pub fn update(&'a mut self, message: Message) -> Action { match message { - Message::AddItem(kind) => match kind { - LibraryKind::Song => todo!(), - LibraryKind::Video => { - let future = cosmic::dialog::file_chooser::open::Dialog::new().filter(cosmic::dialog::file_chooser::FileFilter::new("videos").extension("mp4").extension("mkv").extension("webm").extension(".mpeg")).open_file(); - let task = Task::future(future).and_then(|r| { - if let Ok(video) = r - .url() - .to_file_path() - .and_then(|path| Ok(Video::from(path))) - { - self.video_library.add_item(video); - }; - Task::none() - }); - } - LibraryKind::Image => todo!(), - LibraryKind::Presentation => todo!(), - }, Message::None => (), Message::DeleteItem((kind, index)) => { match kind { @@ -708,7 +690,7 @@ impl<'a> Library { let library_toolbar = rowm!( text_input("Search...", ""), button::icon(icon::from_name("add")) - .on_press(Message::AddItem(model.kind)) + .on_press(Message::AddItem) ); let library_column = column![library_toolbar, items].spacing(3); diff --git a/src/ui/song_editor.rs b/src/ui/song_editor.rs index 05ad850..e388adc 100644 --- a/src/ui/song_editor.rs +++ b/src/ui/song_editor.rs @@ -286,7 +286,7 @@ impl SongEditor { .padding(cosmic::theme::spacing().space_s) .center_x(Length::FillPortion(2)) } else { - container(vertical_space()) + container(horizontal_space()) }; let slide_preview = container(self.slide_preview()) .width(Length::FillPortion(2)); @@ -455,8 +455,10 @@ order", v.set_looping(true); v }); - debug!(?video); + // debug!(?video); self.video = video; + } else { + self.video = None; } } }