Compare commits

...

2 Commits

6 changed files with 15 additions and 37 deletions

12
Cargo.lock generated
View File

@ -2456,17 +2456,6 @@ dependencies = [
"windows 0.37.0",
]
[[package]]
name = "ron"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "300a51053b1cb55c80b7a9fde4120726ddf25ca241a1cbb926626f62fb136bff"
dependencies = [
"base64",
"bitflags",
"serde",
]
[[package]]
name = "rustybeans"
version = "0.5.0"
@ -2484,7 +2473,6 @@ dependencies = [
"palette",
"plotly",
"rfd",
"ron",
"serde",
"serde_json",
"toml",

View File

@ -24,7 +24,6 @@ rfd = "0.10.0"
egui = { git = "https://github.com/emilk/egui", branch = "master" }
eframe = { git = "https://github.com/emilk/egui", branch = "master" }
ron = "0.8.0"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tracing-subscriber = "0.3"

View File

@ -1,9 +1,9 @@
use serde::{Deserialize, Serialize};
use serde::Deserialize;
use std::collections::HashMap;
use std::fs;
#[derive(Deserialize, Debug, Default, Serialize)]
#[derive(Deserialize, Debug, Default)]
pub struct Shot {
pub filename: Option<String>,
pub json: Option<String>,
@ -12,7 +12,7 @@ pub struct Shot {
pub disable: Option<bool>,
}
#[derive(Deserialize, Debug, Default, Serialize)]
#[derive(Deserialize, Debug, Default)]
pub struct Chart {
pub title: String,
pub shots: Vec<u64>,
@ -22,7 +22,7 @@ pub struct Chart {
pub max_flow: u64,
}
#[derive(Deserialize, Debug, Default, Serialize)]
#[derive(Deserialize, Debug, Default)]
pub struct Config {
pub shots: HashMap<String, Shot>,
pub charts: HashMap<String, Chart>,
@ -50,19 +50,12 @@ pub struct Data {
}
impl Config {
pub fn from_toml(path: &str) -> Self {
pub fn from_file(path: &str) -> Self {
let config_file = fs::read_to_string(&path).expect("Can't read config.toml");
toml::from_str(&config_file).expect("Can't deserialize config.toml")
}
pub fn from_ron(path: &str) -> Self {
let config_file = fs::read_to_string(&path).expect("Can't read config.ron");
let ron: Self = ron::from_str(&config_file).expect("Can't deserialize config.ron");
println!("{}", ron::to_string(&ron).unwrap());
ron
}
pub fn from_default() -> Self {
Self::from_ron("config.ron")
Self::from_file("config.toml")
}
}

View File

@ -24,8 +24,8 @@ fn main() -> Result<(), eframe::Error> {
// database_plot_selected_tui();
let options = eframe::NativeOptions {
drag_and_drop_support: true,
min_window_size: Some(egui::vec2(320.0, 100.0)),
initial_window_size: Some(egui::vec2(320.0, 240.0)),
min_window_size: Some(egui::vec2(640.0, 360.0)),
initial_window_size: Some(egui::vec2(640.0, 360.0)),
..Default::default()
};
eframe::run_native(

View File

@ -139,7 +139,7 @@ pub fn database_plot_entries(
if let Some(progress) = &progress {
let mut progress_lock = progress.lock().unwrap();
(*progress_lock).curr_name = brew.date_time_with_bean(&database);
(*progress_lock).current = i+1;
(*progress_lock).current = i + 1;
(*progress_lock).total = brews.len();
(*progress_lock).percentage += step_size;
}

View File

@ -105,7 +105,7 @@ impl eframe::App for Ui {
ctx.request_repaint();
}
// self.allowed_to_close = true;
self.allowed_to_close = true;
egui::TopBottomPanel::bottom("status_bar").show(ctx, |ui| {
ui.columns(2, |_columns| {});
});
@ -166,8 +166,10 @@ impl eframe::App for Ui {
if self.show_confirmation_dialog {
// Show confirmation dialog:
ui.with_layout(Layout::top_down_justified(Align::Center).with_main_align(Align::Center).with_cross_align(Align::Center), |ui| {
ui.separator();
ui.vertical(|ui| {
ui.label("Really quit?");
ui.horizontal(|ui| {
if ui.button("Yes").clicked() {
self.allowed_to_close = true;
frame.close();
@ -177,6 +179,7 @@ impl eframe::App for Ui {
self.modal = false;
self.show_confirmation_dialog = false;
}
});
});
}
});
@ -343,7 +346,7 @@ impl eframe::App for Ui {
let mut loading_data = LoadingData::default();
loading_data.config = Config::from_ron(&picked_path_owned);
loading_data.config = Config::from_file(&picked_path_owned);
loading_data.database =
Database::from_config(&loading_data.config);
@ -427,7 +430,6 @@ impl eframe::App for Ui {
if ui.button("Open file").clicked() {
if let Some(path) = FileDialog::new()
.add_filter("ron", &["ron"])
.add_filter("toml", &["toml"])
.set_directory(
match &env::current_dir() {
@ -442,10 +444,6 @@ impl eframe::App for Ui {
}
}
if ui.button("Open default config.ron").clicked() {
self.picked_path = Some(String::from("config.ron"));
}
if ui.button("Open default config.toml").clicked() {
self.picked_path = Some(String::from("config.toml"));
}