fixing lots of little issues
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
Chris Cochrun 2025-09-18 14:10:08 -05:00
parent 28a18819cf
commit 7d8c2243d8
5 changed files with 95 additions and 26 deletions

View file

@ -41,7 +41,7 @@ rapidfuzz = "0.5.0"
# mupdf = "0.5.0" # mupdf = "0.5.0"
mupdf = { version = "0.5.0", git = "https://github.com/messense/mupdf-rs", rev="2425c1405b326165b06834dcc1ca859015f92787"} mupdf = { version = "0.5.0", git = "https://github.com/messense/mupdf-rs", rev="2425c1405b326165b06834dcc1ca859015f92787"}
# rfd = { version = "0.12.1", features = ["xdg-portal"], default-features = false } # rfd = { version = "0.14.1" }
[dependencies.libcosmic] [dependencies.libcosmic]
git = "https://github.com/pop-os/libcosmic" git = "https://github.com/pop-os/libcosmic"

24
flake.lock generated
View file

@ -6,11 +6,11 @@
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1755585599, "lastModified": 1758177713,
"narHash": "sha256-tl/0cnsqB/Yt7DbaGMel2RLa7QG5elA8lkaOXli6VdY=", "narHash": "sha256-4Mesi0sOxCzrwnFHeAhL/vv1K1Wcwsl4D9duQ7ndYS8=",
"owner": "nix-community", "owner": "nix-community",
"repo": "fenix", "repo": "fenix",
"rev": "6ed03ef4c8ec36d193c18e06b9ecddde78fb7e42", "rev": "60316bdc00603b483992560baa14841e42e58a7b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -80,11 +80,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1755186698, "lastModified": 1758035966,
"narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=", "narHash": "sha256-qqIJ3yxPiB0ZQTT9//nFGQYn8X/PBoJbofA7hRKZnmE=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c", "rev": "8d4ddb19d03c65a36ad8d189d001dc32ffb0306b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -112,11 +112,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1755615617, "lastModified": 1758035966,
"narHash": "sha256-HMwfAJBdrr8wXAkbGhtcby1zGFvs+StOp19xNsbqdOg=", "narHash": "sha256-qqIJ3yxPiB0ZQTT9//nFGQYn8X/PBoJbofA7hRKZnmE=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "20075955deac2583bb12f07151c2df830ef346b4", "rev": "8d4ddb19d03c65a36ad8d189d001dc32ffb0306b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -137,11 +137,11 @@
"rust-analyzer-src": { "rust-analyzer-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1755504847, "lastModified": 1757362324,
"narHash": "sha256-VX0B9hwhJypCGqncVVLC+SmeMVd/GAYbJZ0MiiUn2Pk=", "narHash": "sha256-/PAhxheUq4WBrW5i/JHzcCqK5fGWwLKdH6/Lu1tyS18=",
"owner": "rust-lang", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "a905e3b21b144d77e1b304e49f3264f6f8d4db75", "rev": "9edc9cbe5d8e832b5864e09854fa94861697d2fd",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -178,9 +178,44 @@ impl<'a> Library {
}) })
.ok() .ok()
} }
LibraryKind::Video => todo!(), LibraryKind::Video => {
LibraryKind::Image => todo!(), let video = Video::default();
LibraryKind::Presentation => todo!(), self.video_library
.add_item(video)
.map(|_| {
let index =
self.video_library.items.len();
(LibraryKind::Video, index as i32)
})
.ok()
}
LibraryKind::Image => {
let image = Image::default();
self.image_library
.add_item(image)
.map(|_| {
let index =
self.image_library.items.len();
(LibraryKind::Image, index as i32)
})
.ok()
}
LibraryKind::Presentation => {
let presentation = Presentation::default();
self.presentation_library
.add_item(presentation)
.map(|_| {
let index = self
.presentation_library
.items
.len();
(
LibraryKind::Presentation,
index as i32,
)
})
.ok()
}
}; };
return self.update(Message::OpenItem(item)); return self.update(Message::OpenItem(item));
} }

View file

@ -775,7 +775,7 @@ pub(crate) fn slide_view<'a>(
}) })
.content_fit(ContentFit::Cover), .content_fit(ContentFit::Cover),
) )
.center(Length::Shrink) .center(Length::Fill)
.clip(true) .clip(true)
// Container::new(Space::new(0, 0)) // Container::new(Space::new(0, 0))
} else { } else {

View file

@ -1,8 +1,9 @@
use std::{io, path::PathBuf, sync::Arc}; use std::{io, path::PathBuf, sync::Arc};
use cosmic::{ use cosmic::{
dialog::file_chooser::open::Dialog, dialog::file_chooser::{open::Dialog, FileFilter},
iced::{ iced::{
alignment::Vertical,
font::{Family, Stretch, Style, Weight}, font::{Family, Stretch, Style, Weight},
Font, Length, Font, Length,
}, },
@ -17,11 +18,13 @@ use cosmic::{
}; };
use dirs::font_dir; use dirs::font_dir;
use iced_video_player::Video; use iced_video_player::Video;
use tracing::{debug, error}; use tracing::{debug, error, warn};
use crate::{ use crate::{
core::{service_items::ServiceTrait, songs::Song}, core::{service_items::ServiceTrait, songs::Song},
ui::{presenter::slide_view, slide_editor::SlideEditor}, ui::{
presenter::slide_view, slide_editor::SlideEditor, text_svg,
},
Background, BackgroundKind, Background, BackgroundKind,
}; };
@ -199,7 +202,14 @@ impl SongEditor {
self.current_font = font; self.current_font = font;
// return self.update_song(song); // return self.update_song(song);
} }
Message::ChangeFontSize(size) => self.font_size = size, Message::ChangeFontSize(size) => {
self.font_size = size;
if let Some(song) = &mut self.song {
song.font_size = Some(size as i32);
let song = song.to_owned();
return self.update_song(song);
}
}
Message::ChangeTitle(title) => { Message::ChangeTitle(title) => {
self.title = title.clone(); self.title = title.clone();
if let Some(song) = &mut self.song { if let Some(song) = &mut self.song {
@ -288,7 +298,11 @@ impl SongEditor {
let slides: Vec<Element<Message>> = slides let slides: Vec<Element<Message>> = slides
.into_iter() .into_iter()
.enumerate() .enumerate()
.map(|(index, slide)| { .map(|(index, mut slide)| {
text_svg::text_svg_generator(
&mut slide,
Arc::clone(&self.font_db),
);
container( container(
slide_view( slide_view(
slide, slide,
@ -383,7 +397,7 @@ order",
Some(selected_font), Some(selected_font),
Message::ChangeFont, Message::ChangeFont,
) )
.width(200); .width(300);
let font_size = combo_box( let font_size = combo_box(
&self.font_sizes, &self.font_sizes,
"Font Size", "Font Size",
@ -405,11 +419,14 @@ order",
.padding(10); .padding(10);
row![ row![
text::body("Font:"),
font_selector, font_selector,
text::body("Font Size:"),
font_size, font_size,
horizontal_space(), horizontal_space(),
background_selector background_selector
] ]
.align_y(Vertical::Center)
.spacing(10) .spacing(10)
.into() .into()
} }
@ -448,21 +465,38 @@ impl Default for SongEditor {
async fn pick_background() -> Result<PathBuf, SongError> { async fn pick_background() -> Result<PathBuf, SongError> {
let dialog = Dialog::new().title("Choose a background..."); let dialog = Dialog::new().title("Choose a background...");
let bg_filter = FileFilter::new("Videos and Images")
.extension("png")
.extension("jpg")
.extension("mp4")
.extension("webm")
.extension("mkv")
.extension("jpeg");
dialog dialog
.filter(bg_filter)
.directory(dirs::home_dir().expect("oops"))
.open_file() .open_file()
.await .await
.map_err(|_| SongError::DialogClosed) .map_err(|e| {
error!(?e);
SongError::BackgroundDialogClosed
})
.map(|file| file.url().to_file_path().unwrap()) .map(|file| file.url().to_file_path().unwrap())
// rfd::AsyncFileDialog::new() // rfd::AsyncFileDialog::new()
// .set_title("Choose a background...") // .set_title("Choose a background...")
// .add_filter(
// "Images and Videos",
// &["png", "jpeg", "mp4", "webm", "mkv", "jpg", "mpeg"],
// )
// .set_directory(dirs::home_dir().unwrap())
// .pick_file() // .pick_file()
// .await // .await
// .ok_or(SongError::DialogClosed) // .ok_or(SongError::BackgroundDialogClosed)
// .map(|file| file.path().to_owned()) // .map(|file| file.path().to_owned())
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum SongError { pub enum SongError {
DialogClosed, BackgroundDialogClosed,
IOError(io::ErrorKind), IOError(io::ErrorKind),
} }