Adding egui directly and log
This commit is contained in:
parent
ef751e5cb8
commit
7f8c215227
2 changed files with 19 additions and 2 deletions
|
|
@ -6,7 +6,10 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
egui = {version = "0.32.3", features = ["log"]}
|
||||
eframe = { version = "0.32.3" }
|
||||
log = "0.4.28"
|
||||
colog = "1.4.0"
|
||||
rfd = "*"
|
||||
json = "*"
|
||||
serde = { version = "*", features = ["derive"] }
|
||||
|
|
|
|||
18
src/main.rs
18
src/main.rs
|
|
@ -2,10 +2,12 @@ use std::path::PathBuf;
|
|||
|
||||
use eframe::egui;
|
||||
use eframe::egui::KeyboardShortcut;
|
||||
use log::{info, warn, error};
|
||||
|
||||
use billy_sheet::gui::SheetGui;
|
||||
|
||||
fn main() -> eframe::Result {
|
||||
colog::init();
|
||||
let options = eframe::NativeOptions {
|
||||
viewport: egui::ViewportBuilder::default().with_drag_and_drop(true),
|
||||
..Default::default()
|
||||
|
|
@ -54,7 +56,7 @@ impl eframe::App for Gui {
|
|||
if ui.button("Save in json").clicked() {
|
||||
let path = std::path::Path::new("./sheet.json");
|
||||
if let Err(error) = billy_sheet::sheet::write_sheet(path, &self.sheet) {
|
||||
println!("{error}");
|
||||
error!("{error}");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -99,7 +101,19 @@ impl eframe::App for Gui {
|
|||
}
|
||||
});
|
||||
if let Some(file_path) = &self.picked_path {
|
||||
println!("{}", file_path.to_str().unwrap_or_default());
|
||||
if let Some(extension) = file_path.extension() {
|
||||
info!("File selected : {}", file_path.display());
|
||||
if extension == "json" {
|
||||
info!("File has json extension");
|
||||
} else {
|
||||
warn!(
|
||||
"File has not .json: {}",
|
||||
extension.to_str().unwrap_or_default()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
error!("No extension for the file.");
|
||||
}
|
||||
self.picked_path = None;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue