update width

This commit is contained in:
Chris Cochrun 2023-09-20 06:15:48 -05:00
parent 1d1c49c5fa
commit 70eadeadb2
8 changed files with 104 additions and 40 deletions

View file

@ -13,7 +13,8 @@ pub fn bg_from_video(video: &Path) -> PathBuf {
data_dir.push("librepresenter");
data_dir.push("thumbnails");
if !data_dir.exists() {
fs::create_dir(&data_dir).expect("Could not create thumbnails dir");
fs::create_dir(&data_dir)
.expect("Could not create thumbnails dir");
}
let mut screenshot = data_dir.clone();
screenshot.push(video.file_name().unwrap());
@ -46,8 +47,10 @@ pub fn bg_from_video(video: &Path) -> PathBuf {
}
}
let hours: i32 = hours.parse().unwrap_or_default();
let mut minutes: i32 = minutes.parse().unwrap_or_default();
let mut seconds: i32 = seconds.parse().unwrap_or_default();
let mut minutes: i32 =
minutes.parse().unwrap_or_default();
let mut seconds: i32 =
seconds.parse().unwrap_or_default();
minutes += hours * 60;
seconds += minutes * 60;
at_second = seconds / 5;

View file

@ -1,3 +1,5 @@
// The purpose of this file is to provide validation
// of whether or not a file exists
#[cxx_qt::bridge]
mod file_helper {
use cxx_qt_lib::QVariantValue;
@ -55,7 +57,8 @@ mod file_helper {
let _file_string = file_string.strip_prefix("file://");
match _file_string {
None => {
let _exists = Path::new(&file.to_string()).exists();
let _exists =
Path::new(&file.to_string()).exists();
println!("{file} exists? {_exists}");
_exists
}

View file

@ -7,7 +7,7 @@ pub mod reveal_js;
pub mod schema;
mod service_item_model;
mod service_thing;
mod settings;
pub mod settings;
pub mod slide_model;
mod slide_obj;
pub mod song_model;

View file

@ -1,8 +1,11 @@
use diesel::prelude::*;
use diesel::sqlite::SqliteConnection;
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
use diesel_migrations::{
embed_migrations, EmbeddedMigrations, MigrationHarness,
};
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("src/rust/migrations");
pub const MIGRATIONS: EmbeddedMigrations =
embed_migrations!("src/rust/migrations");
pub fn run_migrations(conn: &mut SqliteConnection) -> bool {
conn.run_pending_migrations(MIGRATIONS).unwrap();

View file

@ -3,11 +3,13 @@ use std::fs::read_to_string;
pub fn count_slides_and_fragments(html_file_path: &str) -> i32 {
// Read the HTML file
let html_content = read_to_string(html_file_path).expect("Failed to read HTML file");
let html_content = read_to_string(html_file_path)
.expect("Failed to read HTML file");
// Split HTML content by slide delimiters
let slide_delimiter = "<section";
let slide_content: Vec<&str> = html_content.split(slide_delimiter).collect();
let slide_content: Vec<&str> =
html_content.split(slide_delimiter).collect();
// Count slides and fragments
let num_slides = slide_content.len() - 1;

View file

@ -59,4 +59,9 @@ diesel::table! {
}
}
diesel::allow_tables_to_appear_in_same_query!(images, presentations, songs, videos,);
diesel::allow_tables_to_appear_in_same_query!(
images,
presentations,
songs,
videos,
);

View file

@ -8,7 +8,8 @@ mod slide_obj {
include!("cxx-qt-lib/qstring.h");
type QString = cxx_qt_lib::QString;
include!("cxx-qt-lib/qmap.h");
type QMap_QString_QVariant = cxx_qt_lib::QMap<cxx_qt_lib::QMapPair_QString_QVariant>;
type QMap_QString_QVariant =
cxx_qt_lib::QMap<cxx_qt_lib::QMapPair_QString_QVariant>;
include!("cxx-qt-lib/qvariant.h");
type QVariant = cxx_qt_lib::QVariant;
}
@ -87,7 +88,11 @@ mod slide_obj {
impl qobject::SlideObj {
#[qinvokable]
pub fn change_slide(mut self: Pin<&mut Self>, item: QMap_QString_QVariant, index: i32) {
pub fn change_slide(
mut self: Pin<&mut Self>,
item: QMap_QString_QVariant,
index: i32,
) {
println!("## Slide Details ##");
let text = item
.get(&QString::from("text"))
@ -126,10 +131,15 @@ mod slide_obj {
let image_background = item
.get(&QString::from("imageBackground"))
.unwrap_or(QVariant::from(&QString::from("")));
if let Some(image_background) = image_background.value::<QString>() {
if &image_background != self.as_ref().image_background() {
if let Some(image_background) =
image_background.value::<QString>()
{
if &image_background
!= self.as_ref().image_background()
{
println!("image-bg: {image_background}");
self.as_mut().set_image_background(image_background);
self.as_mut()
.set_image_background(image_background);
}
} else {
println!("image-bg: empty");
@ -137,17 +147,22 @@ mod slide_obj {
let video_background = item
.get(&QString::from("videoBackground"))
.unwrap_or(QVariant::from(&QString::from("")));
if let Some(video_background) = video_background.value::<QString>() {
if &video_background != self.as_ref().video_background() {
if let Some(video_background) =
video_background.value::<QString>()
{
if &video_background
!= self.as_ref().video_background()
{
println!("video-bg: {video_background}");
self.as_mut().set_video_background(video_background);
self.as_mut()
.set_video_background(video_background);
}
} else {
println!("video-bg: empty");
}
let font = item
.get(&QString::from("font"))
.unwrap_or(QVariant::from(&QString::from("Quicksand")));
let font = item.get(&QString::from("font")).unwrap_or(
QVariant::from(&QString::from("Quicksand")),
);
if let Some(font) = font.value::<QString>() {
if &font != self.as_ref().font() {
println!("font: {font}");
@ -159,10 +174,16 @@ mod slide_obj {
let vtext_alignment = item
.get(&QString::from("verticalTextAlignment"))
.unwrap_or(QVariant::from(&QString::from("center")));
if let Some(vtext_alignment) = vtext_alignment.value::<QString>() {
if &vtext_alignment != self.as_ref().vtext_alignment() {
println!("vertical-text-align: {vtext_alignment}");
self.as_mut().set_vtext_alignment(vtext_alignment);
if let Some(vtext_alignment) =
vtext_alignment.value::<QString>()
{
if &vtext_alignment != self.as_ref().vtext_alignment()
{
println!(
"vertical-text-align: {vtext_alignment}"
);
self.as_mut()
.set_vtext_alignment(vtext_alignment);
}
} else {
println!("vertical-text-align: empty");
@ -170,10 +191,16 @@ mod slide_obj {
let htext_alignment = item
.get(&QString::from("horizontalTextAlignment"))
.unwrap_or(QVariant::from(&QString::from("center")));
if let Some(htext_alignment) = htext_alignment.value::<QString>() {
if &htext_alignment != self.as_ref().htext_alignment() {
println!("horizontal-text-align: {htext_alignment}");
self.as_mut().set_htext_alignment(htext_alignment);
if let Some(htext_alignment) =
htext_alignment.value::<QString>()
{
if &htext_alignment != self.as_ref().htext_alignment()
{
println!(
"horizontal-text-align: {htext_alignment}"
);
self.as_mut()
.set_htext_alignment(htext_alignment);
}
} else {
println!("horizontal-text-align: empty");
@ -197,7 +224,8 @@ mod slide_obj {
println!("looping: {looping}");
self.as_mut().set_looping(looping);
let lp = looping;
self.as_mut().emit(Signals::LoopChanged { looping: &lp });
self.as_mut()
.emit(Signals::LoopChanged { looping: &lp });
}
} else {
println!("looping: empty")
@ -230,18 +258,25 @@ mod slide_obj {
println!("New slide index = {}", int);
self.as_mut().set_slide_index(int);
};
self.as_mut().emit(Signals::SlideChanged { slide: &index });
self.as_mut()
.emit(Signals::SlideChanged { slide: &index });
println!("## Slide End ##");
}
#[qinvokable]
pub fn next(mut self: Pin<&mut Self>, next_item: QMap_QString_QVariant) -> bool {
pub fn next(
mut self: Pin<&mut Self>,
next_item: QMap_QString_QVariant,
) -> bool {
let new_id = self.as_ref().slide_index() + 1;
self.as_mut().change_slide(next_item, new_id);
true
}
#[qinvokable]
pub fn previous(mut self: Pin<&mut Self>, prev_item: QMap_QString_QVariant) -> bool {
pub fn previous(
mut self: Pin<&mut Self>,
prev_item: QMap_QString_QVariant,
) -> bool {
let new_id = self.as_ref().slide_index() - 1;
self.as_mut().change_slide(prev_item, new_id);
true

View file

@ -28,7 +28,10 @@ mod ytdl {
impl qobject::Ytdl {
#[qinvokable]
pub fn get_video(mut self: Pin<&mut Self>, url: QUrl) -> bool {
pub fn get_video(
mut self: Pin<&mut Self>,
url: QUrl,
) -> bool {
if !url.is_valid() {
false
} else {
@ -37,7 +40,8 @@ mod ytdl {
data_dir.push("librepresenter");
data_dir.push("ytdl");
if !data_dir.exists() {
fs::create_dir(&data_dir).expect("Could not create ytdl dir");
fs::create_dir(&data_dir)
.expect("Could not create ytdl dir");
}
println!("{:?}", data_dir);
self.as_mut().set_loading(true);
@ -53,25 +57,34 @@ mod ytdl {
.download(true)
.run()
.unwrap();
let output = ytdl.into_single_video().unwrap();
let output =
ytdl.into_single_video().unwrap();
println!("{:?}", output.title);
println!("{:?}", output.thumbnail);
println!("{:?}", output.url);
let title = QString::from(&output.title);
let thumbnail = QUrl::from(&output.thumbnail.unwrap_or_default());
let thumbnail = QUrl::from(
&output.thumbnail.unwrap_or_default(),
);
let mut file = String::from(output_dirs);
file.push_str("/");
file.push_str(&output.title);
file.push_str(".");
file.push_str(&output.ext.unwrap_or_default());
file.push_str(
&output.ext.unwrap_or_default(),
);
println!("{:?}", file);
thread.queue(move |mut qobject_ytdl| {
qobject_ytdl.as_mut().set_loaded(true);
qobject_ytdl.as_mut().set_loading(false);
qobject_ytdl.as_mut().set_title(title);
qobject_ytdl.as_mut().set_thumbnail(thumbnail);
qobject_ytdl.as_mut().set_file(QUrl::from(&file));
qobject_ytdl
.as_mut()
.set_thumbnail(thumbnail);
qobject_ytdl
.as_mut()
.set_file(QUrl::from(&file));
})
});
true