fixing some things....
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
Chris Cochrun 2025-09-24 10:39:28 -05:00
parent 77daa03db6
commit a56ff6a022
4 changed files with 15 additions and 26 deletions

View file

@ -37,9 +37,10 @@ impl From<&Video> for Value {
impl From<PathBuf> for Video { impl From<PathBuf> for Video {
fn from(value: PathBuf) -> Self { fn from(value: PathBuf) -> Self {
let title: String = value.file_name().map_or_else(|| "Video".into(), |filename| { let title: String = value.file_name().map_or_else(
filename.to_str().unwrap_or("Video").into() || "Video".into(),
}); |filename| filename.to_str().unwrap_or("Video").into(),
);
Self { Self {
title, title,
path: value, path: value,

View file

@ -1340,7 +1340,11 @@ impl cosmic::Application for App {
let column = column![ let column = column![
row![ 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)) main_area.width(Length::FillPortion(4))
], ],
preview_bar preview_bar

View file

@ -76,7 +76,7 @@ pub enum Action {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub(crate) enum Message { pub(crate) enum Message {
AddItem(LibraryKind), AddItem,
DeleteItem((LibraryKind, i32)), DeleteItem((LibraryKind, i32)),
OpenItem(Option<(LibraryKind, i32)>), OpenItem(Option<(LibraryKind, i32)>),
HoverLibrary(Option<LibraryKind>), HoverLibrary(Option<LibraryKind>),
@ -128,24 +128,6 @@ impl<'a> Library {
pub fn update(&'a mut self, message: Message) -> Action { pub fn update(&'a mut self, message: Message) -> Action {
match message { 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::None => (),
Message::DeleteItem((kind, index)) => { Message::DeleteItem((kind, index)) => {
match kind { match kind {
@ -708,7 +690,7 @@ impl<'a> Library {
let library_toolbar = rowm!( let library_toolbar = rowm!(
text_input("Search...", ""), text_input("Search...", ""),
button::icon(icon::from_name("add")) button::icon(icon::from_name("add"))
.on_press(Message::AddItem(model.kind)) .on_press(Message::AddItem)
); );
let library_column = let library_column =
column![library_toolbar, items].spacing(3); column![library_toolbar, items].spacing(3);

View file

@ -286,7 +286,7 @@ impl SongEditor {
.padding(cosmic::theme::spacing().space_s) .padding(cosmic::theme::spacing().space_s)
.center_x(Length::FillPortion(2)) .center_x(Length::FillPortion(2))
} else { } else {
container(vertical_space()) container(horizontal_space())
}; };
let slide_preview = container(self.slide_preview()) let slide_preview = container(self.slide_preview())
.width(Length::FillPortion(2)); .width(Length::FillPortion(2));
@ -455,8 +455,10 @@ order",
v.set_looping(true); v.set_looping(true);
v v
}); });
debug!(?video); // debug!(?video);
self.video = video; self.video = video;
} else {
self.video = None;
} }
} }
} }