diff --git a/src/core/service_items.rs b/src/core/service_items.rs index a3c5eeb..19c2301 100644 --- a/src/core/service_items.rs +++ b/src/core/service_items.rs @@ -221,9 +221,9 @@ impl From<&Value> for ServiceItem { let song = lisp_to_song(list.clone()); Self::from(&song) } - _ => todo!(), + _ => ServiceItem::default(), }, - _ => todo!(), + _ => ServiceItem::default(), } } } diff --git a/src/main.rs b/src/main.rs index d84c7d7..9d1cd41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -318,38 +318,46 @@ impl cosmic::Application for App { }).on_drop(move |x, y| { debug!(x, y); cosmic::Action::App(Message::AddServiceItemDrop(index)) - }).on_data_received( move |mime, data| { - debug!(?data, mime); - let Ok(item) = ServiceItem::try_from((data.clone(), mime.clone())) else { - return cosmic::Action::None; - }; - cosmic::Action::App(Message::AddServiceItem(index, item)) }).on_finish(move |mime, data, action, x, y| { debug!(mime, ?data, ?action, x, y); - let Ok(item) = ServiceItem::try_from((data.clone(), mime.clone())) else { + let Ok(item) = ServiceItem::try_from((data, mime)) else { return cosmic::Action::None; }; + debug!(?item); cosmic::Action::App(Message::AddServiceItem(index, item)) }) .into() }); + let end_index = self.service.len(); let column = column![ text::heading("Service List").center().width(280), column(list).spacing(10), - dnd_destination_for_data::< - ServiceItem, - cosmic::Action, - >( - Container::new(vertical_space()), - |item, _| { - if let Some(item) = item { - cosmic::Action::App( - Message::AppendServiceItem(item), - ) - } else { - cosmic::Action::None - } + dnd_destination( + vertical_space(), + vec!["application/service-item".into()] + ) + .data_received_for::(|item| { + if let Some(item) = item { + cosmic::Action::App(Message::AppendServiceItem( + item, + )) + } else { + cosmic::Action::None + } + }) + .on_finish( + move |mime, data, action, x, y| { + debug!(mime, ?data, ?action, x, y); + let Ok(item) = + ServiceItem::try_from((data, mime)) + else { + return cosmic::Action::None; + }; + debug!(?item); + cosmic::Action::App(Message::AddServiceItem( + end_index, item, + )) } ) ] diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 0289c38..8372371 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -3,11 +3,11 @@ use crate::core::model::LibraryKind; pub mod double_ended_slider; pub mod library; pub mod presenter; +pub mod slide_editor; pub mod song_editor; pub mod text_svg; pub mod video; pub mod widgets; -pub mod slide_editor; pub enum EditorMode { Song,