clippy fix
This commit is contained in:
parent
f8e7eead5f
commit
0e949fae65
|
@ -2,7 +2,7 @@ use crate::{Background, Slide, SlideBuilder, TextAlignment};
|
||||||
|
|
||||||
use super::{model::Model, service_items::ServiceTrait};
|
use super::{model::Model, service_items::ServiceTrait};
|
||||||
use crisp::types::{Keyword, Value};
|
use crisp::types::{Keyword, Value};
|
||||||
use miette::{miette, IntoDiagnostic, Result};
|
use miette::{IntoDiagnostic, Result};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{query_as, SqliteConnection};
|
use sqlx::{query_as, SqliteConnection};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -114,7 +114,7 @@ pub async fn get_image_from_db(
|
||||||
database_id: i32,
|
database_id: i32,
|
||||||
db: &mut SqliteConnection,
|
db: &mut SqliteConnection,
|
||||||
) -> Result<Image> {
|
) -> Result<Image> {
|
||||||
Ok(query_as!(Image, r#"SELECT title as "title!", file_path as "path!", id as "id: i32" from images where id = ?"#, database_id).fetch_one(db).await.into_diagnostic()?)
|
query_as!(Image, r#"SELECT title as "title!", file_path as "path!", id as "id: i32" from images where id = ?"#, database_id).fetch_one(db).await.into_diagnostic()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::Slide;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
images::Image,
|
images::Image,
|
||||||
presentations::{PresKind, Presentation},
|
presentations::Presentation,
|
||||||
songs::Song,
|
songs::Song,
|
||||||
videos::Video,
|
videos::Video,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
|
|
||||||
use cosmic::{executor, iced::Executor, Task};
|
use cosmic::iced::Executor;
|
||||||
use miette::{miette, IntoDiagnostic, Result};
|
use miette::{miette, Result};
|
||||||
use sqlx::{Connection, SqliteConnection};
|
use sqlx::{Connection, SqliteConnection};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crisp::types::{Keyword, Value};
|
use crisp::types::{Keyword, Value};
|
||||||
use miette::{miette, IntoDiagnostic, Result};
|
use miette::{IntoDiagnostic, Result};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{
|
use sqlx::{
|
||||||
prelude::FromRow, query, sqlite::SqliteRow, Row, SqliteConnection,
|
prelude::FromRow, query, sqlite::SqliteRow, Row, SqliteConnection,
|
||||||
|
@ -164,7 +164,7 @@ pub async fn get_presentation_from_db(
|
||||||
db: &mut SqliteConnection,
|
db: &mut SqliteConnection,
|
||||||
) -> Result<Presentation> {
|
) -> Result<Presentation> {
|
||||||
let row = query(r#"SELECT id as "id: i32", title, file_path as "path", html from presentations where id = $1"#).bind(database_id).fetch_one(db).await.into_diagnostic()?;
|
let row = query(r#"SELECT id as "id: i32", title, file_path as "path", html from presentations where id = $1"#).bind(database_id).fetch_one(db).await.into_diagnostic()?;
|
||||||
Ok(Presentation::from_row(&row).into_diagnostic()?)
|
Presentation::from_row(&row).into_diagnostic()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
use crisp::types::{Keyword, Symbol, Value};
|
use crisp::types::{Keyword, Symbol, Value};
|
||||||
use miette::{miette, IntoDiagnostic, Result};
|
use miette::{miette, Result};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
str::FromStr,
|
|
||||||
};
|
};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
|
@ -381,7 +379,7 @@ pub fn lisp_to_background(lisp: &Value) -> Background {
|
||||||
panic!("Should always be there");
|
panic!("Should always be there");
|
||||||
};
|
};
|
||||||
let mut home = home.to_string();
|
let mut home = home.to_string();
|
||||||
home.push_str("/");
|
home.push('/');
|
||||||
|
|
||||||
let s = s.replace("./", &home);
|
let s = s.replace("./", &home);
|
||||||
match Background::try_from(s.as_str()) {
|
match Background::try_from(s.as_str()) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use std::{collections::HashMap, fmt::Display, path::PathBuf};
|
use std::{collections::HashMap, path::PathBuf};
|
||||||
|
|
||||||
use cosmic::{executor, iced::Executor};
|
use cosmic::iced::Executor;
|
||||||
use crisp::types::{Keyword, Symbol, Value};
|
use crisp::types::{Keyword, Symbol, Value};
|
||||||
use miette::{miette, IntoDiagnostic, Result};
|
use miette::{miette, IntoDiagnostic, Result};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{
|
use sqlx::{
|
||||||
query, query_as, sqlite::SqliteRow, FromRow, Row,
|
query, sqlite::SqliteRow, FromRow, Row,
|
||||||
SqliteConnection,
|
SqliteConnection,
|
||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::{debug, error};
|
||||||
|
@ -154,7 +154,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||||
.position(|v| v == &Value::Keyword(Keyword::from("id")))
|
.position(|v| v == &Value::Keyword(Keyword::from("id")))
|
||||||
{
|
{
|
||||||
let pos = key_pos + 1;
|
let pos = key_pos + 1;
|
||||||
list.get(pos).map(|c| i32::from(c)).unwrap_or_default()
|
list.get(pos).map(i32::from).unwrap_or_default()
|
||||||
} else {
|
} else {
|
||||||
DEFAULT_SONG_ID
|
DEFAULT_SONG_ID
|
||||||
};
|
};
|
||||||
|
@ -164,7 +164,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||||
v == &Value::Keyword(Keyword::from("background"))
|
v == &Value::Keyword(Keyword::from("background"))
|
||||||
}) {
|
}) {
|
||||||
let pos = key_pos + 1;
|
let pos = key_pos + 1;
|
||||||
list.get(pos).map(|b| slide::lisp_to_background(b))
|
list.get(pos).map(slide::lisp_to_background)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -174,7 +174,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||||
.position(|v| v == &Value::Keyword(Keyword::from("author")))
|
.position(|v| v == &Value::Keyword(Keyword::from("author")))
|
||||||
{
|
{
|
||||||
let pos = key_pos + 1;
|
let pos = key_pos + 1;
|
||||||
list.get(pos).map(|a| String::from(a))
|
list.get(pos).map(String::from)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -204,7 +204,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||||
.position(|v| v == &Value::Keyword(Keyword::from("font")))
|
.position(|v| v == &Value::Keyword(Keyword::from("font")))
|
||||||
{
|
{
|
||||||
let pos = key_pos + 1;
|
let pos = key_pos + 1;
|
||||||
list.get(pos).map(|f| String::from(f))
|
list.get(pos).map(String::from)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -213,7 +213,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||||
v == &Value::Keyword(Keyword::from("font-size"))
|
v == &Value::Keyword(Keyword::from("font-size"))
|
||||||
}) {
|
}) {
|
||||||
let pos = key_pos + 1;
|
let pos = key_pos + 1;
|
||||||
list.get(pos).map(|f| i32::from(f))
|
list.get(pos).map(i32::from)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -224,7 +224,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||||
{
|
{
|
||||||
let pos = key_pos + 1;
|
let pos = key_pos + 1;
|
||||||
list.get(pos)
|
list.get(pos)
|
||||||
.map(|t| String::from(t))
|
.map(String::from)
|
||||||
.unwrap_or(String::from("song"))
|
.unwrap_or(String::from("song"))
|
||||||
} else {
|
} else {
|
||||||
String::from("song")
|
String::from("song")
|
||||||
|
@ -235,7 +235,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||||
v == &Value::Keyword(Keyword::from("text-alignment"))
|
v == &Value::Keyword(Keyword::from("text-alignment"))
|
||||||
}) {
|
}) {
|
||||||
let pos = key_pos + 1;
|
let pos = key_pos + 1;
|
||||||
list.get(pos).map(|t| TextAlignment::from(t))
|
list.get(pos).map(TextAlignment::from)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -247,7 +247,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||||
let pos = key_pos + 1;
|
let pos = key_pos + 1;
|
||||||
list.get(pos).map(|v| match v {
|
list.get(pos).map(|v| match v {
|
||||||
Value::List(vals) => vals
|
Value::List(vals) => vals
|
||||||
.into_iter()
|
.iter()
|
||||||
.map(|v| String::from(v).to_uppercase())
|
.map(|v| String::from(v).to_uppercase())
|
||||||
.collect::<Vec<String>>(),
|
.collect::<Vec<String>>(),
|
||||||
_ => vec![],
|
_ => vec![],
|
||||||
|
@ -256,8 +256,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let first_text_postiion = if let Some(pos) =
|
let first_text_postiion = list.iter().position(|v| match v {
|
||||||
list.iter().position(|v| match v {
|
|
||||||
Value::List(inner) => {
|
Value::List(inner) => {
|
||||||
(match &inner[0] {
|
(match &inner[0] {
|
||||||
Value::Symbol(Symbol(text)) => {
|
Value::Symbol(Symbol(text)) => {
|
||||||
|
@ -273,11 +272,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}) {
|
}).unwrap_or(1);
|
||||||
pos
|
|
||||||
} else {
|
|
||||||
1
|
|
||||||
};
|
|
||||||
|
|
||||||
let lyric_elements = &list[first_text_postiion..];
|
let lyric_elements = &list[first_text_postiion..];
|
||||||
|
|
||||||
|
@ -347,7 +342,7 @@ pub async fn get_song_from_db(
|
||||||
db: &mut SqliteConnection,
|
db: &mut SqliteConnection,
|
||||||
) -> Result<Song> {
|
) -> Result<Song> {
|
||||||
let row = query(r#"SELECT verse_order as "verse_order!", font_size as "font_size!: i32", background_type as "background_type!", horizontal_text_alignment as "horizontal_text_alignment!", vertical_text_alignment as "vertical_text_alignment!", title as "title!", font as "font!", background as "background!", lyrics as "lyrics!", ccli as "ccli!", author as "author!", audio as "audio!", id as "id: i32" from songs where id = $1"#).bind(index).fetch_one(db).await.into_diagnostic()?;
|
let row = query(r#"SELECT verse_order as "verse_order!", font_size as "font_size!: i32", background_type as "background_type!", horizontal_text_alignment as "horizontal_text_alignment!", vertical_text_alignment as "vertical_text_alignment!", title as "title!", font as "font!", background as "background!", lyrics as "lyrics!", ccli as "ccli!", author as "author!", audio as "audio!", id as "id: i32" from songs where id = $1"#).bind(index).fetch_one(db).await.into_diagnostic()?;
|
||||||
Ok(Song::from_row(&row).into_diagnostic()?)
|
Song::from_row(&row).into_diagnostic()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Model<Song> {
|
impl Model<Song> {
|
||||||
|
|
|
@ -3,9 +3,9 @@ use crate::{Background, SlideBuilder, TextAlignment};
|
||||||
use super::{
|
use super::{
|
||||||
model::Model, service_items::ServiceTrait, slide::Slide,
|
model::Model, service_items::ServiceTrait, slide::Slide,
|
||||||
};
|
};
|
||||||
use cosmic::{executor, iced::Executor};
|
use cosmic::iced::Executor;
|
||||||
use crisp::types::{Keyword, Value};
|
use crisp::types::{Keyword, Value};
|
||||||
use miette::{miette, IntoDiagnostic, Result};
|
use miette::{IntoDiagnostic, Result};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{query_as, SqliteConnection};
|
use sqlx::{query_as, SqliteConnection};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -83,7 +83,7 @@ impl From<&Value> for Video {
|
||||||
let pos = loop_pos + 1;
|
let pos = loop_pos + 1;
|
||||||
list.get(pos)
|
list.get(pos)
|
||||||
.map(|l| {
|
.map(|l| {
|
||||||
String::from(l) == "true".to_string()
|
String::from(l) == *"true"
|
||||||
})
|
})
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
} else {
|
} else {
|
||||||
|
@ -157,7 +157,7 @@ pub async fn get_video_from_db(
|
||||||
database_id: i32,
|
database_id: i32,
|
||||||
db: &mut SqliteConnection,
|
db: &mut SqliteConnection,
|
||||||
) -> Result<Video> {
|
) -> Result<Video> {
|
||||||
Ok(query_as!(Video, r#"SELECT title as "title!", file_path as "path!", start_time as "start_time!: f32", end_time as "end_time!: f32", loop as "looping!", id as "id: i32" from videos where id = ?"#, database_id).fetch_one(db).await.into_diagnostic()?)
|
query_as!(Video, r#"SELECT title as "title!", file_path as "path!", start_time as "start_time!: f32", end_time as "end_time!: f32", loop as "looping!", id as "id: i32" from videos where id = ?"#, database_id).fetch_one(db).await.into_diagnostic()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
use std::{fs::read_to_string, path::PathBuf};
|
use std::{fs::read_to_string, path::PathBuf};
|
||||||
|
|
||||||
use crisp::types::{Symbol, Value};
|
use crisp::types::{Symbol, Value};
|
||||||
use tracing::error;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::core::service_items::ServiceItem;
|
||||||
core::{service_items::ServiceItem, songs::lisp_to_song},
|
|
||||||
Slide,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn parse_lisp(value: Value) -> Vec<ServiceItem> {
|
pub fn parse_lisp(value: Value) -> Vec<ServiceItem> {
|
||||||
match &value {
|
match &value {
|
||||||
|
@ -28,7 +24,7 @@ pub fn parse_lisp(value: Value) -> Vec<ServiceItem> {
|
||||||
match lisp_value {
|
match lisp_value {
|
||||||
Value::List(value) => value
|
Value::List(value) => value
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|v| parse_lisp(v))
|
.flat_map(parse_lisp)
|
||||||
.collect(),
|
.collect(),
|
||||||
_ => panic!("Should not be"),
|
_ => panic!("Should not be"),
|
||||||
}
|
}
|
||||||
|
|
43
src/main.rs
43
src/main.rs
|
@ -5,18 +5,17 @@ use cosmic::app::{Core, Settings, Task};
|
||||||
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, event, window, Font, Length, Padding, Point,
|
self, event, window, Length, Padding, Point,
|
||||||
};
|
};
|
||||||
use cosmic::iced_core::SmolStr;
|
use cosmic::iced_core::SmolStr;
|
||||||
use cosmic::iced_futures::Subscription;
|
use cosmic::iced_futures::Subscription;
|
||||||
use cosmic::iced_widget::{column, row, stack};
|
use cosmic::iced_widget::{column, row};
|
||||||
use cosmic::prelude::ElementExt;
|
use cosmic::prelude::ElementExt;
|
||||||
use cosmic::prelude::*;
|
use cosmic::prelude::*;
|
||||||
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::{
|
use cosmic::widget::{
|
||||||
button, context_drawer, image, nav_bar, text, tooltip, MouseArea,
|
button, nav_bar, text, tooltip, Space,
|
||||||
Responsive, Space,
|
|
||||||
};
|
};
|
||||||
use cosmic::widget::{icon, slider};
|
use cosmic::widget::{icon, slider};
|
||||||
use cosmic::{executor, Application, ApplicationExt, Element};
|
use cosmic::{executor, Application, ApplicationExt, Element};
|
||||||
|
@ -75,8 +74,8 @@ fn main() -> Result<()> {
|
||||||
Settings::default().debug(false).no_main_window(true);
|
Settings::default().debug(false).no_main_window(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(cosmic::app::run::<App>(settings, args)
|
cosmic::app::run::<App>(settings, args)
|
||||||
.map_err(|e| miette!("Invalid things... {}", e))?)
|
.map_err(|e| miette!("Invalid things... {}", e))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn theme(_state: &App) -> Theme {
|
fn theme(_state: &App) -> Theme {
|
||||||
|
@ -159,11 +158,7 @@ impl cosmic::Application for App {
|
||||||
|
|
||||||
let items = ServiceItemModel::from(items);
|
let items = ServiceItemModel::from(items);
|
||||||
let presenter = Presenter::with_items(items.clone());
|
let presenter = Presenter::with_items(items.clone());
|
||||||
let slides = if let Ok(slides) = items.to_slides() {
|
let slides = items.to_slides().unwrap_or_default();
|
||||||
slides
|
|
||||||
} else {
|
|
||||||
vec![]
|
|
||||||
};
|
|
||||||
let current_slide = slides[0].clone();
|
let current_slide = slides[0].clone();
|
||||||
|
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
|
@ -239,7 +234,7 @@ impl cosmic::Application for App {
|
||||||
.spacing(10);
|
.spacing(10);
|
||||||
let padding = Padding::new(0.0).top(20);
|
let padding = Padding::new(0.0).top(20);
|
||||||
let container = Container::new(column)
|
let container = Container::new(column)
|
||||||
.style(|t| nav_bar_style(t))
|
.style(nav_bar_style)
|
||||||
.padding(padding);
|
.padding(padding);
|
||||||
Some(container.into())
|
Some(container.into())
|
||||||
}
|
}
|
||||||
|
@ -288,7 +283,7 @@ impl cosmic::Application for App {
|
||||||
.on_press({
|
.on_press({
|
||||||
if self.presentation_open {
|
if self.presentation_open {
|
||||||
Message::CloseWindow(
|
Message::CloseWindow(
|
||||||
presenter_window.map(|id| *id),
|
presenter_window.copied(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Message::OpenWindow
|
Message::OpenWindow
|
||||||
|
@ -351,14 +346,14 @@ impl cosmic::Application for App {
|
||||||
) -> Option<
|
) -> Option<
|
||||||
cosmic::app::context_drawer::ContextDrawer<Self::Message>,
|
cosmic::app::context_drawer::ContextDrawer<Self::Message>,
|
||||||
> {
|
> {
|
||||||
Some(ContextDrawer {
|
ContextDrawer {
|
||||||
title: Some("Context".into()),
|
title: Some("Context".into()),
|
||||||
header_actions: vec![],
|
header_actions: vec![],
|
||||||
header: Some("hi".into()),
|
header: Some("hi".into()),
|
||||||
content: "Sup".into(),
|
content: "Sup".into(),
|
||||||
footer: Some("foot".into()),
|
footer: Some("foot".into()),
|
||||||
on_close: Message::None,
|
on_close: Message::None,
|
||||||
});
|
};
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,23 +385,23 @@ impl cosmic::Application for App {
|
||||||
presenter::Message::NextSlide,
|
presenter::Message::NextSlide,
|
||||||
)),
|
)),
|
||||||
(Key::Character(k), _)
|
(Key::Character(k), _)
|
||||||
if k == SmolStr::from("j")
|
if k == *"j"
|
||||||
|| k == SmolStr::from("l") =>
|
|| k == *"l" =>
|
||||||
{
|
{
|
||||||
self.update(Message::Present(
|
self.update(Message::Present(
|
||||||
presenter::Message::NextSlide,
|
presenter::Message::NextSlide,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
(Key::Character(k), _)
|
(Key::Character(k), _)
|
||||||
if k == SmolStr::from("k")
|
if k == *"k"
|
||||||
|| k == SmolStr::from("h") =>
|
|| k == *"h" =>
|
||||||
{
|
{
|
||||||
self.update(Message::Present(
|
self.update(Message::Present(
|
||||||
presenter::Message::PrevSlide,
|
presenter::Message::PrevSlide,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
(Key::Character(k), _)
|
(Key::Character(k), _)
|
||||||
if k == SmolStr::from("q") =>
|
if k == *"q" =>
|
||||||
{
|
{
|
||||||
self.update(Message::Quit)
|
self.update(Message::Quit)
|
||||||
}
|
}
|
||||||
|
@ -484,7 +479,7 @@ impl cosmic::Application for App {
|
||||||
};
|
};
|
||||||
self.windows.remove(window);
|
self.windows.remove(window);
|
||||||
// This closes the app if using the cli example
|
// This closes the app if using the cli example
|
||||||
if self.windows.len() == 0 {
|
if self.windows.is_empty() {
|
||||||
self.update(Message::Quit)
|
self.update(Message::Quit)
|
||||||
} else {
|
} else {
|
||||||
self.presentation_open = false;
|
self.presentation_open = false;
|
||||||
|
@ -542,7 +537,7 @@ impl cosmic::Application for App {
|
||||||
Container::new(
|
Container::new(
|
||||||
self.presenter
|
self.presenter
|
||||||
.view_preview()
|
.view_preview()
|
||||||
.map(|m| Message::Present(m)),
|
.map(Message::Present),
|
||||||
)
|
)
|
||||||
.align_bottom(Length::Fill),
|
.align_bottom(Length::Fill),
|
||||||
Container::new(if self.presenter.video.is_some() {
|
Container::new(if self.presenter.video.is_some() {
|
||||||
|
@ -618,7 +613,7 @@ impl cosmic::Application for App {
|
||||||
Container::new(
|
Container::new(
|
||||||
self.presenter
|
self.presenter
|
||||||
.preview_bar()
|
.preview_bar()
|
||||||
.map(|m| Message::Present(m))
|
.map(Message::Present)
|
||||||
)
|
)
|
||||||
.clip(true)
|
.clip(true)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
|
@ -632,7 +627,7 @@ impl cosmic::Application for App {
|
||||||
// View for presentation
|
// View for presentation
|
||||||
fn view_window(&self, _id: window::Id) -> Element<Message> {
|
fn view_window(&self, _id: window::Id) -> Element<Message> {
|
||||||
debug!("window");
|
debug!("window");
|
||||||
self.presenter.view().map(|m| Message::Present(m))
|
self.presenter.view().map(Message::Present)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ use cosmic::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
widget::{
|
widget::{
|
||||||
container, image, mouse_area, responsive, scrollable, text,
|
container, image, mouse_area, responsive, scrollable, text,
|
||||||
Column, Container, Id, Responsive, Row, Space, Text,
|
Column, Container, Id, Responsive, Row, Space,
|
||||||
},
|
},
|
||||||
Task,
|
Task,
|
||||||
};
|
};
|
||||||
|
@ -63,18 +63,14 @@ pub(crate) enum Message {
|
||||||
|
|
||||||
impl Presenter {
|
impl Presenter {
|
||||||
pub fn with_items(items: ServiceItemModel) -> Self {
|
pub fn with_items(items: ServiceItemModel) -> Self {
|
||||||
let slides = if let Ok(slides) = items.to_slides() {
|
let slides = items.to_slides().unwrap_or_default();
|
||||||
slides
|
|
||||||
} else {
|
|
||||||
vec![]
|
|
||||||
};
|
|
||||||
Self {
|
Self {
|
||||||
slides: slides.clone(),
|
slides: slides.clone(),
|
||||||
items: items.into(),
|
items: items,
|
||||||
current_slide: slides[0].clone(),
|
current_slide: slides[0].clone(),
|
||||||
current_slide_index: 0,
|
current_slide_index: 0,
|
||||||
video: {
|
video: {
|
||||||
if let Some(slide) = slides.get(0) {
|
if let Some(slide) = slides.first() {
|
||||||
let path = slide.background().path.clone();
|
let path = slide.background().path.clone();
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
let url = Url::from_file_path(path).unwrap();
|
let url = Url::from_file_path(path).unwrap();
|
||||||
|
|
Loading…
Reference in a new issue