Skip to content

Commit

Permalink
feat: save and show filename
Browse files Browse the repository at this point in the history
  • Loading branch information
c-git committed Jun 2, 2024
1 parent 0efafb6 commit 4ec1cc2
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub struct LogViewerApp {
main_table_screen_proportion: f32,
data_display_options: DataDisplayOptions,
start_open_path: Arc<Mutex<Option<PathBuf>>>,
last_filename: Arc<Mutex<Option<PathBuf>>>,
show_last_filename: bool,

#[serde(skip)]
loading_status: LoadingStatus,
Expand All @@ -33,6 +35,8 @@ impl Default for LogViewerApp {
data_display_options: Default::default(),
start_open_path: Default::default(),
loading_status: Default::default(),
last_filename: Default::default(),
show_last_filename: true,
}
}
}
Expand Down Expand Up @@ -237,6 +241,11 @@ impl LogViewerApp {
if ui.button("Clear Data").clicked() {
self.data = None;
}
if self.show_last_filename {
if let Some(filename) = self.last_filename.lock().unwrap().as_ref() {
ui.label(format!("Filename: {}", filename.display()));
}
}
});
}
LoadingStatus::InProgress(promise) => {
Expand Down Expand Up @@ -274,6 +283,7 @@ impl LogViewerApp {

fn initiate_loading(&self, ctx: egui::Context) -> LoadingStatus {
let start_open_path = Arc::clone(&self.start_open_path);
let last_filename = Arc::clone(&self.last_filename);

Check warning on line 286 in src/app.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

unused variable: `last_filename`
LoadingStatus::InProgress(execute(async move {
let mut dialog = rfd::AsyncFileDialog::new();
if let Some(path) = start_open_path.lock().unwrap().as_mut() {
Expand All @@ -284,8 +294,11 @@ impl LogViewerApp {
return Box::new(LoadingStatus::NotInProgress);
};
#[cfg(not(target_arch = "wasm32"))]
if let Some(parent) = file.path().parent() {
*start_open_path.lock().unwrap() = Some(PathBuf::from(parent));
{
if let Some(parent) = file.path().parent() {
*start_open_path.lock().unwrap() = Some(PathBuf::from(parent));
}
*last_filename.lock().unwrap() = Some(PathBuf::from(file.path()));
}
let text = file.read().await;

Expand All @@ -310,6 +323,7 @@ impl LogViewerApp {
.clamp_range(0.2..=0.85)
.prefix("Main Area Proportion Percentage "),
);
ui.checkbox(&mut self.show_last_filename, "Show last filename");
});
}

Expand Down

0 comments on commit 4ec1cc2

Please sign in to comment.