adding the save function working and adding to service items better
This commit is contained in:
parent
258949ae50
commit
8031c32a18
2 changed files with 44 additions and 14 deletions
|
@ -72,7 +72,7 @@ Item {
|
||||||
onEntered: (drag) => {
|
onEntered: (drag) => {
|
||||||
if (drag.keys[0] === "library") {
|
if (drag.keys[0] === "library") {
|
||||||
dropHighlightLine.visible = true;
|
dropHighlightLine.visible = true;
|
||||||
var lastItem = serviceItemList.itemAtIndex(ServiceItemModel.rowCount() - 1);
|
var lastItem = serviceItemList.itemAtIndex(ServiceItemModel.count() - 1);
|
||||||
dropHighlightLine.y = lastItem.y + lastItem.height;
|
dropHighlightLine.y = lastItem.y + lastItem.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -559,7 +559,7 @@ Item {
|
||||||
ServiceItemModel.insertItem(index, image.title,
|
ServiceItemModel.insertItem(index, image.title,
|
||||||
type, image.filePath,
|
type, image.filePath,
|
||||||
"image", "", "",
|
"image", "", "",
|
||||||
"", 0, 0, false);
|
"", 0, 0, false, 0.0, 0.0);
|
||||||
serviceItemList.forceLayout()
|
serviceItemList.forceLayout()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -569,7 +569,7 @@ Item {
|
||||||
ServiceItemModel.insertItem(index, video.title,
|
ServiceItemModel.insertItem(index, video.title,
|
||||||
type, video.filePath,
|
type, video.filePath,
|
||||||
"video", "", "",
|
"video", "", "",
|
||||||
"", 0, 0, video.loop);
|
"", 0, 0, video.loop, video.startTime, video.endTime);
|
||||||
serviceItemList.forceLayout()
|
serviceItemList.forceLayout()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -584,7 +584,7 @@ Item {
|
||||||
type, song.background,
|
type, song.background,
|
||||||
song.backgroundType, lyrics,
|
song.backgroundType, lyrics,
|
||||||
song.audio, song.font, song.fontSize,
|
song.audio, song.font, song.fontSize,
|
||||||
lyrics.length, true);
|
lyrics.length, true, 0.0, 0.0);
|
||||||
serviceItemList.forceLayout()
|
serviceItemList.forceLayout()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -596,7 +596,7 @@ Item {
|
||||||
ServiceItemModel.insertItem(index, pres.title,
|
ServiceItemModel.insertItem(index, pres.title,
|
||||||
type, pres.filePath,
|
type, pres.filePath,
|
||||||
"image", "",
|
"image", "",
|
||||||
"", "", 0, pres.pageCount, false);
|
"", "", 0, pres.pageCount, false, 0.0, 0.0);
|
||||||
serviceItemList.forceLayout()
|
serviceItemList.forceLayout()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -614,7 +614,7 @@ Item {
|
||||||
ServiceItemModel.addItem(image.title,
|
ServiceItemModel.addItem(image.title,
|
||||||
type, image.filePath,
|
type, image.filePath,
|
||||||
"image", "", "",
|
"image", "", "",
|
||||||
"", 0, 0, false);
|
"", 0, 0, false, 0.0, 0.0);
|
||||||
serviceItemList.forceLayout()
|
serviceItemList.forceLayout()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,7 @@ Item {
|
||||||
ServiceItemModel.addItem(video.title,
|
ServiceItemModel.addItem(video.title,
|
||||||
type, video.filePath,
|
type, video.filePath,
|
||||||
"video", "", "",
|
"video", "", "",
|
||||||
"", 0, 0, video.loop);
|
"", 0, 0, video.loop, video.startTime, video.endTime);
|
||||||
serviceItemList.forceLayout()
|
serviceItemList.forceLayout()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -638,7 +638,7 @@ Item {
|
||||||
type, song.background,
|
type, song.background,
|
||||||
song.backgroundType, lyrics,
|
song.backgroundType, lyrics,
|
||||||
song.audio, song.font, song.fontSize,
|
song.audio, song.font, song.fontSize,
|
||||||
lyrics.length, true);
|
lyrics.length, true, 0.0, 0.0);
|
||||||
serviceItemList.forceLayout()
|
serviceItemList.forceLayout()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -651,7 +651,7 @@ Item {
|
||||||
type, pres.filePath,
|
type, pres.filePath,
|
||||||
"image", "",
|
"image", "",
|
||||||
"", "", 0, pres.pageCount,
|
"", "", 0, pres.pageCount,
|
||||||
false);
|
false, 0.0, 0.0);
|
||||||
serviceItemList.forceLayout()
|
serviceItemList.forceLayout()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -487,9 +487,9 @@ mod service_item_model {
|
||||||
}
|
}
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
pub fn save(mut self: Pin<&mut Self>, file: QUrl) -> bool {
|
pub fn save(mut self: Pin<&mut Self>, file: QUrl) -> bool {
|
||||||
println!("file is: {file}");
|
println!("rust-save-file: {file}");
|
||||||
let lfr = fs::File::open(
|
let lfr = fs::File::create(
|
||||||
file.to_local_file().unwrap_or_default().to_string(),
|
&file.to_local_file().unwrap_or_default().to_string(),
|
||||||
);
|
);
|
||||||
if let Ok(lf) = &lfr {
|
if let Ok(lf) = &lfr {
|
||||||
println!("archive: {:?}", lf);
|
println!("archive: {:?}", lf);
|
||||||
|
@ -502,8 +502,36 @@ mod service_item_model {
|
||||||
let text_list = QList_QString::from(&item.text);
|
let text_list = QList_QString::from(&item.text);
|
||||||
let mut text_vec = Vec::<String>::default();
|
let mut text_vec = Vec::<String>::default();
|
||||||
|
|
||||||
let flat_background = item.background.to_string();
|
let flat_background_path =
|
||||||
let flat_audio = item.audio.to_string();
|
PathBuf::from(item.background.to_string());
|
||||||
|
let flat_background_name =
|
||||||
|
flat_background_path.file_name();
|
||||||
|
let flat_background;
|
||||||
|
match flat_background_name {
|
||||||
|
Some(name) => {
|
||||||
|
flat_background = name.to_str().unwrap()
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
println!(
|
||||||
|
"save-background: no background"
|
||||||
|
);
|
||||||
|
flat_background = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let flat_audio_path =
|
||||||
|
PathBuf::from(item.audio.to_string());
|
||||||
|
let flat_audio_name = flat_audio_path.file_name();
|
||||||
|
let flat_audio;
|
||||||
|
match flat_audio_name {
|
||||||
|
Some(name) => {
|
||||||
|
flat_audio = name.to_str().unwrap()
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
println!("save-audio: no audio");
|
||||||
|
flat_audio = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (index, line) in text_list.iter().enumerate()
|
for (index, line) in text_list.iter().enumerate()
|
||||||
{
|
{
|
||||||
|
@ -522,9 +550,11 @@ mod service_item_model {
|
||||||
"loop".to_owned(): Value::from(item.looping),
|
"loop".to_owned(): Value::from(item.looping),
|
||||||
"slideNumber".to_owned(): Value::from(item.slide_count),
|
"slideNumber".to_owned(): Value::from(item.slide_count),
|
||||||
"text".to_owned(): Value::from(text_vec)});
|
"text".to_owned(): Value::from(text_vec)});
|
||||||
|
println!("{service_json}");
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
println!("rust-save-file-failed: {:?}", lfr);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue