cargo fix

This commit is contained in:
Chris Cochrun 2025-05-01 09:44:35 -05:00
parent e6621072cd
commit 8cf2d48a16
14 changed files with 85 additions and 115 deletions

View file

@ -3,7 +3,7 @@ use crate::{Background, Slide, SlideBuilder, TextAlignment};
use super::{ use super::{
content::Content, content::Content,
kinds::ServiceItemKind, kinds::ServiceItemKind,
model::{get_db, LibraryKind, Model}, model::{LibraryKind, Model},
service_items::ServiceTrait, service_items::ServiceTrait,
}; };
use crisp::types::{Keyword, Symbol, Value}; use crisp::types::{Keyword, Symbol, Value};
@ -45,13 +45,7 @@ impl Content for Image {
} }
fn background(&self) -> Option<Background> { fn background(&self) -> Option<Background> {
if let Ok(background) = Background::try_from(self.path.clone()).ok()
Background::try_from(self.path.clone())
{
Some(background)
} else {
None
}
} }
fn subtext(&self) -> String { fn subtext(&self) -> String {

View file

@ -133,12 +133,12 @@ pub(crate) fn get_lists(exp: &Value) -> Vec<Value> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use std::fs::read_to_string;
use lexpr::{parse::Options, Parser};
use pretty_assertions::assert_eq;
use super::*;
// #[test] // #[test]
// fn test_list() { // fn test_list() {

View file

@ -4,7 +4,6 @@ use cosmic::iced::Executor;
use miette::{miette, Result}; use miette::{miette, Result};
use sqlx::{Connection, SqliteConnection}; use sqlx::{Connection, SqliteConnection};
use super::kinds::ServiceItemKind;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Model<T> { pub struct Model<T> {

View file

@ -13,7 +13,7 @@ use crate::{Background, Slide, SlideBuilder, TextAlignment};
use super::{ use super::{
content::Content, content::Content,
kinds::ServiceItemKind, kinds::ServiceItemKind,
model::{get_db, LibraryKind, Model}, model::{LibraryKind, Model},
service_items::ServiceTrait, service_items::ServiceTrait,
}; };
@ -57,13 +57,7 @@ impl Content for Presentation {
} }
fn background(&self) -> Option<Background> { fn background(&self) -> Option<Background> {
if let Ok(background) = Background::try_from(self.path.clone()).ok()
Background::try_from(self.path.clone())
{
Some(background)
} else {
None
}
} }
fn subtext(&self) -> String { fn subtext(&self) -> String {

View file

@ -3,7 +3,7 @@ use std::ops::Deref;
use cosmic::iced::clipboard::mime::{AllowedMimeTypes, AsMimeTypes}; use cosmic::iced::clipboard::mime::{AllowedMimeTypes, AsMimeTypes};
use crisp::types::{Keyword, Symbol, Value}; use crisp::types::{Keyword, Symbol, Value};
use miette::{miette, Result}; use miette::Result;
use tracing::{debug, error}; use tracing::{debug, error};
use crate::Slide; use crate::Slide;
@ -153,52 +153,50 @@ impl From<&Value> for ServiceItem {
database_id: 0, database_id: 0,
kind: ServiceItemKind::Content(slide), kind: ServiceItemKind::Content(slide),
} }
} else { } else if let Some(background) =
if let Some(background) = list.get(background_pos)
list.get(background_pos) {
{ match background {
match background { Value::List(item) => match &item[0] {
Value::List(item) => match &item[0] { Value::Symbol(Symbol(s))
Value::Symbol(Symbol(s)) if s == "image" =>
if s == "image" => {
{ Self::from(&Image::from(
Self::from(&Image::from( background,
background, ))
))
}
Value::Symbol(Symbol(s))
if s == "video" =>
{
Self::from(&Video::from(
background,
))
}
Value::Symbol(Symbol(s))
if s == "presentation" =>
{
Self::from(
&Presentation::from(
background,
),
)
}
_ => todo!(),
},
_ => {
error!(
"There is no background here: {:?}",
background
);
ServiceItem::default()
} }
Value::Symbol(Symbol(s))
if s == "video" =>
{
Self::from(&Video::from(
background,
))
}
Value::Symbol(Symbol(s))
if s == "presentation" =>
{
Self::from(
&Presentation::from(
background,
),
)
}
_ => todo!(),
},
_ => {
error!(
"There is no background here: {:?}",
background
);
ServiceItem::default()
} }
} else {
error!(
"There is no background here: {:?}",
background_pos
);
ServiceItem::default()
} }
} else {
error!(
"There is no background here: {:?}",
background_pos
);
ServiceItem::default()
} }
} }
Value::Symbol(Symbol(s)) if s == "song" => { Value::Symbol(Symbol(s)) if s == "song" => {
@ -342,7 +340,7 @@ mod test {
use crate::core::presentations::PresKind; use crate::core::presentations::PresKind;
use super::*; use super::*;
use pretty_assertions::{assert_eq, assert_ne}; use pretty_assertions::assert_eq;
fn test_song() -> Song { fn test_song() -> Song {
Song { Song {

View file

@ -1,6 +1,5 @@
// 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 gstreamer::query::Uri;
use iced_video_player::Video; use iced_video_player::Video;
use miette::{miette, Result}; use miette::{miette, Result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View file

@ -8,14 +8,14 @@ use sqlx::{
pool::PoolConnection, query, sqlite::SqliteRow, FromRow, Row, pool::PoolConnection, query, sqlite::SqliteRow, FromRow, Row,
Sqlite, SqliteConnection, SqlitePool, Sqlite, SqliteConnection, SqlitePool,
}; };
use tracing::{debug, error}; use tracing::error;
use crate::{core::slide, Slide, SlideBuilder}; use crate::{core::slide, Slide, SlideBuilder};
use super::{ use super::{
content::Content, content::Content,
kinds::ServiceItemKind, kinds::ServiceItemKind,
model::{get_db, LibraryKind, Model}, model::{LibraryKind, Model},
service_items::ServiceTrait, service_items::ServiceTrait,
slide::{Background, TextAlignment}, slide::{Background, TextAlignment},
}; };
@ -132,10 +132,7 @@ impl FromRow<'_, SqliteRow> for Song {
}), }),
background: { background: {
let string: String = row.try_get(7)?; let string: String = row.try_get(7)?;
match Background::try_from(string) { Background::try_from(string).ok()
Ok(background) => Some(background),
Err(_) => None,
}
}, },
text_alignment: Some({ text_alignment: Some({
let horizontal_alignment: String = row.try_get(3)?; let horizontal_alignment: String = row.try_get(3)?;
@ -423,7 +420,7 @@ pub async fn update_song_in_db(
if let Some(vo) = item.verse_order { if let Some(vo) = item.verse_order {
vo.into_iter() vo.into_iter()
.map(|mut s| { .map(|mut s| {
s.push_str(" "); s.push(' ');
s s
}) })
.collect::<String>() .collect::<String>()
@ -538,7 +535,7 @@ impl Song {
lyric_list.push(lyric.to_string()); lyric_list.push(lyric.to_string());
} else { } else {
// error!("NOT WORKING!"); // error!("NOT WORKING!");
()
}; };
} }
// for lyric in lyric_list.iter() { // for lyric in lyric_list.iter() {
@ -556,7 +553,7 @@ mod test {
use std::fs::read_to_string; use std::fs::read_to_string;
use super::*; use super::*;
use pretty_assertions::{assert_eq, assert_ne}; use pretty_assertions::assert_eq;
#[test] #[test]
pub fn test_song_lyrics() { pub fn test_song_lyrics() {
@ -724,7 +721,7 @@ You saved my soul"
let lisp = read_to_string("./test_song.lisp").expect("oops"); let lisp = read_to_string("./test_song.lisp").expect("oops");
let lisp_value = crisp::reader::read(&lisp); let lisp_value = crisp::reader::read(&lisp);
match lisp_value { match lisp_value {
Value::List(v) => v.get(0).unwrap().clone(), Value::List(v) => v.first().unwrap().clone(),
_ => Value::Nil, _ => Value::Nil,
} }
} }

View file

@ -3,7 +3,7 @@ use crate::{Background, SlideBuilder, TextAlignment};
use super::{ use super::{
content::Content, content::Content,
kinds::ServiceItemKind, kinds::ServiceItemKind,
model::{get_db, LibraryKind, Model}, model::{LibraryKind, Model},
service_items::ServiceTrait, service_items::ServiceTrait,
slide::Slide, slide::Slide,
}; };
@ -50,13 +50,7 @@ impl Content for Video {
} }
fn background(&self) -> Option<Background> { fn background(&self) -> Option<Background> {
if let Ok(background) = Background::try_from(self.path.clone()).ok()
Background::try_from(self.path.clone())
{
Some(background)
} else {
None
}
} }
fn subtext(&self) -> String { fn subtext(&self) -> String {

View file

@ -39,7 +39,7 @@ pub fn parse_lisp(value: Value) -> Vec<ServiceItem> {
mod test { mod test {
use std::{ use std::{
fs::read_to_string, fs::read_to_string,
path::{Path, PathBuf}, path::PathBuf,
}; };
use crate::{ use crate::{
@ -47,7 +47,7 @@ mod test {
images::Image, kinds::ServiceItemKind, images::Image, kinds::ServiceItemKind,
service_items::ServiceTrait, songs::Song, videos::Video, service_items::ServiceTrait, songs::Song, videos::Video,
}, },
Background, Slide, SlideBuilder, TextAlignment, Background, TextAlignment,
}; };
use super::*; use super::*;

View file

@ -1,5 +1,4 @@
use clap::{command, Parser}; use clap::{command, Parser};
use core::model::{get_db, LibraryKind};
use core::service_items::{ServiceItem, ServiceItemModel}; use core::service_items::{ServiceItem, ServiceItemModel};
use core::slide::*; use core::slide::*;
use core::songs::Song; use core::songs::Song;
@ -16,11 +15,11 @@ use cosmic::widget::nav_bar::nav_bar_style;
use cosmic::widget::segmented_button::Entity; use cosmic::widget::segmented_button::Entity;
use cosmic::widget::tooltip::Position as TPosition; use cosmic::widget::tooltip::Position as TPosition;
use cosmic::widget::{ use cosmic::widget::{
button, horizontal_space, nav_bar, search_input, text_input, button, horizontal_space, nav_bar, search_input,
tooltip, Space, tooltip, Space,
}; };
use cosmic::widget::{icon, slider}; use cosmic::widget::{icon, slider};
use cosmic::widget::{text, toggler}; use cosmic::widget::text;
use cosmic::{executor, Application, ApplicationExt, Element}; use cosmic::{executor, Application, ApplicationExt, Element};
use cosmic::{prelude::*, theme}; use cosmic::{prelude::*, theme};
use cosmic::{widget::Container, Theme}; use cosmic::{widget::Container, Theme};
@ -332,7 +331,7 @@ impl cosmic::Application for App {
) )
.class(cosmic::theme::style::Button::HeaderBar) .class(cosmic::theme::style::Button::HeaderBar)
.on_press(Message::EditorToggle( .on_press(Message::EditorToggle(
!self.editor_mode.is_some(), self.editor_mode.is_none(),
)), )),
"Enter Edit Mode", "Enter Edit Mode",
TPosition::Bottom, TPosition::Bottom,
@ -721,7 +720,7 @@ impl cosmic::Application for App {
let library = if self.library_open { let library = if self.library_open {
Container::new(if let Some(library) = &self.library { Container::new(if let Some(library) = &self.library {
library.view().map(|m| Message::Library(m)) library.view().map(Message::Library)
} else { } else {
Space::new(0, 0).into() Space::new(0, 0).into()
}) })
@ -732,7 +731,7 @@ impl cosmic::Application for App {
}; };
let song_editor = let song_editor =
self.song_editor.view().map(|m| Message::SongEditor(m)); self.song_editor.view().map(Message::SongEditor);
let row = row![ let row = row![
Container::new( Container::new(
@ -880,8 +879,8 @@ where
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*;
use pretty_assertions::assert_eq;
fn test_slide() -> String { fn test_slide() -> String {
let slide = r#"(slide (image :source "./somehting.jpg" :fill cover let slide = r#"(slide (image :source "./somehting.jpg" :fill cover

View file

@ -8,13 +8,13 @@ use cosmic::{
widget::{ widget::{
button, container, horizontal_space, icon, mouse_area, button, container, horizontal_space, icon, mouse_area,
responsive, row, scrollable, text, text_input, Container, responsive, row, scrollable, text, text_input, Container,
DndSource, Icon, Space, Widget, DndSource, Space, Widget,
}, },
Element, Task, Element, Task,
}; };
use miette::{miette, IntoDiagnostic, Result}; use miette::{IntoDiagnostic, Result};
use sqlx::{ use sqlx::{
pool::PoolConnection, Sqlite, SqliteConnection, SqlitePool, pool::PoolConnection, Sqlite, SqlitePool,
}; };
use tracing::{debug, error, warn}; use tracing::{debug, error, warn};

View file

@ -1,4 +1,4 @@
use miette::{miette, IntoDiagnostic, Result}; use miette::{IntoDiagnostic, Result};
use std::{fs::File, io::BufReader, path::PathBuf, sync::Arc}; use std::{fs::File, io::BufReader, path::PathBuf, sync::Arc};
use cosmic::{ use cosmic::{
@ -13,7 +13,7 @@ use cosmic::{
scrollable::{ scrollable::{
scroll_to, AbsoluteOffset, Direction, Scrollbar, scroll_to, AbsoluteOffset, Direction, Scrollbar,
}, },
span, stack, text, span, stack,
}, },
prelude::*, prelude::*,
widget::{ widget::{
@ -32,9 +32,6 @@ use crate::{
BackgroundKind, BackgroundKind,
}; };
use super::text_svg::{
self, shadow, stroke, Font as SvgFont, TextSvg,
};
const REFERENCE_WIDTH: f32 = 1920.0; const REFERENCE_WIDTH: f32 = 1920.0;
const REFERENCE_HEIGHT: f32 = 1080.0; const REFERENCE_HEIGHT: f32 = 1080.0;
@ -528,21 +525,21 @@ async fn start_audio(sink: Arc<Sink>, audio: PathBuf) {
fn scale_font(font_size: f32, width: f32) -> f32 { fn scale_font(font_size: f32, width: f32) -> f32 {
let scale_factor = (REFERENCE_WIDTH / width).sqrt(); let scale_factor = (REFERENCE_WIDTH / width).sqrt();
// debug!(scale_factor); // debug!(scale_factor);
let font_size = if font_size > 0.0 {
if font_size > 0.0 {
font_size / scale_factor font_size / scale_factor
} else { } else {
50.0 50.0
}; }
font_size
} }
pub(crate) fn slide_view<'a>( pub(crate) fn slide_view(
slide: Slide, slide: Slide,
video: &'a Option<Video>, video: &Option<Video>,
font: Font, font: Font,
delegate: bool, delegate: bool,
hide_mouse: bool, hide_mouse: bool,
) -> Element<'a, Message> { ) -> Element<'_, Message> {
responsive(move |size| { responsive(move |size| {
let width = size.height * 16.0 / 9.0; let width = size.height * 16.0 / 9.0;
let font_size = scale_font(slide.font_size() as f32, width); let font_size = scale_font(slide.font_size() as f32, width);
@ -560,7 +557,7 @@ pub(crate) fn slide_view<'a>(
let lines = slide_text.lines(); let lines = slide_text.lines();
let text: Vec<Element<Message>> = lines let text: Vec<Element<Message>> = lines
.map(|t| { .map(|t| {
rich_text([span(format!("{}\n", t.to_string())) rich_text([span(format!("{}\n", t))
.background( .background(
Background::Color(Color::BLACK) Background::Color(Color::BLACK)
.scale_alpha(0.4), .scale_alpha(0.4),

View file

@ -167,7 +167,7 @@ impl SongEditor {
self.verse_order = verse_order self.verse_order = verse_order
.into_iter() .into_iter()
.map(|mut s| { .map(|mut s| {
s.push_str(" "); s.push(' ');
s s
}) })
.collect(); .collect();
@ -227,7 +227,6 @@ impl SongEditor {
if let Some(mut song) = self.song.clone() { if let Some(mut song) = self.song.clone() {
let verse_order = verse_order let verse_order = verse_order
.split(" ") .split(" ")
.into_iter()
.map(|s| s.to_owned()) .map(|s| s.to_owned())
.collect(); .collect();
song.verse_order = Some(verse_order); song.verse_order = Some(verse_order);

View file

@ -9,7 +9,7 @@ use cosmic::{
prelude::*, prelude::*,
widget::{container, responsive, svg::Handle, Svg}, widget::{container, responsive, svg::Handle, Svg},
}; };
use tracing::{debug, error}; use tracing::error;
use crate::TextAlignment; use crate::TextAlignment;
@ -61,11 +61,11 @@ impl Font {
} }
pub fn get_weight(&self) -> Weight { pub fn get_weight(&self) -> Weight {
self.weight.clone() self.weight
} }
pub fn get_style(&self) -> Style { pub fn get_style(&self) -> Style {
self.style.clone() self.style
} }
pub fn weight(mut self, weight: impl Into<Weight>) -> Self { pub fn weight(mut self, weight: impl Into<Weight>) -> Self {