This commit is contained in:
parent
29c4f9de92
commit
32c49a59a9
14 changed files with 78 additions and 87 deletions
|
|
@ -1,4 +1,3 @@
|
|||
pub mod song_search;
|
||||
pub mod content;
|
||||
pub mod file;
|
||||
pub mod images;
|
||||
|
|
@ -9,6 +8,7 @@ pub mod service_items;
|
|||
pub mod settings;
|
||||
pub mod slide;
|
||||
pub mod slide_actions;
|
||||
pub mod song_search;
|
||||
pub mod songs;
|
||||
pub mod thumbnail;
|
||||
pub mod videos;
|
||||
|
|
|
|||
|
|
@ -334,8 +334,7 @@ impl Model<Presentation> {
|
|||
presentation.ending_index,
|
||||
) {
|
||||
PresKind::Pdf {
|
||||
starting_index: starting_index
|
||||
as i32,
|
||||
starting_index: starting_index as i32,
|
||||
ending_index: ending_index as i32,
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -63,9 +63,8 @@ impl Default for Settings {
|
|||
Eq,
|
||||
PartialEq,
|
||||
Serialize,
|
||||
Default,
|
||||
)]
|
||||
#[derive(Default)]
|
||||
pub struct PersistentState {
|
||||
pub recent_files: VecDeque<PathBuf>,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use crisp::types::{Keyword, Symbol, Value};
|
|||
use miette::{IntoDiagnostic, Result, miette};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{
|
||||
Acquire, FromRow, Row, Sqlite, SqliteConnection, SqlitePool,
|
||||
FromRow, Row, Sqlite, SqliteConnection, SqlitePool,
|
||||
pool::PoolConnection, query, sqlite::SqliteRow,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
|
|
@ -58,7 +58,7 @@ pub enum VerseName {
|
|||
}
|
||||
|
||||
impl VerseName {
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn get_name(&self) -> String {
|
||||
match self {
|
||||
Self::Verse { number, .. } => {
|
||||
|
|
@ -129,7 +129,7 @@ impl AsMimeTypes for VerseName {
|
|||
|
||||
fn as_bytes(
|
||||
&self,
|
||||
mime_type: &str,
|
||||
_mime_type: &str,
|
||||
) -> Option<std::borrow::Cow<'static, [u8]>> {
|
||||
let ron = ron::ser::to_string(self).ok()?;
|
||||
Some(Cow::from(ron.into_bytes()))
|
||||
|
|
@ -143,7 +143,7 @@ impl Default for VerseName {
|
|||
}
|
||||
|
||||
impl From<&Song> for Value {
|
||||
fn from(value: &Song) -> Self {
|
||||
fn from(_value: &Song) -> Self {
|
||||
Self::List(vec![Self::Symbol(Symbol("song".into()))])
|
||||
}
|
||||
}
|
||||
|
|
@ -373,7 +373,7 @@ fn lyrics_to_verse(
|
|||
|
||||
pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||
const DEFAULT_SONG_ID: i32 = 0;
|
||||
const DEFAULT_SONG_LOCATION: usize = 0;
|
||||
// const DEFAULT_SONG_LOCATION: usize = 0;
|
||||
|
||||
let id = if let Some(key_pos) = list
|
||||
.iter()
|
||||
|
|
@ -717,16 +717,14 @@ pub async fn update_song_in_db(
|
|||
}
|
||||
|
||||
impl Song {
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn get_lyric(&self, verse: &VerseName) -> Option<String> {
|
||||
self.verse_map
|
||||
.as_ref()
|
||||
.and_then(|verse_map| {
|
||||
verse_map
|
||||
.get(verse)
|
||||
.cloned()
|
||||
.map(|lyric| lyric.trim_end().to_string())
|
||||
})
|
||||
self.verse_map.as_ref().and_then(|verse_map| {
|
||||
verse_map
|
||||
.get(verse)
|
||||
.cloned()
|
||||
.map(|lyric| lyric.trim_end().to_string())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_lyrics<T: Into<String>>(
|
||||
|
|
@ -815,9 +813,10 @@ impl Song {
|
|||
) {
|
||||
self.set_lyrics(&verse, lyric);
|
||||
if let Some(verses) = self.verses.as_mut()
|
||||
&& let Some(old_verse) = verses.get_mut(index) {
|
||||
*old_verse = verse;
|
||||
}
|
||||
&& let Some(old_verse) = verses.get_mut(index)
|
||||
{
|
||||
*old_verse = verse;
|
||||
}
|
||||
|
||||
if let Some(verses) = &self.verses {
|
||||
let mut new_lyrics = String::new();
|
||||
|
|
|
|||
|
|
@ -707,16 +707,13 @@ impl cosmic::Application for App {
|
|||
|
||||
fn dialog(&self) -> Option<Element<'_, Self::Message>> {
|
||||
let cosmic::cosmic_theme::Spacing {
|
||||
space_none,
|
||||
space_xxxs,
|
||||
space_xxs,
|
||||
space_xs,
|
||||
space_s,
|
||||
space_m,
|
||||
space_l,
|
||||
space_xl,
|
||||
space_xxl,
|
||||
space_xxxl,
|
||||
..
|
||||
} = cosmic::theme::spacing();
|
||||
if self.searching {
|
||||
let items: Vec<Element<Message>> = self
|
||||
|
|
@ -1052,7 +1049,7 @@ impl cosmic::Application for App {
|
|||
let slide_index = self.current_item.1;
|
||||
let item_index = self.current_item.0;
|
||||
let mut tasks = vec![];
|
||||
if let Some(item) =
|
||||
if let Some(_item) =
|
||||
self.service.get(item_index)
|
||||
{
|
||||
if slide_index != 0 {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ pub enum Message {
|
|||
}
|
||||
|
||||
impl ImageEditor {
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
image: None,
|
||||
|
|
@ -93,7 +93,7 @@ impl ImageEditor {
|
|||
Action::None
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn view(&self) -> Element<Message> {
|
||||
let container = if let Some(pic) = &self.image {
|
||||
let image = widget::image(pic.path.clone());
|
||||
|
|
@ -132,7 +132,7 @@ impl ImageEditor {
|
|||
.into()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub const fn editing(&self) -> bool {
|
||||
self.editing
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ impl<'a> Library {
|
|||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn get_song(&self, index: i32) -> Option<&Song> {
|
||||
self.song_library.get_item(index)
|
||||
}
|
||||
|
|
@ -813,7 +813,7 @@ impl<'a> Library {
|
|||
Action::None
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn view(&self) -> Element<Message> {
|
||||
let cosmic::cosmic_theme::Spacing { space_s, .. } =
|
||||
cosmic::theme::spacing();
|
||||
|
|
@ -1263,17 +1263,17 @@ impl<'a> Library {
|
|||
items.into_iter().map(|item| item.1).collect()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn get_video(&self, index: i32) -> Option<&Video> {
|
||||
self.video_library.get_item(index)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn get_image(&self, index: i32) -> Option<&Image> {
|
||||
self.image_library.get_item(index)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn get_presentation(
|
||||
&self,
|
||||
index: i32,
|
||||
|
|
@ -1281,7 +1281,10 @@ impl<'a> Library {
|
|||
self.presentation_library.get_item(index)
|
||||
}
|
||||
|
||||
pub const fn set_modifiers(&mut self, modifiers: Option<Modifiers>) {
|
||||
pub const fn set_modifiers(
|
||||
&mut self,
|
||||
modifiers: Option<Modifiers>,
|
||||
) {
|
||||
self.modifiers_pressed = modifiers;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ impl menu::Action for MenuAction {
|
|||
}
|
||||
|
||||
impl PresentationEditor {
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
presentation: None,
|
||||
|
|
@ -205,9 +205,9 @@ impl PresentationEditor {
|
|||
if let Some(presentation) = self.presentation.as_ref()
|
||||
&& let PresKind::Pdf { ending_index, .. } =
|
||||
presentation.kind
|
||||
{
|
||||
last_index = ending_index;
|
||||
}
|
||||
{
|
||||
last_index = ending_index;
|
||||
}
|
||||
|
||||
if next_index > last_index {
|
||||
return Action::None;
|
||||
|
|
@ -248,9 +248,9 @@ impl PresentationEditor {
|
|||
if let Some(presentation) = self.presentation.as_ref()
|
||||
&& let PresKind::Pdf { starting_index, .. } =
|
||||
presentation.kind
|
||||
{
|
||||
first_index = starting_index;
|
||||
}
|
||||
{
|
||||
first_index = starting_index;
|
||||
}
|
||||
|
||||
if previous_index < first_index {
|
||||
return Action::None;
|
||||
|
|
|
|||
|
|
@ -271,7 +271,9 @@ impl Presenter {
|
|||
let audio = items
|
||||
.first()
|
||||
.and_then(|item| {
|
||||
item.slides.first().map(super::super::core::slide::Slide::audio)
|
||||
item.slides
|
||||
.first()
|
||||
.map(super::super::core::slide::Slide::audio)
|
||||
})
|
||||
.flatten();
|
||||
|
||||
|
|
@ -984,28 +986,28 @@ impl Presenter {
|
|||
|
||||
if let Some(map) = &self.slide_action_map
|
||||
&& let Some(actions) = map.get(&(item_index, slide_index))
|
||||
{
|
||||
for action in actions {
|
||||
match action {
|
||||
slide_actions::Action::Obs { action } => {
|
||||
debug!("found obs slide actions");
|
||||
if let Some(obs) = &self.obs_client {
|
||||
let obs = Arc::clone(obs);
|
||||
let action = action.to_owned();
|
||||
let task = Task::perform(
|
||||
async move { action.run(obs).await },
|
||||
|res| {
|
||||
debug!(?res);
|
||||
Message::None
|
||||
},
|
||||
);
|
||||
tasks.push(task);
|
||||
}
|
||||
{
|
||||
for action in actions {
|
||||
match action {
|
||||
slide_actions::Action::Obs { action } => {
|
||||
debug!("found obs slide actions");
|
||||
if let Some(obs) = &self.obs_client {
|
||||
let obs = Arc::clone(obs);
|
||||
let action = action.to_owned();
|
||||
let task = Task::perform(
|
||||
async move { action.run(obs).await },
|
||||
|res| {
|
||||
debug!(?res);
|
||||
Message::None
|
||||
},
|
||||
);
|
||||
tasks.push(task);
|
||||
}
|
||||
slide_actions::Action::Other => todo!(),
|
||||
}
|
||||
slide_actions::Action::Other => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Task::batch(tasks)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use tracing::debug;
|
|||
|
||||
use crate::core::service_items::ServiceItem;
|
||||
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub const fn service<Message: Clone + 'static>(
|
||||
service: &Vec<ServiceItem>,
|
||||
) -> Service<'_, Message> {
|
||||
|
|
@ -35,7 +35,7 @@ pub struct Service<'a, Message> {
|
|||
}
|
||||
|
||||
impl<'a, Message: Clone + 'static> Service<'a, Message> {
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub const fn new(service: &'a Vec<ServiceItem>) -> Self {
|
||||
Self {
|
||||
service,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ pub enum Message {
|
|||
}
|
||||
|
||||
impl VideoEditor {
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
video: None,
|
||||
|
|
|
|||
|
|
@ -101,13 +101,13 @@ where
|
|||
Theme: Catalog,
|
||||
{
|
||||
/// Creates an empty [`Column`].
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
Self::from_vec(Vec::new())
|
||||
}
|
||||
|
||||
/// Creates a [`Column`] with the given capacity.
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn with_capacity(capacity: usize) -> Self {
|
||||
Self::from_vec(Vec::with_capacity(capacity))
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ where
|
|||
///
|
||||
/// If any of the children have a [`Length::Fill`] strategy, you will need to
|
||||
/// call [`Column::width`] or [`Column::height`] accordingly.
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn from_vec(
|
||||
children: Vec<Element<'a, Message, Theme, Renderer>>,
|
||||
) -> Self {
|
||||
|
|
@ -896,7 +896,7 @@ impl Catalog for cosmic::Theme {
|
|||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn default(theme: &Theme) -> Style {
|
||||
Style {
|
||||
scale: 1.05,
|
||||
|
|
|
|||
|
|
@ -95,13 +95,13 @@ where
|
|||
Theme: Catalog,
|
||||
{
|
||||
/// Creates an empty [`Row`].
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
Self::from_vec(Vec::new())
|
||||
}
|
||||
|
||||
/// Creates a [`Row`] with the given capacity.
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn with_capacity(capacity: usize) -> Self {
|
||||
Self::from_vec(Vec::with_capacity(capacity))
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ where
|
|||
///
|
||||
/// If any of the children have a [`Length::Fill`] strategy, you will need to
|
||||
/// call [`Row::width`] or [`Row::height`] accordingly.
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn from_vec(
|
||||
children: Vec<Element<'a, Message, Theme, Renderer>>,
|
||||
) -> Self {
|
||||
|
|
@ -257,7 +257,9 @@ where
|
|||
/// Turns the [`Row`] into a [`Wrapping`] row.
|
||||
///
|
||||
/// The original alignment of the [`Row`] is preserved per row wrapped.
|
||||
pub const fn wrap(self) -> Wrapping<'a, Message, Theme, Renderer> {
|
||||
pub const fn wrap(
|
||||
self,
|
||||
) -> Wrapping<'a, Message, Theme, Renderer> {
|
||||
Wrapping { row: self }
|
||||
}
|
||||
|
||||
|
|
@ -314,8 +316,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<Message, Renderer> Default
|
||||
for Row<'_, Message, Theme, Renderer>
|
||||
impl<Message, Renderer> Default for Row<'_, Message, Theme, Renderer>
|
||||
where
|
||||
Renderer: renderer::Renderer,
|
||||
Theme: Catalog,
|
||||
|
|
@ -1044,7 +1045,7 @@ impl Catalog for cosmic::Theme {
|
|||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn default(theme: &cosmic::Theme) -> Style {
|
||||
Style {
|
||||
scale: 1.05,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ pub enum Action {
|
|||
}
|
||||
|
||||
impl VerseEditor {
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn new(verse: VerseName, lyric: String) -> Self {
|
||||
Self {
|
||||
verse_name: verse,
|
||||
|
|
@ -50,16 +50,7 @@ impl VerseEditor {
|
|||
|
||||
pub fn view(&self) -> Element<Message> {
|
||||
let cosmic::cosmic_theme::Spacing {
|
||||
space_none,
|
||||
space_xxxs,
|
||||
space_xxs,
|
||||
space_xs,
|
||||
space_s,
|
||||
space_m,
|
||||
space_l,
|
||||
space_xl,
|
||||
space_xxl,
|
||||
space_xxxl,
|
||||
space_s, space_m, ..
|
||||
} = theme::spacing();
|
||||
|
||||
let verse_title =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue