gupax: disable FileSelector ui if thread exists

This commit is contained in:
hinto-janaiyo 2022-11-17 16:53:55 -05:00
parent 51df689cb0
commit adaaca394a
No known key found for this signature in database
GPG key ID: B1C5A64B80691E45
2 changed files with 31 additions and 28 deletions

View file

@ -59,6 +59,7 @@ pub const GUPAX_AUTO_UPDATE: &'static str = "Automatically check for updates at
pub const GUPAX_UPDATE_VIA_TOR: &'static str = "Update through the Tor network. Tor is embedded within Gupax; a Tor system proxy is not required";
pub const GUPAX_ASK_BEFORE_QUIT: &'static str = "Ask before quitting Gupax";
pub const GUPAX_SAVE_BEFORE_QUIT: &'static str = "Automatically save any changed settings before quitting";
pub const GUPAX_SELECT: &'static str = "Open a file explorer to select a file";
pub const GUPAX_PATH_P2POOL: &'static str = "The location of the P2Pool binary: Both absolute and relative paths are accepted; A red [X] will appear if there is no file found at the given path";
pub const GUPAX_PATH_XMRIG: &'static str = "The location of the XMRig binary: Both absolute and relative paths are accepted; A red [X] will appear if there is no file found at the given path";
// P2Pool

View file

@ -152,8 +152,9 @@ impl Gupax {
};
}
ui.spacing_mut().text_edit_width = ui.available_width() - SPACE;
if ui.button("Select File").clicked() {
if file_window.lock().unwrap().thread == false {
ui.set_enabled(!file_window.lock().unwrap().thread);
if ui.button("Select").on_hover_text(GUPAX_SELECT).clicked() {
file_window.lock().unwrap().thread = true;
let file_window = Arc::clone(file_window);
thread::spawn(move|| {
match rfd::FileDialog::new().set_title("Select P2Pool Binary for Gupax").pick_file() {
@ -164,9 +165,9 @@ impl Gupax {
},
None => info!("Gupax | No path selected for P2Pool"),
};
file_window.lock().unwrap().thread = false;
});
}
}
ui.text_edit_singleline(&mut self.p2pool_path).on_hover_text(GUPAX_PATH_P2POOL);
});
ui.horizontal(|ui| {
@ -185,8 +186,9 @@ impl Gupax {
};
}
ui.spacing_mut().text_edit_width = ui.available_width() - SPACE;
if ui.button("Select File").clicked() {
if file_window.lock().unwrap().thread == false {
ui.set_enabled(!file_window.lock().unwrap().thread);
if ui.button("Select").on_hover_text(GUPAX_SELECT).clicked() {
file_window.lock().unwrap().thread = true;
let file_window = Arc::clone(file_window);
thread::spawn(move|| {
match rfd::FileDialog::new().set_title("Select XMRig Binary for Gupax").pick_file() {
@ -197,9 +199,9 @@ impl Gupax {
},
None => info!("Gupax | No path selected for XMRig"),
};
file_window.lock().unwrap().thread = false;
});
}
}
ui.text_edit_singleline(&mut self.xmrig_path).on_hover_text(GUPAX_PATH_XMRIG);
});
let mut guard = file_window.lock().unwrap();