Merge branch 'revert-ba25cee5' into 'master'
Revert "setting these two to do the same" See merge request chriscochrun/church-presenter!1
This commit is contained in:
commit
61440147b1
2 changed files with 398 additions and 405 deletions
|
@ -2,6 +2,10 @@
|
||||||
// of whether or not a file exists
|
// of whether or not a file exists
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
mod file_helper {
|
mod file_helper {
|
||||||
|
use rfd::FileDialog;
|
||||||
|
use std::path::Path;
|
||||||
|
use tracing::{debug, debug_span, error, info, instrument};
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!("cxx-qt-lib/qstring.h");
|
include!("cxx-qt-lib/qstring.h");
|
||||||
type QString = cxx_qt_lib::QString;
|
type QString = cxx_qt_lib::QString;
|
||||||
|
@ -11,124 +15,127 @@ mod file_helper {
|
||||||
type QVariant = cxx_qt_lib::QVariant;
|
type QVariant = cxx_qt_lib::QVariant;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "RustQt" {
|
#[derive(Clone)]
|
||||||
#[qobject]
|
#[cxx_qt::qobject]
|
||||||
#[qml_element]
|
pub struct FileHelper {
|
||||||
#[qproperty(QString, name)]
|
#[qproperty]
|
||||||
#[qproperty(QString, file_path)]
|
name: QString,
|
||||||
type FileHelper = super::FileHelperRust;
|
#[qproperty]
|
||||||
|
file_path: QString,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for FileHelper {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
name: QString::from(""),
|
||||||
|
file_path: QString::from(""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl qobject::FileHelper {
|
||||||
|
// #[qinvokable]
|
||||||
|
// pub fn save(self: Pin<&mut Self>, file: QUrl, service_list: QVariant) -> bool {
|
||||||
|
// println!("{}", file);
|
||||||
|
// match service_list.value() {
|
||||||
|
// QVariantValue::<QString>(..) => println!("string"),
|
||||||
|
// QVariantValue::<QUrl>(..) => println!("url"),
|
||||||
|
// QVariantValue::<QDate>(..) => println!("date"),
|
||||||
|
// _ => println!("QVariant is..."),
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn validate(self: Pin<&mut FileHelper>, file: QUrl) -> bool;
|
pub fn load(self: Pin<&mut Self>, file: QUrl) -> Vec<String> {
|
||||||
|
println!("{file}");
|
||||||
|
vec!["hi".to_string()]
|
||||||
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
pub fn save_file(self: Pin<&mut FileHelper>) -> QUrl;
|
pub fn validate(self: Pin<&mut Self>, file: QUrl) -> bool {
|
||||||
|
let file_string = file.to_string();
|
||||||
|
let file_string = file_string.strip_prefix("file://");
|
||||||
|
match file_string {
|
||||||
|
Some(file) => {
|
||||||
|
let exists = Path::new(&file).exists();
|
||||||
|
println!("{file} exists? {exists}");
|
||||||
|
exists
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
let exists =
|
||||||
|
Path::new(&file.to_string()).exists();
|
||||||
|
println!("{file} exists? {exists}");
|
||||||
|
exists
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn load_file(
|
pub fn save_file(self: Pin<&mut Self>) -> QUrl {
|
||||||
self: Pin<&mut FileHelper>,
|
let file = FileDialog::new()
|
||||||
|
.set_file_name("NVTFC.pres")
|
||||||
|
.set_title("Save Presentation")
|
||||||
|
.save_file();
|
||||||
|
if let Some(file) = file {
|
||||||
|
println!("saving-file: {:?}", file);
|
||||||
|
let mut string =
|
||||||
|
String::from(file.to_str().unwrap_or(""));
|
||||||
|
if string.is_empty() {
|
||||||
|
QUrl::default()
|
||||||
|
} else {
|
||||||
|
string.insert_str(0, "file://");
|
||||||
|
QUrl::from(string.as_str())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QUrl::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
pub fn load_file(
|
||||||
|
self: Pin<&mut Self>,
|
||||||
title: QString,
|
title: QString,
|
||||||
filter: QString,
|
filter: QString,
|
||||||
) -> QUrl;
|
) -> QUrl {
|
||||||
|
let video_filters = [
|
||||||
}
|
"mp4", "webm", "avi", "mkv", "MP4", "WEBM", "AVI",
|
||||||
}
|
"MKV",
|
||||||
|
];
|
||||||
use rfd::FileDialog;
|
let image_filters = [
|
||||||
use std::path::Path;
|
"jpg", "png", "gif", "jpeg", "JPG", "PNG", "webp",
|
||||||
use tracing::{debug, debug_span, error, info, instrument};
|
"gif",
|
||||||
|
];
|
||||||
#[derive(Clone)]
|
let audio_filters = ["mp3", "opus", "ogg", "flac", "wav"];
|
||||||
pub struct FileHelperRust {
|
let title = title.to_string();
|
||||||
name: QString,
|
let filter = filter.to_string();
|
||||||
file_path: QString,
|
let mut file = FileDialog::new().set_title(title);
|
||||||
}
|
match filter.as_str() {
|
||||||
|
"video" => {
|
||||||
impl Default for FileHelperRust {
|
file = file.add_filter(filter, &video_filters);
|
||||||
fn default() -> Self {
|
}
|
||||||
Self {
|
"image" => {
|
||||||
name: QString::from(""),
|
file = file.add_filter(filter, &image_filters);
|
||||||
file_path: QString::from(""),
|
}
|
||||||
}
|
"audio" => {
|
||||||
}
|
file = file.add_filter(filter, &audio_filters);
|
||||||
}
|
}
|
||||||
|
_ => debug!("nothing"),
|
||||||
impl ffi::FileHelperRust {
|
};
|
||||||
pub fn validate(self: Pin<&mut Self>, file: QUrl) -> bool {
|
let file = file.pick_file();
|
||||||
let file_string = file.to_string();
|
if let Some(file) = file {
|
||||||
let file_string = file_string.strip_prefix("file://");
|
println!("loading-file: {:?}", file);
|
||||||
match file_string {
|
let mut string =
|
||||||
Some(file) => {
|
String::from(file.to_str().unwrap_or(""));
|
||||||
let exists = Path::new(&file).exists();
|
if string.is_empty() {
|
||||||
println!("{file} exists? {exists}");
|
QUrl::default()
|
||||||
exists
|
} else {
|
||||||
}
|
string.insert_str(0, "file://");
|
||||||
None => {
|
QUrl::from(string.as_str())
|
||||||
let exists = Path::new(&file.to_string()).exists();
|
}
|
||||||
println!("{file} exists? {exists}");
|
|
||||||
exists
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn save_file(self: Pin<&mut Self>) -> QUrl {
|
|
||||||
let file = FileDialog::new()
|
|
||||||
.set_file_name("NVTFC.pres")
|
|
||||||
.set_title("Save Presentation")
|
|
||||||
.save_file();
|
|
||||||
if let Some(file) = file {
|
|
||||||
println!("saving-file: {:?}", file);
|
|
||||||
let mut string =
|
|
||||||
String::from(file.to_str().unwrap_or(""));
|
|
||||||
if string.is_empty() {
|
|
||||||
QUrl::default()
|
|
||||||
} else {
|
} else {
|
||||||
string.insert_str(0, "file://");
|
|
||||||
QUrl::from(string.as_str())
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
QUrl::default()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn load_file(
|
|
||||||
self: Pin<&mut Self>,
|
|
||||||
title: QString,
|
|
||||||
filter: QString,
|
|
||||||
) -> QUrl {
|
|
||||||
let video_filters = [
|
|
||||||
"mp4", "webm", "avi", "mkv", "MP4", "WEBM", "AVI", "MKV",
|
|
||||||
];
|
|
||||||
let image_filters = [
|
|
||||||
"jpg", "png", "gif", "jpeg", "JPG", "PNG", "webp", "gif",
|
|
||||||
];
|
|
||||||
let audio_filters = ["mp3", "opus", "ogg", "flac", "wav"];
|
|
||||||
let title = title.to_string();
|
|
||||||
let filter = filter.to_string();
|
|
||||||
let mut file = FileDialog::new().set_title(title);
|
|
||||||
match filter.as_str() {
|
|
||||||
"video" => {
|
|
||||||
file = file.add_filter(filter, &video_filters);
|
|
||||||
}
|
|
||||||
"image" => {
|
|
||||||
file = file.add_filter(filter, &image_filters);
|
|
||||||
}
|
|
||||||
"audio" => {
|
|
||||||
file = file.add_filter(filter, &audio_filters);
|
|
||||||
}
|
|
||||||
_ => debug!("nothing"),
|
|
||||||
};
|
|
||||||
let file = file.pick_file();
|
|
||||||
if let Some(file) = file {
|
|
||||||
println!("loading-file: {:?}", file);
|
|
||||||
let mut string =
|
|
||||||
String::from(file.to_str().unwrap_or(""));
|
|
||||||
if string.is_empty() {
|
|
||||||
QUrl::default()
|
QUrl::default()
|
||||||
} else {
|
|
||||||
string.insert_str(0, "file://");
|
|
||||||
QUrl::from(string.as_str())
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
QUrl::default()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
mod slide_obj {
|
mod slide_obj {
|
||||||
|
// use cxx_qt_lib::QVariantValue;
|
||||||
|
// use std::path::Path;
|
||||||
|
// use std::task::Context;
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!("cxx-qt-lib/qstring.h");
|
include!("cxx-qt-lib/qstring.h");
|
||||||
type QString = cxx_qt_lib::QString;
|
type QString = cxx_qt_lib::QString;
|
||||||
|
@ -10,312 +14,294 @@ mod slide_obj {
|
||||||
type QVariant = cxx_qt_lib::QVariant;
|
type QVariant = cxx_qt_lib::QVariant;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "RustQt" {
|
#[cxx_qt::qsignals(SlideObj)]
|
||||||
#[qobject]
|
pub enum Signals<'a> {
|
||||||
#[qml_element]
|
PlayingChanged { is_playing: &'a bool },
|
||||||
#[qproperty(i32, slide_index)]
|
SlideIndexChanged { slide_index: &'a i32 },
|
||||||
#[qproperty(i32, slide_size)]
|
SlideSizeChanged { slide_size: &'a i32 },
|
||||||
#[qproperty(i32, image_count)]
|
SlideChanged { slide: &'a i32 },
|
||||||
#[qproperty(bool, is_playing)]
|
LoopChanged { looping: &'a bool },
|
||||||
#[qproperty(bool, looping)]
|
}
|
||||||
#[qproperty(QString, text)]
|
|
||||||
#[qproperty(QString, ty)]
|
|
||||||
#[qproperty(QString, audio)]
|
|
||||||
#[qproperty(QString, image_background)]
|
|
||||||
#[qproperty(QString, video_background)]
|
|
||||||
#[qproperty(QString, html)]
|
|
||||||
#[qproperty(QString, vtext_alignment)]
|
|
||||||
#[qproperty(QString, htext_alignment)]
|
|
||||||
#[qproperty(QString, font)]
|
|
||||||
#[qproperty(i32, font_size)]
|
|
||||||
#[qproperty(f32, video_start_time)]
|
|
||||||
#[qproperty(f32, video_end_time)]
|
|
||||||
type SlideObj = super::SlideObjectRust;
|
|
||||||
|
|
||||||
#[qsignal]
|
#[derive(Clone, Debug)]
|
||||||
fn playing_changed(
|
#[cxx_qt::qobject]
|
||||||
self: Pin<&mut SlideObj>,
|
pub struct SlideObj {
|
||||||
is_playing: bool,
|
#[qproperty]
|
||||||
);
|
slide_index: i32,
|
||||||
#[qsignal]
|
#[qproperty]
|
||||||
fn slide_index_changed(
|
slide_size: i32,
|
||||||
self: Pin<&mut SlideObj>,
|
#[qproperty]
|
||||||
slide_index: i32,
|
image_count: i32,
|
||||||
);
|
#[qproperty]
|
||||||
#[qsignal]
|
is_playing: bool,
|
||||||
fn slide_size_changed(
|
#[qproperty]
|
||||||
self: Pin<&mut SlideObj>,
|
looping: bool,
|
||||||
slide_size: i32,
|
#[qproperty]
|
||||||
);
|
text: QString,
|
||||||
#[qsignal]
|
#[qproperty]
|
||||||
fn slide_changed(self: Pin<&mut SlideObj>, slide: i32);
|
ty: QString,
|
||||||
#[qsignal]
|
#[qproperty]
|
||||||
fn loop_changed(self: Pin<&mut SlideObj>, looping: bool);
|
audio: QString,
|
||||||
|
#[qproperty]
|
||||||
|
image_background: QString,
|
||||||
|
#[qproperty]
|
||||||
|
video_background: QString,
|
||||||
|
#[qproperty]
|
||||||
|
html: QString,
|
||||||
|
#[qproperty]
|
||||||
|
vtext_alignment: QString,
|
||||||
|
#[qproperty]
|
||||||
|
htext_alignment: QString,
|
||||||
|
#[qproperty]
|
||||||
|
font: QString,
|
||||||
|
#[qproperty]
|
||||||
|
font_size: i32,
|
||||||
|
#[qproperty]
|
||||||
|
video_start_time: f32,
|
||||||
|
#[qproperty]
|
||||||
|
video_end_time: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for SlideObj {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
slide_index: 0,
|
||||||
|
slide_size: 0,
|
||||||
|
is_playing: false,
|
||||||
|
looping: false,
|
||||||
|
text: QString::from(""),
|
||||||
|
ty: QString::from(""),
|
||||||
|
audio: QString::from(""),
|
||||||
|
image_background: QString::from(""),
|
||||||
|
html: QString::from(""),
|
||||||
|
video_background: QString::from(""),
|
||||||
|
vtext_alignment: QString::from(""),
|
||||||
|
htext_alignment: QString::from(""),
|
||||||
|
font: QString::from(""),
|
||||||
|
font_size: 50,
|
||||||
|
image_count: 0,
|
||||||
|
video_start_time: 0.0,
|
||||||
|
video_end_time: 0.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl qobject::SlideObj {
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn change_slide(
|
pub fn change_slide(
|
||||||
self: Pin<&mut SlideObj>,
|
mut self: Pin<&mut Self>,
|
||||||
item: QMap_QString_QVariant,
|
item: QMap_QString_QVariant,
|
||||||
index: i32,
|
index: i32,
|
||||||
);
|
) {
|
||||||
#[qinvokable]
|
println!("## Slide Details ##");
|
||||||
fn next(
|
let text = item
|
||||||
self: Pin<&mut SlideObj>,
|
.get(&QString::from("text"))
|
||||||
next_item: QMap_QString_QVariant,
|
.unwrap_or(QVariant::from(&QString::from("")));
|
||||||
) -> bool;
|
if let Some(txt) = text.value::<QString>() {
|
||||||
#[qinvokable]
|
if &txt != self.as_ref().text() {
|
||||||
fn previous(
|
println!("text: {txt}");
|
||||||
self: Pin<&mut SlideObj>,
|
self.as_mut().set_text(txt);
|
||||||
prev_item: QMap_QString_QVariant,
|
};
|
||||||
) -> bool;
|
} else {
|
||||||
#[qinvokable]
|
println!("text: empty");
|
||||||
fn play(self: Pin<&mut SlideObj>) -> bool;
|
}
|
||||||
#[qinvokable]
|
let audio = item
|
||||||
fn pause(self: Pin<&mut SlideObj>) -> bool;
|
.get(&QString::from("audio"))
|
||||||
#[qinvokable]
|
.unwrap_or(QVariant::from(&QString::from("")));
|
||||||
fn play_pause(self: Pin<&mut SlideObj>) -> bool;
|
if let Some(audio) = audio.value::<QString>() {
|
||||||
|
if &audio != self.as_ref().audio() {
|
||||||
|
println!("audio: {audio}");
|
||||||
|
self.as_mut().set_audio(audio);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("audio: empty");
|
||||||
|
}
|
||||||
|
let ty = item
|
||||||
|
.get(&QString::from("type"))
|
||||||
|
.unwrap_or(QVariant::from(&QString::from("")));
|
||||||
|
if let Some(ty) = ty.value::<QString>() {
|
||||||
|
if &ty != self.as_ref().ty() {
|
||||||
|
println!("type: {ty}");
|
||||||
|
self.as_mut().set_ty(ty);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("type: empty");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
let image_background = item
|
||||||
}
|
.get(&QString::from("imageBackground"))
|
||||||
|
.unwrap_or(QVariant::from(&QString::from("")));
|
||||||
#[derive(Clone, Debug)]
|
if let Some(image_background) =
|
||||||
pub struct SlideObjectRust {
|
image_background.value::<QString>()
|
||||||
slide_index: i32,
|
{
|
||||||
slide_size: i32,
|
if &image_background
|
||||||
image_count: i32,
|
!= self.as_ref().image_background()
|
||||||
is_playing: bool,
|
{
|
||||||
looping: bool,
|
println!("image-bg: {image_background}");
|
||||||
text: QString,
|
self.as_mut()
|
||||||
ty: QString,
|
.set_image_background(image_background);
|
||||||
audio: QString,
|
}
|
||||||
image_background: QString,
|
} else {
|
||||||
video_background: QString,
|
println!("image-bg: empty");
|
||||||
html: QString,
|
}
|
||||||
vtext_alignment: QString,
|
let video_background = item
|
||||||
htext_alignment: QString,
|
.get(&QString::from("videoBackground"))
|
||||||
font: QString,
|
.unwrap_or(QVariant::from(&QString::from("")));
|
||||||
font_size: i32,
|
if let Some(video_background) =
|
||||||
video_start_time: f32,
|
video_background.value::<QString>()
|
||||||
video_end_time: f32,
|
{
|
||||||
}
|
if &video_background
|
||||||
|
!= self.as_ref().video_background()
|
||||||
impl Default for SlideObjectRust {
|
{
|
||||||
fn default() -> Self {
|
println!("video-bg: {video_background}");
|
||||||
Self {
|
self.as_mut()
|
||||||
slide_index: 0,
|
.set_video_background(video_background);
|
||||||
slide_size: 0,
|
}
|
||||||
is_playing: false,
|
} else {
|
||||||
looping: false,
|
println!("video-bg: empty");
|
||||||
text: QString::from(""),
|
}
|
||||||
ty: QString::from(""),
|
let font = item.get(&QString::from("font")).unwrap_or(
|
||||||
audio: QString::from(""),
|
QVariant::from(&QString::from("Quicksand")),
|
||||||
image_background: QString::from(""),
|
);
|
||||||
html: QString::from(""),
|
if let Some(font) = font.value::<QString>() {
|
||||||
video_background: QString::from(""),
|
if &font != self.as_ref().font() {
|
||||||
vtext_alignment: QString::from(""),
|
println!("font: {font}");
|
||||||
htext_alignment: QString::from(""),
|
self.as_mut().set_font(font);
|
||||||
font: QString::from(""),
|
}
|
||||||
font_size: 50,
|
} else {
|
||||||
image_count: 0,
|
println!("font: empty");
|
||||||
video_start_time: 0.0,
|
}
|
||||||
video_end_time: 0.0,
|
let vtext_alignment = item
|
||||||
}
|
.get(&QString::from("verticalTextAlignment"))
|
||||||
}
|
.unwrap_or(QVariant::from(&QString::from("center")));
|
||||||
}
|
if let Some(vtext_alignment) =
|
||||||
|
vtext_alignment.value::<QString>()
|
||||||
impl ffi::SlideObjectRust {
|
{
|
||||||
pub fn change_slide(
|
if &vtext_alignment != self.as_ref().vtext_alignment()
|
||||||
mut self: Pin<&mut Self>,
|
{
|
||||||
item: QMap_QString_QVariant,
|
println!(
|
||||||
index: i32,
|
"vertical-text-align: {vtext_alignment}"
|
||||||
) {
|
);
|
||||||
println!("## Slide Details ##");
|
self.as_mut()
|
||||||
let text = item
|
.set_vtext_alignment(vtext_alignment);
|
||||||
.get(&QString::from("text"))
|
}
|
||||||
.unwrap_or(QVariant::from(&QString::from("")));
|
} else {
|
||||||
if let Some(txt) = text.value::<QString>() {
|
println!("vertical-text-align: empty");
|
||||||
if &txt != self.as_ref().text() {
|
}
|
||||||
println!("text: {txt}");
|
let htext_alignment = item
|
||||||
self.as_mut().set_text(txt);
|
.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);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("horizontal-text-align: empty");
|
||||||
|
}
|
||||||
|
let font_size = item
|
||||||
|
.get(&QString::from("fontSize"))
|
||||||
|
.unwrap_or(QVariant::from(&50));
|
||||||
|
if let Some(font_size) = font_size.value::<i32>() {
|
||||||
|
if &font_size != self.as_ref().font_size() {
|
||||||
|
println!("font-size: {font_size}");
|
||||||
|
self.as_mut().set_font_size(font_size);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("font-size: empty");
|
||||||
|
}
|
||||||
|
let looping = item
|
||||||
|
.get(&QString::from("looping"))
|
||||||
|
.unwrap_or(QVariant::from(&false));
|
||||||
|
if let Some(looping) = looping.value::<bool>() {
|
||||||
|
if &looping != self.as_ref().looping() {
|
||||||
|
println!("looping: {looping}");
|
||||||
|
self.as_mut().set_looping(looping);
|
||||||
|
let lp = looping;
|
||||||
|
self.as_mut()
|
||||||
|
.emit(Signals::LoopChanged { looping: &lp });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("looping: empty")
|
||||||
|
}
|
||||||
|
let slide_size = item
|
||||||
|
.get(&QString::from("slide_size"))
|
||||||
|
.unwrap_or(QVariant::from(&1));
|
||||||
|
if let Some(slide_size) = slide_size.value::<i32>() {
|
||||||
|
if &slide_size != self.as_ref().slide_size() {
|
||||||
|
println!("slide-size: {slide_size}");
|
||||||
|
self.as_mut().set_slide_size(slide_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let video_start_time = item
|
||||||
|
.get(&QString::from("videoStartTime"))
|
||||||
|
.unwrap_or(QVariant::from(&0.0));
|
||||||
|
if let Some(int) = video_start_time.value::<f32>() {
|
||||||
|
self.as_mut().set_video_start_time(int)
|
||||||
|
}
|
||||||
|
let icount = item
|
||||||
|
.get(&QString::from("imageCount"))
|
||||||
|
.unwrap_or(QVariant::from(&1));
|
||||||
|
if let Some(int) = icount.value::<i32>() {
|
||||||
|
self.as_mut().set_image_count(int);
|
||||||
|
}
|
||||||
|
let slindex = item
|
||||||
|
.get(&QString::from("slideIndex"))
|
||||||
|
.unwrap_or(QVariant::from(&0));
|
||||||
|
if let Some(int) = slindex.value::<i32>() {
|
||||||
|
println!("New slide index = {}", int);
|
||||||
|
self.as_mut().set_slide_index(int);
|
||||||
};
|
};
|
||||||
} else {
|
self.as_mut()
|
||||||
println!("text: empty");
|
.emit(Signals::SlideChanged { slide: &index });
|
||||||
}
|
println!("## Slide End ##");
|
||||||
let audio = item
|
|
||||||
.get(&QString::from("audio"))
|
|
||||||
.unwrap_or(QVariant::from(&QString::from("")));
|
|
||||||
if let Some(audio) = audio.value::<QString>() {
|
|
||||||
if &audio != self.as_ref().audio() {
|
|
||||||
println!("audio: {audio}");
|
|
||||||
self.as_mut().set_audio(audio);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println!("audio: empty");
|
|
||||||
}
|
|
||||||
let ty = item
|
|
||||||
.get(&QString::from("type"))
|
|
||||||
.unwrap_or(QVariant::from(&QString::from("")));
|
|
||||||
if let Some(ty) = ty.value::<QString>() {
|
|
||||||
if &ty != self.as_ref().ty() {
|
|
||||||
println!("type: {ty}");
|
|
||||||
self.as_mut().set_ty(ty);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println!("type: empty");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let image_background = item
|
#[qinvokable]
|
||||||
.get(&QString::from("imageBackground"))
|
pub fn next(
|
||||||
.unwrap_or(QVariant::from(&QString::from("")));
|
mut self: Pin<&mut Self>,
|
||||||
if let Some(image_background) =
|
next_item: QMap_QString_QVariant,
|
||||||
image_background.value::<QString>()
|
) -> bool {
|
||||||
{
|
let new_id = self.as_ref().slide_index() + 1;
|
||||||
if &image_background != self.as_ref().image_background() {
|
self.as_mut().change_slide(next_item, new_id);
|
||||||
println!("image-bg: {image_background}");
|
true
|
||||||
self.as_mut().set_image_background(image_background);
|
}
|
||||||
|
#[qinvokable]
|
||||||
|
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
|
||||||
|
}
|
||||||
|
#[qinvokable]
|
||||||
|
pub fn play(mut self: Pin<&mut Self>) -> bool {
|
||||||
|
self.as_mut().set_is_playing(true);
|
||||||
|
self.as_mut().emit_playing_changed(&true);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
#[qinvokable]
|
||||||
|
pub fn pause(mut self: Pin<&mut Self>) -> bool {
|
||||||
|
self.as_mut().set_is_playing(false);
|
||||||
|
self.as_mut().emit_playing_changed(&false);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
#[qinvokable]
|
||||||
|
pub fn play_pause(mut self: Pin<&mut Self>) -> bool {
|
||||||
|
let playing = self.as_ref().is_playing().clone();
|
||||||
|
match playing {
|
||||||
|
true => self.as_mut().set_is_playing(false),
|
||||||
|
false => self.as_mut().set_is_playing(true),
|
||||||
}
|
}
|
||||||
} else {
|
self.as_mut().emit_playing_changed(&!playing);
|
||||||
println!("image-bg: empty");
|
!playing
|
||||||
}
|
}
|
||||||
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() {
|
|
||||||
println!("video-bg: {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")));
|
|
||||||
if let Some(font) = font.value::<QString>() {
|
|
||||||
if &font != self.as_ref().font() {
|
|
||||||
println!("font: {font}");
|
|
||||||
self.as_mut().set_font(font);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println!("font: empty");
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println!("vertical-text-align: empty");
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println!("horizontal-text-align: empty");
|
|
||||||
}
|
|
||||||
let font_size = item
|
|
||||||
.get(&QString::from("fontSize"))
|
|
||||||
.unwrap_or(QVariant::from(&50));
|
|
||||||
if let Some(font_size) = font_size.value::<i32>() {
|
|
||||||
if &font_size != self.as_ref().font_size() {
|
|
||||||
println!("font-size: {font_size}");
|
|
||||||
self.as_mut().set_font_size(font_size);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println!("font-size: empty");
|
|
||||||
}
|
|
||||||
let looping = item
|
|
||||||
.get(&QString::from("looping"))
|
|
||||||
.unwrap_or(QVariant::from(&false));
|
|
||||||
if let Some(looping) = looping.value::<bool>() {
|
|
||||||
if &looping != self.as_ref().looping() {
|
|
||||||
println!("looping: {looping}");
|
|
||||||
self.as_mut().set_looping(looping);
|
|
||||||
let lp = looping;
|
|
||||||
self.as_mut().loop_changed(&lp);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println!("looping: empty")
|
|
||||||
}
|
|
||||||
let slide_size = item
|
|
||||||
.get(&QString::from("slide_size"))
|
|
||||||
.unwrap_or(QVariant::from(&1));
|
|
||||||
if let Some(slide_size) = slide_size.value::<i32>() {
|
|
||||||
if &slide_size != self.as_ref().slide_size() {
|
|
||||||
println!("slide-size: {slide_size}");
|
|
||||||
self.as_mut().set_slide_size(slide_size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let video_start_time = item
|
|
||||||
.get(&QString::from("videoStartTime"))
|
|
||||||
.unwrap_or(QVariant::from(&0.0));
|
|
||||||
if let Some(int) = video_start_time.value::<f32>() {
|
|
||||||
self.as_mut().set_video_start_time(int)
|
|
||||||
}
|
|
||||||
let icount = item
|
|
||||||
.get(&QString::from("imageCount"))
|
|
||||||
.unwrap_or(QVariant::from(&1));
|
|
||||||
if let Some(int) = icount.value::<i32>() {
|
|
||||||
self.as_mut().set_image_count(int);
|
|
||||||
}
|
|
||||||
let slindex = item
|
|
||||||
.get(&QString::from("slideIndex"))
|
|
||||||
.unwrap_or(QVariant::from(&0));
|
|
||||||
if let Some(int) = slindex.value::<i32>() {
|
|
||||||
println!("New slide index = {}", int);
|
|
||||||
self.as_mut().set_slide_index(int);
|
|
||||||
};
|
|
||||||
self.as_mut().slide_changed(&index);
|
|
||||||
println!("## Slide End ##");
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
|
||||||
pub fn play(mut self: Pin<&mut Self>) -> bool {
|
|
||||||
self.as_mut().set_is_playing(true);
|
|
||||||
self.as_mut().playing_changed(&true);
|
|
||||||
true
|
|
||||||
}
|
|
||||||
pub fn pause(mut self: Pin<&mut Self>) -> bool {
|
|
||||||
self.as_mut().set_is_playing(false);
|
|
||||||
self.as_mut().playing_changed(&false);
|
|
||||||
false
|
|
||||||
}
|
|
||||||
pub fn play_pause(mut self: Pin<&mut Self>) -> bool {
|
|
||||||
let playing = self.as_ref().is_playing().clone();
|
|
||||||
match playing {
|
|
||||||
true => self.as_mut().set_is_playing(false),
|
|
||||||
false => self.as_mut().set_is_playing(true),
|
|
||||||
}
|
|
||||||
self.as_mut().playing_changed(&!playing);
|
|
||||||
!playing
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue