adding some loading mechanics
This commit is contained in:
parent
bfa3f7280c
commit
bc3024434e
1 changed files with 26 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
mod service_item_model {
|
mod service_item_model {
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
|
@ -23,7 +24,7 @@ mod service_item_model {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cxx_qt::qobject]
|
#[cxx_qt::qobject]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct ServiceItm {
|
pub struct ServiceItm {
|
||||||
#[qproperty]
|
#[qproperty]
|
||||||
name: QString,
|
name: QString,
|
||||||
|
@ -133,10 +134,13 @@ mod service_item_model {
|
||||||
// use crate::video_thumbnail;
|
// use crate::video_thumbnail;
|
||||||
// use image::{ImageBuffer, Rgba};
|
// use image::{ImageBuffer, Rgba};
|
||||||
use dirs;
|
use dirs;
|
||||||
|
use serde_json::{Deserializer, Serializer, Value};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Read, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::str;
|
use std::str;
|
||||||
|
use tar::{Archive, Builder};
|
||||||
|
use zstd::{Decoder, Encoder};
|
||||||
impl qobject::ServiceItemMod {
|
impl qobject::ServiceItemMod {
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
pub fn clear(mut self: Pin<&mut Self>) {
|
pub fn clear(mut self: Pin<&mut Self>) {
|
||||||
|
@ -351,8 +355,27 @@ mod service_item_model {
|
||||||
pub fn load(mut self: Pin<&mut Self>, file: QUrl) -> bool {
|
pub fn load(mut self: Pin<&mut Self>, file: QUrl) -> bool {
|
||||||
// todo!();
|
// todo!();
|
||||||
println!("THE LAST SAVE FILE ISSSSS: {file}");
|
println!("THE LAST SAVE FILE ISSSSS: {file}");
|
||||||
let lf = PathBuf::from(file.to_local_file().unwrap_or_default().to_string());
|
let lf = fs::File::open(file.to_local_file().unwrap_or_default().to_string()).unwrap();
|
||||||
println!("{:?}", lf);
|
println!("{:?}", lf);
|
||||||
|
let dec = Decoder::new(lf).unwrap();
|
||||||
|
let mut tar = Archive::new(dec);
|
||||||
|
for file in tar.entries().unwrap() {
|
||||||
|
let mut file = file.unwrap();
|
||||||
|
// Inspect metadata about the file
|
||||||
|
println!("{:?}", file.header().path().unwrap());
|
||||||
|
println!("{:?}", file.header().size().unwrap());
|
||||||
|
|
||||||
|
if file.header().path().unwrap().to_str().unwrap() == "servicelist.json" {
|
||||||
|
println!("THIS ONE HERE CAPTAIN!");
|
||||||
|
|
||||||
|
let mut s = String::new();
|
||||||
|
file.read_to_string(&mut s);
|
||||||
|
println!("{:?}", s);
|
||||||
|
let ds: Value = serde_json::from_str(&s).unwrap();
|
||||||
|
println!("{:?}", ds);
|
||||||
|
}
|
||||||
|
// // files implement the Read trait
|
||||||
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue