adding a SlideType enum that can parse from a string
This will start to allow us to have a much better data model for the slides and service items. They can have a type associated with them and parse which they are from this type.
This commit is contained in:
parent
0cac11cb89
commit
273dd76d23
4 changed files with 182 additions and 37 deletions
|
@ -310,13 +310,14 @@ use self::service_item_model::{
|
|||
QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32,
|
||||
ServiceRoles,
|
||||
};
|
||||
use crate::slide_types::SlideType;
|
||||
|
||||
use super::service_item_model::service_item_model::ServiceItemModel;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ServiceItem {
|
||||
name: QString,
|
||||
ty: QString,
|
||||
ty: SlideType,
|
||||
audio: QString,
|
||||
background: QString,
|
||||
background_type: QString,
|
||||
|
@ -329,21 +330,14 @@ pub struct ServiceItem {
|
|||
looping: bool,
|
||||
video_start_time: f32,
|
||||
video_end_time: f32,
|
||||
obs_scene: QString,
|
||||
id: i32,
|
||||
}
|
||||
|
||||
impl ServiceItem {
|
||||
fn debug(self) {
|
||||
debug!(?self);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ServiceItem {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: QString::default(),
|
||||
ty: QString::default(),
|
||||
ty: SlideType::Image,
|
||||
audio: QString::default(),
|
||||
background: QString::default(),
|
||||
background_type: QString::default(),
|
||||
|
@ -356,7 +350,6 @@ impl Default for ServiceItem {
|
|||
looping: false,
|
||||
video_start_time: 0.0,
|
||||
video_end_time: 0.0,
|
||||
obs_scene: QString::default(),
|
||||
id: 0,
|
||||
}
|
||||
}
|
||||
|
@ -455,7 +448,7 @@ impl service_item_model::ServiceItemModel {
|
|||
) {
|
||||
let service_item = ServiceItem {
|
||||
name,
|
||||
ty,
|
||||
ty: ty.try_into().unwrap(),
|
||||
text,
|
||||
background,
|
||||
background_type,
|
||||
|
@ -515,7 +508,7 @@ impl service_item_model::ServiceItemModel {
|
|||
) {
|
||||
let service_item = ServiceItem {
|
||||
name,
|
||||
ty,
|
||||
ty: ty.try_into().unwrap(),
|
||||
text,
|
||||
background,
|
||||
background_type,
|
||||
|
@ -841,7 +834,8 @@ impl service_item_model::ServiceItemModel {
|
|||
debug!(activating_item = index,
|
||||
title = ?service_item.name,
|
||||
background = ?service_item.background,
|
||||
background_type = ?service_item.background_type);
|
||||
background_type = ?service_item.background_type,
|
||||
kind = ?service_item.ty);
|
||||
service_item.active = true;
|
||||
// if let Some(obs) = obs {
|
||||
// match obs
|
||||
|
@ -993,7 +987,7 @@ impl service_item_model::ServiceItemModel {
|
|||
}
|
||||
|
||||
let item_json = json!({"name".to_owned(): Value::from(item.name.to_string()),
|
||||
"type".to_owned(): Value::from(item.ty.to_string()),
|
||||
"type".to_owned(): Value::from(item.ty.clone().to_string()),
|
||||
"audio".to_owned(): Value::from(item.audio.to_string()),
|
||||
"background".to_owned(): Value::from(item.background.to_string()),
|
||||
"backgroundType".to_owned(): Value::from(item.background_type.to_string()),
|
||||
|
@ -1156,7 +1150,7 @@ impl service_item_model::ServiceItemModel {
|
|||
println!("size: {:?}", file.size());
|
||||
if !file_path.exists() {
|
||||
match file.unpack_in(&datadir) {
|
||||
Ok(t) => (),
|
||||
Ok(_t) => (),
|
||||
Err(e) => error!("Error unpacking archive: {}", e),
|
||||
}
|
||||
}
|
||||
|
@ -1326,25 +1320,46 @@ impl service_item_model::ServiceItemModel {
|
|||
.append(QString::from(txt.as_str().unwrap()));
|
||||
}
|
||||
let text = QStringList::from(&text_list);
|
||||
if let Ok(ty) = ty.try_into() {
|
||||
|
||||
let service_item = ServiceItem {
|
||||
name,
|
||||
ty,
|
||||
text,
|
||||
background,
|
||||
background_type,
|
||||
audio,
|
||||
font,
|
||||
font_size,
|
||||
slide_count,
|
||||
looping,
|
||||
video_start_time,
|
||||
video_end_time,
|
||||
..Default::default()
|
||||
};
|
||||
self.as_mut().add_service_item(&service_item);
|
||||
println!("Loaded Service: {:?}", ds);
|
||||
// // files implement the Read trait
|
||||
let service_item = ServiceItem {
|
||||
name,
|
||||
ty,
|
||||
text,
|
||||
background,
|
||||
background_type,
|
||||
audio,
|
||||
font,
|
||||
font_size,
|
||||
slide_count,
|
||||
looping,
|
||||
video_start_time,
|
||||
video_end_time,
|
||||
..Default::default()
|
||||
};
|
||||
self.as_mut().add_service_item(&service_item);
|
||||
println!("Loaded Service: {:?}", ds);
|
||||
// // files implement the Read trait
|
||||
} else {
|
||||
let service_item = ServiceItem {
|
||||
name,
|
||||
ty: SlideType::Content,
|
||||
text,
|
||||
background,
|
||||
background_type,
|
||||
audio,
|
||||
font,
|
||||
font_size,
|
||||
slide_count,
|
||||
looping,
|
||||
video_start_time,
|
||||
video_end_time,
|
||||
..Default::default()
|
||||
};
|
||||
self.as_mut().add_service_item(&service_item);
|
||||
error!("Loaded service item with generic type since it was an unknown type.");
|
||||
// // files implement the Read trait
|
||||
}
|
||||
}
|
||||
true
|
||||
} else {
|
||||
|
@ -1393,7 +1408,7 @@ impl service_item_model::ServiceItemModel {
|
|||
QVariant::from(&service_item.name)
|
||||
}
|
||||
ServiceRoles::Type => {
|
||||
QVariant::from(&service_item.ty)
|
||||
QVariant::from(&QString::from(&service_item.ty.clone().to_string()))
|
||||
}
|
||||
ServiceRoles::Audio => {
|
||||
QVariant::from(&service_item.audio)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue