some more cleanup

This commit is contained in:
Chris Cochrun 2025-09-28 14:27:08 -05:00
parent 5e3ab8a22b
commit a3516ef70c
20 changed files with 87 additions and 104 deletions

View file

@ -10,8 +10,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::{Path, PathBuf}; use std::path::{Path, PathBuf};
use tracing::{debug, error}; use tracing::{debug, error};

View file

@ -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)]

View file

@ -4,8 +4,8 @@ use miette::{IntoDiagnostic, Result};
use mupdf::{Colorspace, Document, Matrix}; use mupdf::{Colorspace, Document, Matrix};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sqlx::{ use sqlx::{
Row, Sqlite, SqliteConnection, SqlitePool, pool::PoolConnection, pool::PoolConnection, prelude::FromRow, query, sqlite::SqliteRow,
prelude::FromRow, query, sqlite::SqliteRow, Row, Sqlite, SqliteConnection, SqlitePool,
}; };
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use tracing::{debug, error}; use tracing::{debug, error};

View file

@ -12,7 +12,7 @@ use crate::Slide;
use super::images::Image; use super::images::Image;
use super::presentations::Presentation; use super::presentations::Presentation;
use super::songs::{Song, lisp_to_song}; use super::songs::{lisp_to_song, Song};
use super::videos::Video; use super::videos::Video;
use super::kinds::ServiceItemKind; use super::kinds::ServiceItemKind;

View file

@ -2,7 +2,7 @@ use cosmic::widget::image::Handle;
// use cosmic::dialog::ashpd::url::Url; // use cosmic::dialog::ashpd::url::Url;
use crisp::types::{Keyword, Symbol, Value}; use crisp::types::{Keyword, Symbol, Value};
use iced_video_player::Video; use iced_video_player::Video;
use miette::{Result, miette}; use miette::{miette, Result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{ use std::{
fmt::Display, fmt::Display,

View file

@ -1,15 +1,15 @@
use std::{collections::HashMap, option::Option, path::PathBuf}; use std::{collections::HashMap, option::Option, path::PathBuf};
use crisp::types::{Keyword, Symbol, Value}; use crisp::types::{Keyword, Symbol, Value};
use miette::{IntoDiagnostic, Result, miette}; use miette::{miette, IntoDiagnostic, Result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sqlx::{ use sqlx::{
Acquire, FromRow, Row, Sqlite, SqliteConnection, SqlitePool, pool::PoolConnection, query, sqlite::SqliteRow, Acquire, FromRow,
pool::PoolConnection, query, sqlite::SqliteRow, Row, Sqlite, SqliteConnection, SqlitePool,
}; };
use tracing::error; use tracing::error;
use crate::{Slide, SlideBuilder, core::slide}; use crate::{core::slide, Slide, SlideBuilder};
use super::{ use super::{
content::Content, content::Content,

View file

@ -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::{Path, PathBuf}; use std::path::{Path, PathBuf};
use tracing::{debug, error}; use tracing::{debug, error};

View file

@ -40,11 +40,11 @@ mod test {
use std::{fs::read_to_string, path::PathBuf}; use std::{fs::read_to_string, path::PathBuf};
use crate::{ use crate::{
Background, TextAlignment,
core::{ core::{
images::Image, kinds::ServiceItemKind, images::Image, kinds::ServiceItemKind,
service_items::ServiceTrait, songs::Song, videos::Video, service_items::ServiceTrait, songs::Song, videos::Video,
}, },
Background, TextAlignment,
}; };
use super::*; use super::*;

View file

@ -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,8 +9,8 @@ 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::{ use cosmic::iced::{
self, Background as IcedBackground, Border, Color, Length, event, self, event, window, Background as IcedBackground, Border, Color,
window, Length,
}; };
use cosmic::iced_core::text::Wrapping; use cosmic::iced_core::text::Wrapping;
use cosmic::iced_futures::Subscription; use cosmic::iced_futures::Subscription;
@ -21,18 +21,18 @@ use cosmic::widget::menu::key_bind::Modifier;
use cosmic::widget::menu::{ItemWidth, KeyBind}; use cosmic::widget::menu::{ItemWidth, KeyBind};
use cosmic::widget::nav_bar::nav_bar_style; use cosmic::widget::nav_bar::nav_bar_style;
use cosmic::widget::tooltip::Position as TPosition; use cosmic::widget::tooltip::Position as TPosition;
use cosmic::widget::{Container, menu};
use cosmic::widget::{ use cosmic::widget::{
Space, button, context_menu, horizontal_space, mouse_area, button, context_menu, horizontal_space, mouse_area, nav_bar,
nav_bar, nav_bar_toggle, responsive, scrollable, search_input, nav_bar_toggle, responsive, scrollable, search_input, tooltip,
tooltip, vertical_space, vertical_space, Space,
}; };
use cosmic::widget::{container, text}; use cosmic::widget::{container, text};
use cosmic::widget::{icon, slider}; use cosmic::widget::{icon, slider};
use cosmic::{Application, ApplicationExt, Element, executor}; use cosmic::widget::{menu, Container};
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::collections::HashMap; use std::collections::HashMap;
@ -42,10 +42,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::image_editor::{self, ImageEditor}; use crate::ui::image_editor::{self, ImageEditor};
@ -1690,22 +1690,14 @@ where
tooltip, tooltip,
vec!["application/service-item".into()], vec!["application/service-item".into()],
) )
.data_received_for::<ServiceItem>(move |item| { .on_finish(move |mime, data, _, _, _| {
if let Some(item) = item {
Message::AddServiceItem(index, item)
} else {
Message::None
}
})
.forward_drag_as_cursor(true)
.on_finish(move |mime, data, action, x, y| {
debug!(mime, ?data, ?action, x, y);
let Ok(item) = let Ok(item) =
ServiceItem::try_from((data, mime)) ServiceItem::try_from((data, mime))
else { else {
error!("couldn't drag in Service item");
return Message::None; return Message::None;
}; };
debug!(?item); debug!(?item, index, "adding Service item");
Message::AddServiceItem(index, item) Message::AddServiceItem(index, item)
}) })
.into() .into()
@ -1763,24 +1755,15 @@ where
column, column,
vec!["application/service-item".into()], vec!["application/service-item".into()],
) )
.data_received_for::<ServiceItem>(|item| { .on_finish(move |mime, data, _, _, _| {
item.map_or_else( let Ok(item) = ServiceItem::try_from((data, mime))
|| Message::None, else {
Message::AppendServiceItem, error!("couldn't drag in Service item");
) return Message::None;
}) };
.on_finish( debug!(?item, "adding Service item");
move |mime, data, action, x, y| { Message::AppendServiceItem(item)
debug!(mime, ?data, ?action, x, y); }),
let Ok(item) =
ServiceItem::try_from((data, mime))
else {
return Message::None;
};
debug!(?item);
Message::AppendServiceItem(item)
},
),
) )
.style(nav_bar_style); .style(nav_bar_style);

View file

@ -2,15 +2,15 @@ use std::{io, path::PathBuf};
use crate::core::images::Image; use crate::core::images::Image;
use cosmic::{ use cosmic::{
Element, Task, dialog::file_chooser::{open::Dialog, FileFilter},
dialog::file_chooser::{FileFilter, open::Dialog}, iced::{alignment::Vertical, Length},
iced::{Length, alignment::Vertical},
iced_widget::{column, row}, iced_widget::{column, row},
theme, theme,
widget::{ widget::{
self, Space, button, container, horizontal_space, icon, text, self, button, container, horizontal_space, icon, text,
text_input, text_input, Space,
}, },
Element, Task,
}; };
use tracing::{debug, error, warn}; use tracing::{debug, error, warn};

View file

@ -1,35 +1,36 @@
use std::collections::HashMap; use std::collections::HashMap;
use cosmic::{ use cosmic::{
Element, Task,
dialog::file_chooser::open::Dialog, dialog::file_chooser::open::Dialog,
iced::{ iced::{
Background, Border, Color, Length, alignment::Vertical, alignment::Vertical, clipboard::dnd::DndAction,
clipboard::dnd::DndAction, keyboard::Modifiers, keyboard::Modifiers, 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, dnd_destination,
dnd_destination, 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::{SqlitePool, migrate}; use sqlx::{migrate, SqlitePool};
use tracing::{debug, error, warn}; use tracing::{debug, error, warn};
use crate::core::{ use crate::core::{
content::Content, content::Content,
images::{self, Image, update_image_in_db}, images::{self, update_image_in_db, Image},
model::{LibraryKind, Model}, model::{LibraryKind, Model},
presentations::{self, Presentation, update_presentation_in_db}, presentations::{self, update_presentation_in_db, Presentation},
service_items::ServiceItem, service_items::ServiceItem,
songs::{self, Song, update_song_in_db}, songs::{self, update_song_in_db, Song},
videos::{self, Video, update_video_in_db}, videos::{self, update_video_in_db, Video},
}; };
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View file

@ -5,15 +5,15 @@ use crate::core::{
slide::Slide, slide::Slide,
}; };
use cosmic::{ use cosmic::{
Element, Task, dialog::file_chooser::{open::Dialog, FileFilter},
dialog::file_chooser::{FileFilter, open::Dialog}, iced::{alignment::Vertical, Length},
iced::{Length, alignment::Vertical},
iced_widget::{column, row}, iced_widget::{column, row},
theme, theme,
widget::{ widget::{
Space, button, container, horizontal_space, icon, text, button, container, horizontal_space, icon, text, text_input,
text_input, Space,
}, },
Element, Task,
}; };
use tracing::{debug, error, warn}; use tracing::{debug, error, warn};

View file

@ -7,32 +7,32 @@ use std::{
}; };
use cosmic::{ use cosmic::{
Task,
iced::{ iced::{
font::{Family, Stretch, Style, Weight},
Background, Border, Color, ContentFit, Font, Length, Shadow, Background, Border, Color, ContentFit, Font, Length, Shadow,
Vector, Vector,
font::{Family, Stretch, Style, Weight},
}, },
iced_widget::{ iced_widget::{
scrollable::{ scrollable::{
AbsoluteOffset, Direction, Scrollbar, scroll_to, scroll_to, AbsoluteOffset, Direction, Scrollbar,
}, },
stack, vertical_rule, stack, vertical_rule,
}, },
prelude::*, prelude::*,
widget::{ widget::{
Container, Id, Row, Space, container, image, mouse_area, container, image, mouse_area, responsive, scrollable, text,
responsive, scrollable, text, Container, Id, Row, Space,
}, },
Task,
}; };
use iced_video_player::{Position, Video, VideoPlayer, gst_pbutils}; use iced_video_player::{gst_pbutils, Position, Video, VideoPlayer};
use rodio::{Decoder, OutputStream, OutputStreamBuilder, Sink}; use rodio::{Decoder, OutputStream, OutputStreamBuilder, Sink};
use tracing::{debug, error, info, warn}; use tracing::{debug, error, info, warn};
use url::Url; use url::Url;
use crate::{ use crate::{
BackgroundKind,
core::{service_items::ServiceItem, slide::Slide}, core::{service_items::ServiceItem, slide::Slide},
BackgroundKind,
}; };
const REFERENCE_WIDTH: f32 = 1920.0; const REFERENCE_WIDTH: f32 = 1920.0;

View file

@ -2,16 +2,15 @@ use cosmic::iced::Size;
use cosmic::iced_core::widget::tree; use cosmic::iced_core::widget::tree;
use cosmic::{ use cosmic::{
Element,
iced::{ iced::{
Event, Length, Point, Rectangle, Vector,
clipboard::dnd::{DndEvent, SourceEvent}, clipboard::dnd::{DndEvent, SourceEvent},
event, mouse, event, mouse, Event, Length, Point, Rectangle, Vector,
}, },
iced_core::{ iced_core::{
self, Clipboard, Shell, layout, renderer, widget::Tree, self, layout, renderer, widget::Tree, Clipboard, Shell,
}, },
widget::Widget, widget::Widget,
Element,
}; };
use tracing::debug; use tracing::debug;

View file

@ -1,13 +1,13 @@
use std::{io, path::PathBuf}; use std::{io, path::PathBuf};
use cosmic::{ use cosmic::{
Renderer,
iced::{Color, Font, Length, Size}, iced::{Color, Font, Length, Size},
widget::{ widget::{
self, self,
canvas::{self, Program, Stroke}, canvas::{self, Program, Stroke},
container, container,
}, },
Renderer,
}; };
use tracing::debug; use tracing::debug;

View file

@ -1,9 +1,8 @@
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, FileFilter},
dialog::file_chooser::{FileFilter, open::Dialog}, iced::{alignment::Vertical, Length},
iced::{Length, alignment::Vertical},
iced_wgpu::graphics::text::cosmic_text::fontdb, iced_wgpu::graphics::text::cosmic_text::fontdb,
iced_widget::{column, row}, iced_widget::{column, row},
theme, theme,
@ -11,6 +10,7 @@ use cosmic::{
button, combo_box, container, horizontal_space, icon, button, combo_box, container, horizontal_space, icon,
progress_bar, scrollable, text, text_editor, text_input, progress_bar, scrollable, 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;
@ -18,11 +18,11 @@ use rayon::iter::{IntoParallelIterator, ParallelIterator};
use tracing::{debug, error}; use tracing::{debug, error};
use crate::{ use crate::{
Background, BackgroundKind,
core::{service_items::ServiceTrait, slide::Slide, songs::Song}, core::{service_items::ServiceTrait, slide::Slide, songs::Song},
ui::{ ui::{
presenter::slide_view, slide_editor::SlideEditor, text_svg, presenter::slide_view, slide_editor::SlideEditor, text_svg,
}, },
Background, BackgroundKind,
}; };
#[derive(Debug)] #[derive(Debug)]

View file

@ -8,16 +8,16 @@ use std::{
use colors_transform::Rgb; use colors_transform::Rgb;
use cosmic::{ use cosmic::{
iced::{ iced::{
ContentFit, Length, Size,
font::{Style, Weight}, font::{Style, Weight},
ContentFit, Length, Size,
}, },
prelude::*, prelude::*,
widget::{Image, image::Handle}, widget::{image::Handle, Image},
}; };
use rapidhash::v3::rapidhash_v3; use rapidhash::v3::rapidhash_v3;
use resvg::{ use resvg::{
tiny_skia::{self, Pixmap}, tiny_skia::{self, Pixmap},
usvg::{Tree, fontdb}, usvg::{fontdb, Tree},
}; };
use tracing::{debug, error}; use tracing::{debug, error};

View file

@ -1,15 +1,15 @@
use std::{io, path::PathBuf}; use std::{io, path::PathBuf};
use cosmic::{ use cosmic::{
Element, Task, dialog::file_chooser::{open::Dialog, FileFilter},
dialog::file_chooser::{FileFilter, open::Dialog}, iced::{alignment::Vertical, Length},
iced::{Length, alignment::Vertical},
iced_widget::{column, row}, iced_widget::{column, row},
theme, theme,
widget::{ widget::{
Space, button, container, horizontal_space, icon, button, container, horizontal_space, icon, progress_bar,
progress_bar, text, text_input, text, text_input, Space,
}, },
Element, Task,
}; };
use iced_video_player::{Video, VideoPlayer}; use iced_video_player::{Video, VideoPlayer};
use tracing::{debug, error, warn}; use tracing::{debug, error, warn};

View file

@ -22,17 +22,17 @@
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
use cosmic::Theme;
use cosmic::iced::advanced::layout::{self, Layout}; use cosmic::iced::advanced::layout::{self, Layout};
use cosmic::iced::advanced::widget::{Operation, Tree, Widget, tree}; use cosmic::iced::advanced::widget::{tree, Operation, Tree, Widget};
use cosmic::iced::advanced::{Clipboard, Shell, overlay, renderer}; use cosmic::iced::advanced::{overlay, renderer, Clipboard, Shell};
use cosmic::iced::alignment::{self, Alignment}; use cosmic::iced::alignment::{self, Alignment};
use cosmic::iced::event::{self, Event}; use cosmic::iced::event::{self, Event};
use cosmic::iced::{self, Transformation, mouse}; use cosmic::iced::{self, mouse, Transformation};
use cosmic::iced::{ use cosmic::iced::{
Background, Border, Color, Element, Length, Padding, Pixels, Background, Border, Color, Element, Length, Padding, Pixels,
Point, Rectangle, Size, Vector, Point, Rectangle, Size, Vector,
}; };
use cosmic::Theme;
use tracing::debug; use tracing::debug;
use super::{Action, DragEvent, DropPosition}; use super::{Action, DragEvent, DropPosition};

View file

@ -23,11 +23,11 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
use cosmic::iced::advanced::layout::{self, Layout}; use cosmic::iced::advanced::layout::{self, Layout};
use cosmic::iced::advanced::widget::{Operation, Tree, Widget, tree}; use cosmic::iced::advanced::widget::{tree, Operation, Tree, Widget};
use cosmic::iced::advanced::{Clipboard, Shell, overlay, renderer}; use cosmic::iced::advanced::{overlay, renderer, Clipboard, Shell};
use cosmic::iced::alignment::{self, Alignment}; use cosmic::iced::alignment::{self, Alignment};
use cosmic::iced::event::{self, Event}; use cosmic::iced::event::{self, Event};
use cosmic::iced::{self, Transformation, mouse}; use cosmic::iced::{self, mouse, Transformation};
use cosmic::iced::{ use cosmic::iced::{
Background, Border, Color, Element, Length, Padding, Pixels, Background, Border, Color, Element, Length, Padding, Pixels,
Point, Rectangle, Size, Theme, Vector, Point, Rectangle, Size, Theme, Vector,