cargo fix
This commit is contained in:
parent
e6621072cd
commit
8cf2d48a16
|
@ -3,7 +3,7 @@ use crate::{Background, Slide, SlideBuilder, TextAlignment};
|
|||
use super::{
|
||||
content::Content,
|
||||
kinds::ServiceItemKind,
|
||||
model::{get_db, LibraryKind, Model},
|
||||
model::{LibraryKind, Model},
|
||||
service_items::ServiceTrait,
|
||||
};
|
||||
use crisp::types::{Keyword, Symbol, Value};
|
||||
|
@ -45,13 +45,7 @@ impl Content for Image {
|
|||
}
|
||||
|
||||
fn background(&self) -> Option<Background> {
|
||||
if let Ok(background) =
|
||||
Background::try_from(self.path.clone())
|
||||
{
|
||||
Some(background)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
Background::try_from(self.path.clone()).ok()
|
||||
}
|
||||
|
||||
fn subtext(&self) -> String {
|
||||
|
|
|
@ -133,12 +133,12 @@ pub(crate) fn get_lists(exp: &Value) -> Vec<Value> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::fs::read_to_string;
|
||||
|
||||
use lexpr::{parse::Options, Parser};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// #[test]
|
||||
// fn test_list() {
|
||||
|
|
|
@ -4,7 +4,6 @@ use cosmic::iced::Executor;
|
|||
use miette::{miette, Result};
|
||||
use sqlx::{Connection, SqliteConnection};
|
||||
|
||||
use super::kinds::ServiceItemKind;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Model<T> {
|
||||
|
|
|
@ -13,7 +13,7 @@ use crate::{Background, Slide, SlideBuilder, TextAlignment};
|
|||
use super::{
|
||||
content::Content,
|
||||
kinds::ServiceItemKind,
|
||||
model::{get_db, LibraryKind, Model},
|
||||
model::{LibraryKind, Model},
|
||||
service_items::ServiceTrait,
|
||||
};
|
||||
|
||||
|
@ -57,13 +57,7 @@ impl Content for Presentation {
|
|||
}
|
||||
|
||||
fn background(&self) -> Option<Background> {
|
||||
if let Ok(background) =
|
||||
Background::try_from(self.path.clone())
|
||||
{
|
||||
Some(background)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
Background::try_from(self.path.clone()).ok()
|
||||
}
|
||||
|
||||
fn subtext(&self) -> String {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::ops::Deref;
|
|||
|
||||
use cosmic::iced::clipboard::mime::{AllowedMimeTypes, AsMimeTypes};
|
||||
use crisp::types::{Keyword, Symbol, Value};
|
||||
use miette::{miette, Result};
|
||||
use miette::Result;
|
||||
use tracing::{debug, error};
|
||||
|
||||
use crate::Slide;
|
||||
|
@ -153,52 +153,50 @@ impl From<&Value> for ServiceItem {
|
|||
database_id: 0,
|
||||
kind: ServiceItemKind::Content(slide),
|
||||
}
|
||||
} else {
|
||||
if let Some(background) =
|
||||
list.get(background_pos)
|
||||
{
|
||||
match background {
|
||||
Value::List(item) => match &item[0] {
|
||||
Value::Symbol(Symbol(s))
|
||||
if s == "image" =>
|
||||
{
|
||||
Self::from(&Image::from(
|
||||
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()
|
||||
} else if let Some(background) =
|
||||
list.get(background_pos)
|
||||
{
|
||||
match background {
|
||||
Value::List(item) => match &item[0] {
|
||||
Value::Symbol(Symbol(s))
|
||||
if s == "image" =>
|
||||
{
|
||||
Self::from(&Image::from(
|
||||
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()
|
||||
}
|
||||
} 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" => {
|
||||
|
@ -342,7 +340,7 @@ mod test {
|
|||
use crate::core::presentations::PresKind;
|
||||
|
||||
use super::*;
|
||||
use pretty_assertions::{assert_eq, assert_ne};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
fn test_song() -> Song {
|
||||
Song {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// use cosmic::dialog::ashpd::url::Url;
|
||||
use crisp::types::{Keyword, Symbol, Value};
|
||||
use gstreamer::query::Uri;
|
||||
use iced_video_player::Video;
|
||||
use miette::{miette, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
|
@ -8,14 +8,14 @@ use sqlx::{
|
|||
pool::PoolConnection, query, sqlite::SqliteRow, FromRow, Row,
|
||||
Sqlite, SqliteConnection, SqlitePool,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
use crate::{core::slide, Slide, SlideBuilder};
|
||||
|
||||
use super::{
|
||||
content::Content,
|
||||
kinds::ServiceItemKind,
|
||||
model::{get_db, LibraryKind, Model},
|
||||
model::{LibraryKind, Model},
|
||||
service_items::ServiceTrait,
|
||||
slide::{Background, TextAlignment},
|
||||
};
|
||||
|
@ -132,10 +132,7 @@ impl FromRow<'_, SqliteRow> for Song {
|
|||
}),
|
||||
background: {
|
||||
let string: String = row.try_get(7)?;
|
||||
match Background::try_from(string) {
|
||||
Ok(background) => Some(background),
|
||||
Err(_) => None,
|
||||
}
|
||||
Background::try_from(string).ok()
|
||||
},
|
||||
text_alignment: Some({
|
||||
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 {
|
||||
vo.into_iter()
|
||||
.map(|mut s| {
|
||||
s.push_str(" ");
|
||||
s.push(' ');
|
||||
s
|
||||
})
|
||||
.collect::<String>()
|
||||
|
@ -538,7 +535,7 @@ impl Song {
|
|||
lyric_list.push(lyric.to_string());
|
||||
} else {
|
||||
// error!("NOT WORKING!");
|
||||
()
|
||||
|
||||
};
|
||||
}
|
||||
// for lyric in lyric_list.iter() {
|
||||
|
@ -556,7 +553,7 @@ mod test {
|
|||
use std::fs::read_to_string;
|
||||
|
||||
use super::*;
|
||||
use pretty_assertions::{assert_eq, assert_ne};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
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_value = crisp::reader::read(&lisp);
|
||||
match lisp_value {
|
||||
Value::List(v) => v.get(0).unwrap().clone(),
|
||||
Value::List(v) => v.first().unwrap().clone(),
|
||||
_ => Value::Nil,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{Background, SlideBuilder, TextAlignment};
|
|||
use super::{
|
||||
content::Content,
|
||||
kinds::ServiceItemKind,
|
||||
model::{get_db, LibraryKind, Model},
|
||||
model::{LibraryKind, Model},
|
||||
service_items::ServiceTrait,
|
||||
slide::Slide,
|
||||
};
|
||||
|
@ -50,13 +50,7 @@ impl Content for Video {
|
|||
}
|
||||
|
||||
fn background(&self) -> Option<Background> {
|
||||
if let Ok(background) =
|
||||
Background::try_from(self.path.clone())
|
||||
{
|
||||
Some(background)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
Background::try_from(self.path.clone()).ok()
|
||||
}
|
||||
|
||||
fn subtext(&self) -> String {
|
||||
|
|
|
@ -39,7 +39,7 @@ pub fn parse_lisp(value: Value) -> Vec<ServiceItem> {
|
|||
mod test {
|
||||
use std::{
|
||||
fs::read_to_string,
|
||||
path::{Path, PathBuf},
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
@ -47,7 +47,7 @@ mod test {
|
|||
images::Image, kinds::ServiceItemKind,
|
||||
service_items::ServiceTrait, songs::Song, videos::Video,
|
||||
},
|
||||
Background, Slide, SlideBuilder, TextAlignment,
|
||||
Background, TextAlignment,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -1,5 +1,4 @@
|
|||
use clap::{command, Parser};
|
||||
use core::model::{get_db, LibraryKind};
|
||||
use core::service_items::{ServiceItem, ServiceItemModel};
|
||||
use core::slide::*;
|
||||
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::tooltip::Position as TPosition;
|
||||
use cosmic::widget::{
|
||||
button, horizontal_space, nav_bar, search_input, text_input,
|
||||
button, horizontal_space, nav_bar, search_input,
|
||||
tooltip, Space,
|
||||
};
|
||||
use cosmic::widget::{icon, slider};
|
||||
use cosmic::widget::{text, toggler};
|
||||
use cosmic::widget::text;
|
||||
use cosmic::{executor, Application, ApplicationExt, Element};
|
||||
use cosmic::{prelude::*, theme};
|
||||
use cosmic::{widget::Container, Theme};
|
||||
|
@ -332,7 +331,7 @@ impl cosmic::Application for App {
|
|||
)
|
||||
.class(cosmic::theme::style::Button::HeaderBar)
|
||||
.on_press(Message::EditorToggle(
|
||||
!self.editor_mode.is_some(),
|
||||
self.editor_mode.is_none(),
|
||||
)),
|
||||
"Enter Edit Mode",
|
||||
TPosition::Bottom,
|
||||
|
@ -721,7 +720,7 @@ impl cosmic::Application for App {
|
|||
|
||||
let library = if self.library_open {
|
||||
Container::new(if let Some(library) = &self.library {
|
||||
library.view().map(|m| Message::Library(m))
|
||||
library.view().map(Message::Library)
|
||||
} else {
|
||||
Space::new(0, 0).into()
|
||||
})
|
||||
|
@ -732,7 +731,7 @@ impl cosmic::Application for App {
|
|||
};
|
||||
|
||||
let song_editor =
|
||||
self.song_editor.view().map(|m| Message::SongEditor(m));
|
||||
self.song_editor.view().map(Message::SongEditor);
|
||||
|
||||
let row = row![
|
||||
Container::new(
|
||||
|
@ -880,8 +879,8 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
|
||||
|
||||
fn test_slide() -> String {
|
||||
let slide = r#"(slide (image :source "./somehting.jpg" :fill cover
|
||||
|
|
|
@ -8,13 +8,13 @@ use cosmic::{
|
|||
widget::{
|
||||
button, container, horizontal_space, icon, mouse_area,
|
||||
responsive, row, scrollable, text, text_input, Container,
|
||||
DndSource, Icon, Space, Widget,
|
||||
DndSource, Space, Widget,
|
||||
},
|
||||
Element, Task,
|
||||
};
|
||||
use miette::{miette, IntoDiagnostic, Result};
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use sqlx::{
|
||||
pool::PoolConnection, Sqlite, SqliteConnection, SqlitePool,
|
||||
pool::PoolConnection, Sqlite, SqlitePool,
|
||||
};
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use miette::{miette, IntoDiagnostic, Result};
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use std::{fs::File, io::BufReader, path::PathBuf, sync::Arc};
|
||||
|
||||
use cosmic::{
|
||||
|
@ -13,7 +13,7 @@ use cosmic::{
|
|||
scrollable::{
|
||||
scroll_to, AbsoluteOffset, Direction, Scrollbar,
|
||||
},
|
||||
span, stack, text,
|
||||
span, stack,
|
||||
},
|
||||
prelude::*,
|
||||
widget::{
|
||||
|
@ -32,9 +32,6 @@ use crate::{
|
|||
BackgroundKind,
|
||||
};
|
||||
|
||||
use super::text_svg::{
|
||||
self, shadow, stroke, Font as SvgFont, TextSvg,
|
||||
};
|
||||
|
||||
const REFERENCE_WIDTH: f32 = 1920.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 {
|
||||
let scale_factor = (REFERENCE_WIDTH / width).sqrt();
|
||||
// debug!(scale_factor);
|
||||
let font_size = if font_size > 0.0 {
|
||||
|
||||
if font_size > 0.0 {
|
||||
font_size / scale_factor
|
||||
} else {
|
||||
50.0
|
||||
};
|
||||
font_size
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn slide_view<'a>(
|
||||
pub(crate) fn slide_view(
|
||||
slide: Slide,
|
||||
video: &'a Option<Video>,
|
||||
video: &Option<Video>,
|
||||
font: Font,
|
||||
delegate: bool,
|
||||
hide_mouse: bool,
|
||||
) -> Element<'a, Message> {
|
||||
) -> Element<'_, Message> {
|
||||
responsive(move |size| {
|
||||
let width = size.height * 16.0 / 9.0;
|
||||
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 text: Vec<Element<Message>> = lines
|
||||
.map(|t| {
|
||||
rich_text([span(format!("{}\n", t.to_string()))
|
||||
rich_text([span(format!("{}\n", t))
|
||||
.background(
|
||||
Background::Color(Color::BLACK)
|
||||
.scale_alpha(0.4),
|
||||
|
|
|
@ -167,7 +167,7 @@ impl SongEditor {
|
|||
self.verse_order = verse_order
|
||||
.into_iter()
|
||||
.map(|mut s| {
|
||||
s.push_str(" ");
|
||||
s.push(' ');
|
||||
s
|
||||
})
|
||||
.collect();
|
||||
|
@ -227,7 +227,6 @@ impl SongEditor {
|
|||
if let Some(mut song) = self.song.clone() {
|
||||
let verse_order = verse_order
|
||||
.split(" ")
|
||||
.into_iter()
|
||||
.map(|s| s.to_owned())
|
||||
.collect();
|
||||
song.verse_order = Some(verse_order);
|
||||
|
|
|
@ -9,7 +9,7 @@ use cosmic::{
|
|||
prelude::*,
|
||||
widget::{container, responsive, svg::Handle, Svg},
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
use crate::TextAlignment;
|
||||
|
||||
|
@ -61,11 +61,11 @@ impl Font {
|
|||
}
|
||||
|
||||
pub fn get_weight(&self) -> Weight {
|
||||
self.weight.clone()
|
||||
self.weight
|
||||
}
|
||||
|
||||
pub fn get_style(&self) -> Style {
|
||||
self.style.clone()
|
||||
self.style
|
||||
}
|
||||
|
||||
pub fn weight(mut self, weight: impl Into<Weight>) -> Self {
|
||||
|
|
Loading…
Reference in a new issue