show message when clocks table isnt available

This commit is contained in:
Ilya Zlobintsev
2023-01-21 17:04:38 +02:00
parent 826f792a45
commit 860178791c
2 changed files with 20 additions and 5 deletions

View File

@@ -7,29 +7,34 @@ use lact_client::schema::{ClocksTable, ClocksTableGen};
#[derive(Clone)]
pub struct ClocksFrame {
pub container: Box,
tweaking_grid: Grid,
max_sclk_adjustment: Adjustment,
max_mclk_adjustment: Adjustment,
max_voltage_adjustment: Adjustment,
clocks_data_unavailable_label: Label,
}
impl ClocksFrame {
pub fn new() -> Self {
let container = section_box("Maximum Clocks", 0, 5);
container.hide();
let tweaking_grid = Grid::new();
let max_sclk_adjustment = oc_adjustment("GPU Clock (MHz)", &tweaking_grid, 0);
let max_voltage_adjustment = oc_adjustment("GPU voltage (mV)", &tweaking_grid, 1);
let max_mclk_adjustment = oc_adjustment("VRAM Clock (MHz)", &tweaking_grid, 2);
let clocks_data_unavailable_label = Label::new(Some("No clocks data available"));
container.append(&tweaking_grid);
container.append(&clocks_data_unavailable_label);
Self {
container,
tweaking_grid,
max_sclk_adjustment,
max_mclk_adjustment,
max_voltage_adjustment,
clocks_data_unavailable_label,
}
}
@@ -62,6 +67,16 @@ impl ClocksFrame {
Ok(())
}
pub fn show(&self) {
self.tweaking_grid.show();
self.clocks_data_unavailable_label.hide();
}
pub fn hide(&self) {
self.tweaking_grid.hide();
self.clocks_data_unavailable_label.show();
}
}
fn oc_adjustment(title: &'static str, grid: &Grid, row: i32) -> Adjustment {

View File

@@ -70,15 +70,15 @@ impl OcPage {
match table {
Some(table) => match self.clocks_frame.set_table(table) {
Ok(()) => {
self.clocks_frame.container.show();
self.clocks_frame.show();
}
Err(err) => {
warn!("Got invalid clocks table: {err:?}");
self.clocks_frame.container.hide();
self.clocks_frame.hide();
}
},
None => {
self.clocks_frame.container.hide();
self.clocks_frame.hide();
}
}
}