Projects: Inital support for saving and loading projects #22

Merged
cody merged 17 commits from topic/jb/project-files into main 2025-04-05 19:56:33 +00:00
4 changed files with 17 additions and 5 deletions
Showing only changes of commit d42fe2776c - Show all commits

View File

@ -3677,9 +3677,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.137"
version = "1.0.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b"
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
dependencies = [
"itoa",
"memchr",
@ -4113,6 +4113,8 @@ version = "0.1.0"
dependencies = [
"png",
"rfd",
"serde",
"serde_json",
"slint",
"slint-build",
"tiny-skia",

View File

@ -11,6 +11,8 @@ png = "0.17.16"
rfd = "0.15.2"
slint = "1.9.2"
tiny-skia = "0.11.4"
serde = {version = "1.0.140", features = ["derive"]}
serde_json = "1.0"
tool_helper = {path = "../tool_helper"}
[build-dependencies]

View File

@ -95,7 +95,14 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
project.push(cur_job);
}
Err(Error::from_text(format!("Adding {:?} jobs", project)))
let string = match serde_json::to_string(&project) {
Ok(string) => string,
Err(error) => {
return Err(Error::from_error(error));
}
};
Err(Error::from_text(format!("Adding {} jobs", string)))
}
}

View File

@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
pub struct Job {
name: String,
file_path: PathBuf,
@ -12,7 +13,7 @@ impl Job {
}
}
#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
pub struct Project {
jobs: Vec<Job>
}