This commit is contained in:
parent
085c8244f9
commit
49117a39a3
2 changed files with 34 additions and 7 deletions
|
|
@ -2,7 +2,10 @@ use std::{error::Error, fmt::Display};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::Slide;
|
use crate::{
|
||||||
|
core::{content::Content, service_items::ServiceItem},
|
||||||
|
Slide,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
images::Image, presentations::Presentation, songs::Song,
|
images::Image, presentations::Presentation, songs::Song,
|
||||||
|
|
@ -30,6 +33,20 @@ impl ServiceItemKind {
|
||||||
ServiceItemKind::Content(slide) => todo!(),
|
ServiceItemKind::Content(slide) => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn to_service_item(&self) -> ServiceItem {
|
||||||
|
match self {
|
||||||
|
ServiceItemKind::Song(song) => song.to_service_item(),
|
||||||
|
ServiceItemKind::Video(video) => video.to_service_item(),
|
||||||
|
ServiceItemKind::Image(image) => image.to_service_item(),
|
||||||
|
ServiceItemKind::Presentation(presentation) => {
|
||||||
|
presentation.to_service_item()
|
||||||
|
}
|
||||||
|
ServiceItemKind::Content(slide) => {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for ServiceItemKind {
|
impl std::fmt::Display for ServiceItemKind {
|
||||||
|
|
|
||||||
22
src/main.rs
22
src/main.rs
|
|
@ -134,7 +134,7 @@ struct App {
|
||||||
presentation_editor: PresentationEditor,
|
presentation_editor: PresentationEditor,
|
||||||
searching: bool,
|
searching: bool,
|
||||||
search_query: String,
|
search_query: String,
|
||||||
search_results: Vec<ServiceItem>,
|
search_results: Vec<ServiceItemKind>,
|
||||||
search_id: cosmic::widget::Id,
|
search_id: cosmic::widget::Id,
|
||||||
library_dragged_item: Option<ServiceItem>,
|
library_dragged_item: Option<ServiceItem>,
|
||||||
fontdb: Arc<fontdb::Database>,
|
fontdb: Arc<fontdb::Database>,
|
||||||
|
|
@ -170,13 +170,15 @@ enum Message {
|
||||||
RemoveServiceItem(usize),
|
RemoveServiceItem(usize),
|
||||||
AddServiceItemDrop(usize),
|
AddServiceItemDrop(usize),
|
||||||
AppendServiceItem(ServiceItem),
|
AppendServiceItem(ServiceItem),
|
||||||
|
AppendServiceItemKind(ServiceItemKind),
|
||||||
ReorderService(usize, usize),
|
ReorderService(usize, usize),
|
||||||
ContextMenuItem(usize),
|
ContextMenuItem(usize),
|
||||||
SearchFocus,
|
SearchFocus,
|
||||||
Search(String),
|
Search(String),
|
||||||
CloseSearch,
|
CloseSearch,
|
||||||
UpdateSearchResults(Vec<ServiceItem>),
|
UpdateSearchResults(Vec<ServiceItemKind>),
|
||||||
OpenEditor(ServiceItem),
|
OpenEditor(ServiceItem),
|
||||||
|
OpenEditorKind(ServiceItemKind),
|
||||||
New,
|
New,
|
||||||
Open,
|
Open,
|
||||||
OpenFile(PathBuf),
|
OpenFile(PathBuf),
|
||||||
|
|
@ -671,8 +673,8 @@ impl cosmic::Application for App {
|
||||||
.search_results
|
.search_results
|
||||||
.iter()
|
.iter()
|
||||||
.map(|item| {
|
.map(|item| {
|
||||||
let title = text::title4(item.title.clone());
|
let title = text::title4(item.title().clone());
|
||||||
let subtitle = text::body(item.kind.to_string());
|
let subtitle = text::body(item.to_string());
|
||||||
Element::from(Container::new(
|
Element::from(Container::new(
|
||||||
row![
|
row![
|
||||||
column![title, subtitle].spacing(
|
column![title, subtitle].spacing(
|
||||||
|
|
@ -692,7 +694,7 @@ impl cosmic::Application for App {
|
||||||
.space_l()
|
.space_l()
|
||||||
)
|
)
|
||||||
.on_press(
|
.on_press(
|
||||||
Message::AppendServiceItem(
|
Message::AppendServiceItemKind(
|
||||||
item.clone()
|
item.clone()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
@ -709,7 +711,7 @@ impl cosmic::Application for App {
|
||||||
.cosmic()
|
.cosmic()
|
||||||
.space_l()
|
.space_l()
|
||||||
)
|
)
|
||||||
.on_press(Message::OpenEditor(
|
.on_press(Message::OpenEditorKind(
|
||||||
item.clone()
|
item.clone()
|
||||||
)),
|
)),
|
||||||
"Edit Item",
|
"Edit Item",
|
||||||
|
|
@ -1289,6 +1291,10 @@ impl cosmic::Application for App {
|
||||||
self.presenter.update_items(self.service.clone());
|
self.presenter.update_items(self.service.clone());
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
Message::AppendServiceItemKind(item) => {
|
||||||
|
let item = item.to_service_item();
|
||||||
|
return self.update(Message::AppendServiceItem(item));
|
||||||
|
}
|
||||||
Message::ReorderService(index, target_index) => {
|
Message::ReorderService(index, target_index) => {
|
||||||
let item = self.service.remove(index);
|
let item = self.service.remove(index);
|
||||||
self.service.insert(target_index, item);
|
self.service.insert(target_index, item);
|
||||||
|
|
@ -1340,6 +1346,10 @@ impl cosmic::Application for App {
|
||||||
ServiceItemKind::Content(_slide) => todo!(),
|
ServiceItemKind::Content(_slide) => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::OpenEditorKind(item) => {
|
||||||
|
let item = item.to_service_item();
|
||||||
|
return self.update(Message::OpenEditor(item));
|
||||||
|
}
|
||||||
Message::New => {
|
Message::New => {
|
||||||
debug!("new file");
|
debug!("new file");
|
||||||
Task::none()
|
Task::none()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue