fix: disable slider when xvb is not started

This commit is contained in:
mostafaei2002 2024-06-11 12:09:26 +03:30
parent 786432e2b5
commit acff995c20

View file

@ -36,7 +36,7 @@ impl crate::disk::state::Xvb {
ui: &mut egui::Ui, ui: &mut egui::Ui,
api: &Arc<Mutex<PubXvbApi>>, api: &Arc<Mutex<PubXvbApi>>,
gui_api_xmrig: &Arc<Mutex<PubXmrigApi>>, gui_api_xmrig: &Arc<Mutex<PubXmrigApi>>,
private_stats: bool, is_alive: bool,
) { ) {
egui::ScrollArea::vertical().show(ui, |ui| { egui::ScrollArea::vertical().show(ui, |ui| {
@ -182,12 +182,14 @@ impl crate::disk::state::Xvb {
XVB_MANUAL_SLIDER_KEEP_HELP XVB_MANUAL_SLIDER_KEEP_HELP
}; };
ui.horizontal(|ui| { ui.add_enabled_ui(is_alive, |ui| {
ui.spacing_mut().slider_width = width * 0.7; ui.horizontal(|ui| {
ui.add_sized( ui.spacing_mut().slider_width = width * 0.7;
[width, text_edit], ui.add_sized(
egui::Slider::new(&mut self.amount, 0.0..=(hashrate_xmrig as f64)).text("H/s") [width, text_edit],
).on_hover_text(slider_help_text); egui::Slider::new(&mut self.amount, 0.0..=(hashrate_xmrig as f64)).text("H/s")
).on_hover_text(slider_help_text);
});
}); });
} }
@ -227,8 +229,8 @@ impl crate::disk::state::Xvb {
// private stats // private stats
ui.add_space(space_h); ui.add_space(space_h);
// ui.add_enabled_ui(private_stats, |ui| { // ui.add_enabled_ui(is_alive, |ui| {
ui.add_enabled_ui(private_stats, |ui| { ui.add_enabled_ui(is_alive, |ui| {
let api = &lock!(api); let api = &lock!(api);
let priv_stats = &api.stats_priv; let priv_stats = &api.stats_priv;
let current_node = &api.current_node; let current_node = &api.current_node;