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>,
|
editor_mode: Option<EditorMode>,
|
||||||
song_editor: SongEditor,
|
song_editor: SongEditor,
|
||||||
searching: bool,
|
searching: bool,
|
||||||
|
library_dragged_item: Option<ServiceItem>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -134,6 +135,7 @@ enum Message {
|
||||||
SearchFocus,
|
SearchFocus,
|
||||||
ChangeServiceItem(usize),
|
ChangeServiceItem(usize),
|
||||||
AddServiceItem(usize, ServiceItem),
|
AddServiceItem(usize, ServiceItem),
|
||||||
|
AddServiceItemDrop(usize),
|
||||||
AppendServiceItem(ServiceItem),
|
AppendServiceItem(ServiceItem),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,6 +216,7 @@ impl cosmic::Application for App {
|
||||||
song_editor,
|
song_editor,
|
||||||
searching: false,
|
searching: false,
|
||||||
current_item: (0, 0),
|
current_item: (0, 0),
|
||||||
|
library_dragged_item: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut batch = vec![];
|
let mut batch = vec![];
|
||||||
|
@ -305,6 +308,7 @@ impl cosmic::Application for App {
|
||||||
let tooltip = tooltip(button,
|
let tooltip = tooltip(button,
|
||||||
text::body(item.kind.to_string()),
|
text::body(item.kind.to_string()),
|
||||||
TPosition::Right);
|
TPosition::Right);
|
||||||
|
let dragged_item = &self.library_dragged_item;
|
||||||
dnd_destination(tooltip, vec!["application/service-item".into()])
|
dnd_destination(tooltip, vec!["application/service-item".into()])
|
||||||
.data_received_for::<ServiceItem>( move |item| {
|
.data_received_for::<ServiceItem>( move |item| {
|
||||||
if let Some(item) = item {
|
if let Some(item) = item {
|
||||||
|
@ -312,9 +316,9 @@ impl cosmic::Application for App {
|
||||||
} else {
|
} else {
|
||||||
cosmic::Action::None
|
cosmic::Action::None
|
||||||
}
|
}
|
||||||
}).on_drop(|index, idk| {
|
}).on_drop(move |x, y| {
|
||||||
debug!(index, idk);
|
debug!(x, y);
|
||||||
cosmic::Action::None
|
cosmic::Action::App(Message::AddServiceItemDrop(index))
|
||||||
}).on_data_received( move |mime, data| {
|
}).on_data_received( move |mime, data| {
|
||||||
debug!(?data, mime);
|
debug!(?data, mime);
|
||||||
let Ok(item) = ServiceItem::try_from((data.clone(), mime.clone())) else {
|
let Ok(item) = ServiceItem::try_from((data.clone(), mime.clone())) else {
|
||||||
|
@ -774,10 +778,12 @@ impl cosmic::Application for App {
|
||||||
service_item,
|
service_item,
|
||||||
) => {
|
) => {
|
||||||
debug!("hi");
|
debug!("hi");
|
||||||
self.nav_model
|
self.library_dragged_item =
|
||||||
.insert()
|
Some(service_item);
|
||||||
.text(service_item.title.clone())
|
// self.nav_model
|
||||||
.data(service_item);
|
// .insert()
|
||||||
|
// .text(service_item.title.clone())
|
||||||
|
// .data(service_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -929,6 +935,12 @@ impl cosmic::Application for App {
|
||||||
self.service.insert(index, item);
|
self.service.insert(index, item);
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
Message::AddServiceItemDrop(index) => {
|
||||||
|
if let Some(item) = &self.library_dragged_item {
|
||||||
|
self.service.insert(index, item.clone());
|
||||||
|
}
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
Message::AppendServiceItem(item) => {
|
Message::AppendServiceItem(item) => {
|
||||||
self.service.push(item);
|
self.service.push(item);
|
||||||
Task::none()
|
Task::none()
|
||||||
|
|
|
@ -366,8 +366,6 @@ impl<'a> Library {
|
||||||
model.items.iter().enumerate().map(
|
model.items.iter().enumerate().map(
|
||||||
|(index, item)| {
|
|(index, item)| {
|
||||||
let service_item = item.to_service_item();
|
let service_item = item.to_service_item();
|
||||||
let drag_item =
|
|
||||||
Box::new(self.single_item(index, item, &model));
|
|
||||||
let visual_item = self
|
let visual_item = self
|
||||||
.single_item(index, item, model)
|
.single_item(index, item, model)
|
||||||
.map(|_| Message::None);
|
.map(|_| Message::None);
|
||||||
|
@ -402,7 +400,7 @@ impl<'a> Library {
|
||||||
let icon = match model {
|
let icon = match model {
|
||||||
LibraryKind::Song => icon::from_name(
|
LibraryKind::Song => icon::from_name(
|
||||||
"folder-music-symbolic",
|
"folder-music-symbolic",
|
||||||
)
|
).symbolic(true)
|
||||||
,
|
,
|
||||||
LibraryKind::Video => icon::from_name("folder-videos-symbolic"),
|
LibraryKind::Video => icon::from_name("folder-videos-symbolic"),
|
||||||
LibraryKind::Image => icon::from_name("folder-pictures-symbolic"),
|
LibraryKind::Image => icon::from_name("folder-pictures-symbolic"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue