This commit is contained in:
parent
28a18819cf
commit
7d8c2243d8
5 changed files with 95 additions and 26 deletions
|
@ -41,7 +41,7 @@ rapidfuzz = "0.5.0"
|
|||
# mupdf = "0.5.0"
|
||||
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]
|
||||
git = "https://github.com/pop-os/libcosmic"
|
||||
|
|
24
flake.lock
generated
24
flake.lock
generated
|
@ -6,11 +6,11 @@
|
|||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1755585599,
|
||||
"narHash": "sha256-tl/0cnsqB/Yt7DbaGMel2RLa7QG5elA8lkaOXli6VdY=",
|
||||
"lastModified": 1758177713,
|
||||
"narHash": "sha256-4Mesi0sOxCzrwnFHeAhL/vv1K1Wcwsl4D9duQ7ndYS8=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "6ed03ef4c8ec36d193c18e06b9ecddde78fb7e42",
|
||||
"rev": "60316bdc00603b483992560baa14841e42e58a7b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -80,11 +80,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1755186698,
|
||||
"narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=",
|
||||
"lastModified": 1758035966,
|
||||
"narHash": "sha256-qqIJ3yxPiB0ZQTT9//nFGQYn8X/PBoJbofA7hRKZnmE=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c",
|
||||
"rev": "8d4ddb19d03c65a36ad8d189d001dc32ffb0306b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -112,11 +112,11 @@
|
|||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1755615617,
|
||||
"narHash": "sha256-HMwfAJBdrr8wXAkbGhtcby1zGFvs+StOp19xNsbqdOg=",
|
||||
"lastModified": 1758035966,
|
||||
"narHash": "sha256-qqIJ3yxPiB0ZQTT9//nFGQYn8X/PBoJbofA7hRKZnmE=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "20075955deac2583bb12f07151c2df830ef346b4",
|
||||
"rev": "8d4ddb19d03c65a36ad8d189d001dc32ffb0306b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -137,11 +137,11 @@
|
|||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1755504847,
|
||||
"narHash": "sha256-VX0B9hwhJypCGqncVVLC+SmeMVd/GAYbJZ0MiiUn2Pk=",
|
||||
"lastModified": 1757362324,
|
||||
"narHash": "sha256-/PAhxheUq4WBrW5i/JHzcCqK5fGWwLKdH6/Lu1tyS18=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "a905e3b21b144d77e1b304e49f3264f6f8d4db75",
|
||||
"rev": "9edc9cbe5d8e832b5864e09854fa94861697d2fd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -178,9 +178,44 @@ impl<'a> Library {
|
|||
})
|
||||
.ok()
|
||||
}
|
||||
LibraryKind::Video => todo!(),
|
||||
LibraryKind::Image => todo!(),
|
||||
LibraryKind::Presentation => todo!(),
|
||||
LibraryKind::Video => {
|
||||
let video = Video::default();
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -775,7 +775,7 @@ pub(crate) fn slide_view<'a>(
|
|||
})
|
||||
.content_fit(ContentFit::Cover),
|
||||
)
|
||||
.center(Length::Shrink)
|
||||
.center(Length::Fill)
|
||||
.clip(true)
|
||||
// Container::new(Space::new(0, 0))
|
||||
} else {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use std::{io, path::PathBuf, sync::Arc};
|
||||
|
||||
use cosmic::{
|
||||
dialog::file_chooser::open::Dialog,
|
||||
dialog::file_chooser::{open::Dialog, FileFilter},
|
||||
iced::{
|
||||
alignment::Vertical,
|
||||
font::{Family, Stretch, Style, Weight},
|
||||
Font, Length,
|
||||
},
|
||||
|
@ -17,11 +18,13 @@ use cosmic::{
|
|||
};
|
||||
use dirs::font_dir;
|
||||
use iced_video_player::Video;
|
||||
use tracing::{debug, error};
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
use crate::{
|
||||
core::{service_items::ServiceTrait, songs::Song},
|
||||
ui::{presenter::slide_view, slide_editor::SlideEditor},
|
||||
ui::{
|
||||
presenter::slide_view, slide_editor::SlideEditor, text_svg,
|
||||
},
|
||||
Background, BackgroundKind,
|
||||
};
|
||||
|
||||
|
@ -199,7 +202,14 @@ impl SongEditor {
|
|||
self.current_font = font;
|
||||
// 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) => {
|
||||
self.title = title.clone();
|
||||
if let Some(song) = &mut self.song {
|
||||
|
@ -288,7 +298,11 @@ impl SongEditor {
|
|||
let slides: Vec<Element<Message>> = slides
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(index, slide)| {
|
||||
.map(|(index, mut slide)| {
|
||||
text_svg::text_svg_generator(
|
||||
&mut slide,
|
||||
Arc::clone(&self.font_db),
|
||||
);
|
||||
container(
|
||||
slide_view(
|
||||
slide,
|
||||
|
@ -383,7 +397,7 @@ order",
|
|||
Some(selected_font),
|
||||
Message::ChangeFont,
|
||||
)
|
||||
.width(200);
|
||||
.width(300);
|
||||
let font_size = combo_box(
|
||||
&self.font_sizes,
|
||||
"Font Size",
|
||||
|
@ -405,11 +419,14 @@ order",
|
|||
.padding(10);
|
||||
|
||||
row![
|
||||
text::body("Font:"),
|
||||
font_selector,
|
||||
text::body("Font Size:"),
|
||||
font_size,
|
||||
horizontal_space(),
|
||||
background_selector
|
||||
]
|
||||
.align_y(Vertical::Center)
|
||||
.spacing(10)
|
||||
.into()
|
||||
}
|
||||
|
@ -448,21 +465,38 @@ impl Default for SongEditor {
|
|||
|
||||
async fn pick_background() -> Result<PathBuf, SongError> {
|
||||
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
|
||||
.filter(bg_filter)
|
||||
.directory(dirs::home_dir().expect("oops"))
|
||||
.open_file()
|
||||
.await
|
||||
.map_err(|_| SongError::DialogClosed)
|
||||
.map_err(|e| {
|
||||
error!(?e);
|
||||
SongError::BackgroundDialogClosed
|
||||
})
|
||||
.map(|file| file.url().to_file_path().unwrap())
|
||||
// rfd::AsyncFileDialog::new()
|
||||
// .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()
|
||||
// .await
|
||||
// .ok_or(SongError::DialogClosed)
|
||||
// .ok_or(SongError::BackgroundDialogClosed)
|
||||
// .map(|file| file.path().to_owned())
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum SongError {
|
||||
DialogClosed,
|
||||
BackgroundDialogClosed,
|
||||
IOError(io::ErrorKind),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue