parent
de0722b430
commit
b03382f687
6 changed files with 33 additions and 32 deletions
|
@ -1,6 +1,6 @@
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
|
|
||||||
use miette::{Result, miette};
|
use miette::{miette, Result};
|
||||||
use sqlx::{Connection, SqliteConnection};
|
use sqlx::{Connection, SqliteConnection};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
@ -181,7 +181,7 @@ impl TryFrom<PathBuf> for Background {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Couldn't canonicalize: {e} {:?}", path);
|
// error!("Couldn't canonicalize: {e} {:?}", path);
|
||||||
Err(ParseError::CannotCanonicalize)
|
Err(ParseError::CannotCanonicalize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ use crisp::types::{Keyword, Symbol, Value};
|
||||||
use miette::{IntoDiagnostic, Result};
|
use miette::{IntoDiagnostic, Result};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{
|
use sqlx::{
|
||||||
Sqlite, SqliteConnection, SqlitePool, pool::PoolConnection,
|
pool::PoolConnection, query, query_as, Sqlite, SqliteConnection,
|
||||||
query, query_as,
|
SqlitePool,
|
||||||
};
|
};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -1,4 +1,4 @@
|
||||||
use clap::{Parser, command};
|
use clap::{command, Parser};
|
||||||
use core::service_items::ServiceItem;
|
use core::service_items::ServiceItem;
|
||||||
use core::slide::{
|
use core::slide::{
|
||||||
Background, BackgroundKind, Slide, SlideBuilder, TextAlignment,
|
Background, BackgroundKind, Slide, SlideBuilder, TextAlignment,
|
||||||
|
@ -9,24 +9,24 @@ use cosmic::app::{Core, Settings, Task};
|
||||||
use cosmic::iced::alignment::Vertical;
|
use cosmic::iced::alignment::Vertical;
|
||||||
use cosmic::iced::keyboard::{Key, Modifiers};
|
use cosmic::iced::keyboard::{Key, Modifiers};
|
||||||
use cosmic::iced::window::{Mode, Position};
|
use cosmic::iced::window::{Mode, Position};
|
||||||
use cosmic::iced::{self, Length, Point, event, window};
|
use cosmic::iced::{self, event, window, Length, Point};
|
||||||
use cosmic::iced_futures::Subscription;
|
use cosmic::iced_futures::Subscription;
|
||||||
use cosmic::iced_widget::{column, row, stack};
|
use cosmic::iced_widget::{column, row, stack};
|
||||||
use cosmic::theme;
|
use cosmic::theme;
|
||||||
use cosmic::widget::Container;
|
|
||||||
use cosmic::widget::dnd_destination::dnd_destination;
|
use cosmic::widget::dnd_destination::dnd_destination;
|
||||||
use cosmic::widget::nav_bar::nav_bar_style;
|
use cosmic::widget::nav_bar::nav_bar_style;
|
||||||
use cosmic::widget::text;
|
use cosmic::widget::text;
|
||||||
use cosmic::widget::tooltip::Position as TPosition;
|
use cosmic::widget::tooltip::Position as TPosition;
|
||||||
|
use cosmic::widget::Container;
|
||||||
use cosmic::widget::{
|
use cosmic::widget::{
|
||||||
Space, button, horizontal_space, mouse_area, nav_bar,
|
button, horizontal_space, mouse_area, nav_bar, search_input,
|
||||||
search_input, tooltip, vertical_space,
|
tooltip, vertical_space, Space,
|
||||||
};
|
};
|
||||||
use cosmic::widget::{icon, slider};
|
use cosmic::widget::{icon, slider};
|
||||||
use cosmic::{Application, ApplicationExt, Element, executor};
|
use cosmic::{executor, Application, ApplicationExt, Element};
|
||||||
use crisp::types::Value;
|
use crisp::types::Value;
|
||||||
use lisp::parse_lisp;
|
use lisp::parse_lisp;
|
||||||
use miette::{Result, miette};
|
use miette::{miette, Result};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use resvg::usvg::fontdb;
|
use resvg::usvg::fontdb;
|
||||||
use std::fs::read_to_string;
|
use std::fs::read_to_string;
|
||||||
|
@ -35,10 +35,10 @@ use std::sync::Arc;
|
||||||
use tracing::{debug, level_filters::LevelFilter};
|
use tracing::{debug, level_filters::LevelFilter};
|
||||||
use tracing::{error, warn};
|
use tracing::{error, warn};
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
use ui::EditorMode;
|
|
||||||
use ui::library::{self, Library};
|
use ui::library::{self, Library};
|
||||||
use ui::presenter::{self, Presenter};
|
use ui::presenter::{self, Presenter};
|
||||||
use ui::song_editor::{self, SongEditor};
|
use ui::song_editor::{self, SongEditor};
|
||||||
|
use ui::EditorMode;
|
||||||
|
|
||||||
use crate::core::kinds::ServiceItemKind;
|
use crate::core::kinds::ServiceItemKind;
|
||||||
use crate::ui::text_svg::{self};
|
use crate::ui::text_svg::{self};
|
||||||
|
|
|
@ -1,38 +1,38 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
Element, Task,
|
|
||||||
iced::{
|
iced::{
|
||||||
Background, Border, Color, Length, alignment::Vertical,
|
alignment::Vertical, clipboard::dnd::DndAction,
|
||||||
clipboard::dnd::DndAction, futures::FutureExt,
|
futures::FutureExt, Background, Border, Color, Length,
|
||||||
},
|
},
|
||||||
iced_core::widget::tree::State,
|
iced_core::widget::tree::State,
|
||||||
iced_widget::{column, row as rowm, text as textm},
|
iced_widget::{column, row as rowm, text as textm},
|
||||||
theme,
|
theme,
|
||||||
widget::{
|
widget::{
|
||||||
Container, DndSource, Space, button, container, context_menu,
|
button, container, context_menu, horizontal_space, icon,
|
||||||
horizontal_space, icon,
|
|
||||||
menu::{self, Action as MenuAction},
|
menu::{self, Action as MenuAction},
|
||||||
mouse_area, responsive, row, scrollable, text, text_input,
|
mouse_area, responsive, row, scrollable, text, text_input,
|
||||||
|
Container, DndSource, Space,
|
||||||
},
|
},
|
||||||
|
Element, Task,
|
||||||
};
|
};
|
||||||
use miette::{IntoDiagnostic, Result};
|
use miette::{IntoDiagnostic, Result};
|
||||||
use rapidfuzz::distance::levenshtein;
|
use rapidfuzz::distance::levenshtein;
|
||||||
use sqlx::{Sqlite, SqlitePool, pool::PoolConnection};
|
use sqlx::{migrate, pool::PoolConnection, Sqlite, SqlitePool};
|
||||||
use tracing::{debug, error, warn};
|
use tracing::{debug, error, warn};
|
||||||
|
|
||||||
use crate::core::{
|
use crate::core::{
|
||||||
content::Content,
|
content::Content,
|
||||||
images::{Image, update_image_in_db},
|
images::{update_image_in_db, Image},
|
||||||
model::{LibraryKind, Model},
|
model::{LibraryKind, Model},
|
||||||
presentations::{Presentation, update_presentation_in_db},
|
presentations::{update_presentation_in_db, Presentation},
|
||||||
service_items::ServiceItem,
|
service_items::ServiceItem,
|
||||||
songs::{Song, update_song_in_db},
|
songs::{update_song_in_db, Song},
|
||||||
videos::{Video, update_video_in_db},
|
videos::{update_video_in_db, Video},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct Library {
|
pub struct Library {
|
||||||
song_library: Model<Song>,
|
song_library: Model<Song>,
|
||||||
image_library: Model<Image>,
|
image_library: Model<Image>,
|
||||||
video_library: Model<Video>,
|
video_library: Model<Video>,
|
||||||
|
@ -41,7 +41,6 @@ pub(crate) struct Library {
|
||||||
library_hovered: Option<LibraryKind>,
|
library_hovered: Option<LibraryKind>,
|
||||||
selected_item: Option<(LibraryKind, i32)>,
|
selected_item: Option<(LibraryKind, i32)>,
|
||||||
hovered_item: Option<(LibraryKind, i32)>,
|
hovered_item: Option<(LibraryKind, i32)>,
|
||||||
pub dragged_item: Option<(LibraryKind, i32)>,
|
|
||||||
editing_item: Option<(LibraryKind, i32)>,
|
editing_item: Option<(LibraryKind, i32)>,
|
||||||
db: SqlitePool,
|
db: SqlitePool,
|
||||||
menu_keys: std::collections::HashMap<menu::KeyBind, MenuMessage>,
|
menu_keys: std::collections::HashMap<menu::KeyBind, MenuMessage>,
|
||||||
|
@ -69,7 +68,7 @@ impl MenuAction for MenuMessage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) enum Action {
|
pub enum Action {
|
||||||
OpenItem(Option<(LibraryKind, i32)>),
|
OpenItem(Option<(LibraryKind, i32)>),
|
||||||
DraggedItem(ServiceItem),
|
DraggedItem(ServiceItem),
|
||||||
Task(Task<Message>),
|
Task(Task<Message>),
|
||||||
|
@ -77,7 +76,7 @@ pub(crate) enum Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) enum Message {
|
pub enum Message {
|
||||||
AddItem,
|
AddItem,
|
||||||
DeleteItem((LibraryKind, i32)),
|
DeleteItem((LibraryKind, i32)),
|
||||||
OpenItem(Option<(LibraryKind, i32)>),
|
OpenItem(Option<(LibraryKind, i32)>),
|
||||||
|
@ -102,6 +101,9 @@ pub(crate) enum Message {
|
||||||
impl<'a> Library {
|
impl<'a> Library {
|
||||||
pub async fn new() -> Self {
|
pub async fn new() -> Self {
|
||||||
let mut db = add_db().await.expect("probs");
|
let mut db = add_db().await.expect("probs");
|
||||||
|
if let Err(e) = migrate!("./migrations").run(&db).await {
|
||||||
|
error!(?e)
|
||||||
|
}
|
||||||
Self {
|
Self {
|
||||||
song_library: Model::new_song_model(&mut db).await,
|
song_library: Model::new_song_model(&mut db).await,
|
||||||
image_library: Model::new_image_model(&mut db).await,
|
image_library: Model::new_image_model(&mut db).await,
|
||||||
|
@ -114,7 +116,6 @@ impl<'a> Library {
|
||||||
library_hovered: None,
|
library_hovered: None,
|
||||||
selected_item: None,
|
selected_item: None,
|
||||||
hovered_item: None,
|
hovered_item: None,
|
||||||
dragged_item: None,
|
|
||||||
editing_item: None,
|
editing_item: None,
|
||||||
db,
|
db,
|
||||||
menu_keys: HashMap::new(),
|
menu_keys: HashMap::new(),
|
||||||
|
@ -465,7 +466,7 @@ impl<'a> Library {
|
||||||
if index == context_id as usize {
|
if index == context_id as usize {
|
||||||
let context_menu = context_menu(
|
let context_menu = context_menu(
|
||||||
mouse_area,
|
mouse_area,
|
||||||
self.context_menu.map_or_else(|| None, |id| {
|
self.context_menu.map_or_else(|| None, |_| {
|
||||||
Some(menu::items(&self.menu_keys,
|
Some(menu::items(&self.menu_keys,
|
||||||
vec![menu::Item::Button("Delete", None, MenuMessage::Delete((model.kind, index as i32)))]))
|
vec![menu::Item::Button("Delete", None, MenuMessage::Delete((model.kind, index as i32)))]))
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use std::{io, path::PathBuf, sync::Arc};
|
use std::{io, path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
Element, Task,
|
|
||||||
dialog::file_chooser::open::Dialog,
|
dialog::file_chooser::open::Dialog,
|
||||||
iced::{
|
iced::{
|
||||||
Font, Length,
|
|
||||||
font::{Family, Stretch, Style, Weight},
|
font::{Family, Stretch, Style, Weight},
|
||||||
|
Font, Length,
|
||||||
},
|
},
|
||||||
iced_wgpu::graphics::text::cosmic_text::fontdb,
|
iced_wgpu::graphics::text::cosmic_text::fontdb,
|
||||||
iced_widget::row,
|
iced_widget::row,
|
||||||
|
@ -14,14 +13,15 @@ use cosmic::{
|
||||||
button, column, combo_box, container, horizontal_space, icon,
|
button, column, combo_box, container, horizontal_space, icon,
|
||||||
text, text_editor, text_input,
|
text, text_editor, text_input,
|
||||||
},
|
},
|
||||||
|
Element, Task,
|
||||||
};
|
};
|
||||||
use dirs::font_dir;
|
use dirs::font_dir;
|
||||||
use iced_video_player::Video;
|
use iced_video_player::Video;
|
||||||
use tracing::{debug, error};
|
use tracing::{debug, error};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Background, BackgroundKind, core::songs::Song,
|
core::songs::Song, ui::slide_editor::SlideEditor, Background,
|
||||||
ui::slide_editor::SlideEditor,
|
BackgroundKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue