Version bump. Add early-error display

This commit is contained in:
Luke D. Jones
2022-08-02 15:09:25 +12:00
parent 3e244d7d3d
commit e05d5bd143
11 changed files with 84 additions and 21 deletions

View File

@@ -16,6 +16,7 @@ pub mod mocking;
pub mod notify;
pub mod page_states;
pub mod pages;
pub mod startup_error;
pub mod widgets;
#[cfg(feature = "mocking")]

View File

@@ -1,7 +1,8 @@
use rog_aura::layouts::KeyLayout;
use rog_control_center::{
config::Config, get_ipc_file, notify::start_notifications, on_tmp_dir_exists,
page_states::PageDataStates, RogApp, RogDbusClientBlocking, SHOW_GUI,
page_states::PageDataStates, startup_error::AppErrorShow, RogApp, RogDbusClientBlocking,
SHOW_GUI,
};
use std::{
@@ -23,6 +24,24 @@ const DATA_DIR: &str = env!("CARGO_MANIFEST_DIR");
const BOARD_NAME: &str = "/sys/class/dmi/id/board_name";
fn main() -> Result<(), Box<dyn std::error::Error>> {
let native_options = eframe::NativeOptions {
decorated: false,
transparent: false,
min_window_size: Some(egui::vec2(840.0, 600.0)),
max_window_size: Some(egui::vec2(840.0, 600.0)),
..Default::default()
};
let (dbus, _) = RogDbusClientBlocking::new()
.map_err(|e| {
eframe::run_native(
"ROG Control Center",
native_options.clone(),
Box::new(move |_| Box::new(AppErrorShow::new(e.to_string()))),
);
})
.unwrap();
// Startup
let mut config = Config::load()?;
let start_closed = config.startup_in_background;
@@ -76,8 +95,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let notifs_enabled = Arc::new(AtomicBool::new(config.enable_notifications));
let states = {
let (dbus, _) = RogDbusClientBlocking::new()?;
let supported = dbus.proxies().supported().supported_functions().unwrap();
let supported = dbus
.proxies()
.supported()
.supported_functions()
.map_err(|e| {
eframe::run_native(
"ROG Control Center",
native_options.clone(),
Box::new(move |_| Box::new(AppErrorShow::new(e.to_string()))),
);
})
.unwrap();
PageDataStates::new(
layout,
notifs_enabled.clone(),
@@ -114,14 +143,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Err(_) => on_tmp_dir_exists().unwrap(),
};
let native_options = eframe::NativeOptions {
decorated: false,
transparent: false,
min_window_size: Some(egui::vec2(840.0, 600.0)),
max_window_size: Some(egui::vec2(840.0, 600.0)),
..Default::default()
};
let should_show_gui = Arc::new(AtomicBool::new(!start_closed));
let should = should_show_gui.clone();
spawn(move || {

View File

@@ -18,7 +18,7 @@ impl<'a> RogApp<'a> {
egui::ScrollArea::vertical().show(ui, |ui| {
ui.spacing_mut().item_spacing = egui::vec2(8.0, 10.0);
let rect = ui.available_rect_before_wrap();
egui::Grid::new("id_source")
egui::Grid::new("grid_of_bits")
.min_col_width(rect.width() / 2.0)
.show(ui, |ui| {
ui.vertical(|ui| {

View File

@@ -0,0 +1,36 @@
use egui::{Button, RichText};
pub struct AppErrorShow {
error: String,
}
impl AppErrorShow {
pub fn new(error: String) -> Self {
Self { error }
}
}
impl eframe::App for AppErrorShow {
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("ROG ERROR");
ui.centered_and_justified(|ui| {
ui.label(RichText::new(format!("The error was: {:?}", self.error)).size(22.0));
});
egui::TopBottomPanel::bottom("error_bar_2")
.default_height(26.0)
.show(ctx, |ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if ui
.add(Button::new(RichText::new("Okay").size(20.0)))
.clicked()
{
frame.quit();
}
});
});
});
}
}

View File

@@ -55,7 +55,7 @@ pub fn fan_graphs(
let line = Line::new(PlotPoints::from_iter(points.clone())).width(2.0);
let points = Points::new(PlotPoints::from_iter(points)).radius(3.0);
Plot::new("my_plot")
Plot::new("fan_curves")
.view_aspect(1.666)
// .center_x_axis(true)
// .center_y_axis(true)