This commit is contained in:
parent
0c51e7a724
commit
adbfd8ce0f
2 changed files with 20 additions and 10 deletions
26
src/main.rs
26
src/main.rs
|
@ -110,6 +110,7 @@ struct App {
|
|||
editor_mode: Option<EditorMode>,
|
||||
song_editor: SongEditor,
|
||||
searching: bool,
|
||||
library_dragged_item: Option<ServiceItem>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -134,6 +135,7 @@ enum Message {
|
|||
SearchFocus,
|
||||
ChangeServiceItem(usize),
|
||||
AddServiceItem(usize, ServiceItem),
|
||||
AddServiceItemDrop(usize),
|
||||
AppendServiceItem(ServiceItem),
|
||||
}
|
||||
|
||||
|
@ -214,6 +216,7 @@ impl cosmic::Application for App {
|
|||
song_editor,
|
||||
searching: false,
|
||||
current_item: (0, 0),
|
||||
library_dragged_item: None,
|
||||
};
|
||||
|
||||
let mut batch = vec![];
|
||||
|
@ -305,6 +308,7 @@ 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::<ServiceItem>( move |item| {
|
||||
if let Some(item) = item {
|
||||
|
@ -312,9 +316,9 @@ impl cosmic::Application for App {
|
|||
} else {
|
||||
cosmic::Action::None
|
||||
}
|
||||
}).on_drop(|index, idk| {
|
||||
debug!(index, idk);
|
||||
cosmic::Action::None
|
||||
}).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 {
|
||||
|
@ -774,10 +778,12 @@ impl cosmic::Application for App {
|
|||
service_item,
|
||||
) => {
|
||||
debug!("hi");
|
||||
self.nav_model
|
||||
.insert()
|
||||
.text(service_item.title.clone())
|
||||
.data(service_item);
|
||||
self.library_dragged_item =
|
||||
Some(service_item);
|
||||
// self.nav_model
|
||||
// .insert()
|
||||
// .text(service_item.title.clone())
|
||||
// .data(service_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -929,6 +935,12 @@ impl cosmic::Application for App {
|
|||
self.service.insert(index, item);
|
||||
Task::none()
|
||||
}
|
||||
Message::AddServiceItemDrop(index) => {
|
||||
if let Some(item) = &self.library_dragged_item {
|
||||
self.service.insert(index, item.clone());
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
Message::AppendServiceItem(item) => {
|
||||
self.service.push(item);
|
||||
Task::none()
|
||||
|
|
|
@ -366,8 +366,6 @@ impl<'a> Library {
|
|||
model.items.iter().enumerate().map(
|
||||
|(index, item)| {
|
||||
let service_item = item.to_service_item();
|
||||
let drag_item =
|
||||
Box::new(self.single_item(index, item, &model));
|
||||
let visual_item = self
|
||||
.single_item(index, item, model)
|
||||
.map(|_| Message::None);
|
||||
|
@ -402,7 +400,7 @@ impl<'a> Library {
|
|||
let icon = match model {
|
||||
LibraryKind::Song => icon::from_name(
|
||||
"folder-music-symbolic",
|
||||
)
|
||||
).symbolic(true)
|
||||
,
|
||||
LibraryKind::Video => icon::from_name("folder-videos-symbolic"),
|
||||
LibraryKind::Image => icon::from_name("folder-pictures-symbolic"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue