Skip to content

Commit

Permalink
add download functionality of datasheets
Browse files Browse the repository at this point in the history
  • Loading branch information
markusdd committed Mar 11, 2024
1 parent f95d57d commit 2d344df
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
65 changes: 65 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ subprocess = "0.2.9"
serde_json = "1.0.114"
regex = "1.10.3"
indexmap = "2.2.5"
downloader = "0.2.7"

# You only need serde if you want app persistence:
serde = { version = "1", features = ["derive"] }
Expand Down
20 changes: 19 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use std::{fs::create_dir_all, path::Path};

use downloader::{Download, Downloader};
use egui::{TextEdit, Vec2, Window};
use egui_extras::{Column, TableBuilder};
use indexmap::{indexmap, IndexMap};
Expand Down Expand Up @@ -300,7 +303,22 @@ impl eframe::App for MyApp {
if self.no_symbol {
args.push("--no_symbol");
}
Exec::cmd(&self.exe_path).args(&args).popen();
let _ = Exec::cmd(&self.exe_path).args(&args).popen();
if self.download_datasheet {
let dlpath = Path::new(&self.datasheet_dir);
if !dlpath.is_dir() {
let _ = create_dir_all(dlpath);
}
if let Some(url) = self.current_part.get("meta_datasheeturl") {
let dl = Downloader::builder()
.download_folder(&dlpath)

Check failure on line 314 in src/app.rs

View workflow job for this annotation

GitHub Actions / Clippy

this expression creates a reference which is immediately dereferenced by the compiler
.build()
.ok();
if let Some(mut dl) = dl {
let _ = dl.download(&[Download::new(url)]);
}
}
}
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() -> eframe::Result<()> {

let native_options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_inner_size([1024.0, 768.0])
.with_inner_size([1024.0, 1000.0])
.with_min_inner_size([300.0, 220.0])
.with_title("EasyEDA to KiCAD Library UI")
.with_icon(
Expand Down

0 comments on commit 2d344df

Please sign in to comment.