diff --git a/src/constants.rs b/src/constants.rs index 2a2bbd2..ab5ed61 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -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 diff --git a/src/gupax.rs b/src/gupax.rs index 6bde3b3..8eed214 100644 --- a/src/gupax.rs +++ b/src/gupax.rs @@ -152,20 +152,21 @@ 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 { - let file_window = Arc::clone(file_window); - thread::spawn(move|| { - match rfd::FileDialog::new().set_title("Select P2Pool Binary for Gupax").pick_file() { - Some(path) => { - info!("Gupax | [{}] path selected for P2Pool", path.display()); - file_window.lock().unwrap().p2pool_path = path.display().to_string(); - file_window.lock().unwrap().picked_p2pool = true; - }, - None => info!("Gupax | No path selected for P2Pool"), - }; - }); - } + 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() { + Some(path) => { + info!("Gupax | [{}] path selected for P2Pool", path.display()); + file_window.lock().unwrap().p2pool_path = path.display().to_string(); + file_window.lock().unwrap().picked_p2pool = true; + }, + 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); }); @@ -185,20 +186,21 @@ 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 { - let file_window = Arc::clone(file_window); - thread::spawn(move|| { - match rfd::FileDialog::new().set_title("Select XMRig Binary for Gupax").pick_file() { - Some(path) => { - info!("Gupax | [{}] path selected for XMRig", path.display()); - file_window.lock().unwrap().xmrig_path = path.display().to_string(); - file_window.lock().unwrap().picked_xmrig = true; - }, - None => info!("Gupax | No path selected for XMRig"), - }; - }); - } + 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() { + Some(path) => { + info!("Gupax | [{}] path selected for XMRig", path.display()); + file_window.lock().unwrap().xmrig_path = path.display().to_string(); + file_window.lock().unwrap().picked_xmrig = true; + }, + 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); });