Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,25 @@ short_description = "A GUI for the awtrix clock."

[dependencies]
# Error handling
anyhow = "1.0.92"
anyhow = "1.0.95"
# Networking
reqwest = { version = "0.12.9", features = ["blocking"] }
reqwest = { version = "0.12.11", features = ["blocking"] }
# Parsing
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.132"
semver = "1.0.23"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.134"
semver = "1.0.24"
# GUI
eframe = "0.29.1"
egui = "0.29.1"
egui-notify = "0.17.0"
egui_extras = { version = "0.29.1", features = ["syntect", "image"] }
image = "0.25.4"
open = "5.3.0"
eframe = "0.30.0"
egui = "0.30.0"
egui-notify = "0.18.0"
egui_extras = { version = "0.30.0", features = ["syntect", "image"] }
image = "0.25.5"
open = "5.3.1"
parking_lot = "0.12.3"

[lints.rust]
unsafe_code = "forbid"
deprecated = "deny"

[lints.clippy]
nursery = { level = "deny", priority = 0 }
Expand Down
4 changes: 2 additions & 2 deletions src/ui/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Device {
}
}

pub fn show(&mut self, ui: &mut Ui, ip: &str, stats: &Option<Stat>) -> anyhow::Result<()> {
pub fn show(&mut self, ui: &mut Ui, ip: &str, stats: Option<&Stat>) -> anyhow::Result<()> {
SidePanel::right("panel")
.show_separator_line(true)
.show_inside(ui, |ui| {
Expand Down Expand Up @@ -119,7 +119,7 @@ impl Device {
&mut self,
ui: &mut Ui,
ip: &str,
stats: &Option<Stat>,
stats: Option<&Stat>,
enabled: bool,
) -> anyhow::Result<()> {
if self.update_available {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl eframe::App for App {
});

self.device
.show(ui, &self.config.ip, &self.stat)
.show(ui, &self.config.ip, self.stat.as_ref())
.unwrap_or_else(|e| {
self.toasts.error(e.to_string());
});
Expand Down
4 changes: 2 additions & 2 deletions src/ui/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn show(ui: &mut Ui, ip: &str, stat: &mut Option<Stat>) -> anyhow::Result<()
Err(e) => anyhow::bail!(e),
}
}
ui.add(egui::Label::new(get_string(stat)));
ui.add(egui::Label::new(get_string(stat.as_ref())));
Ok(())
}

Expand All @@ -27,7 +27,7 @@ pub fn get_stats(ip: &str) -> anyhow::Result<Stat> {
Ok(from_str(&response.text()?)?)
}

fn get_string(stat: &Option<Stat>) -> String {
fn get_string(stat: Option<&Stat>) -> String {
stat.as_ref().map_or_else(||
"Battery: N/A\nBattery Raw: N/A\nData Type: N/A\nLux: N/A\nLDR Raw: N/A\nRAM: N/A\nBrightness: N/A\nTemperature: N/A\nHumidity: N/A\nUptime: N/A\nWiFi Signal: N/A\nMessages: N/A\nVersion: N/A\nIndicator 1: N/A\nIndicator 2: N/A\nIndicator 3: N/A\nApp: N/A\nUID: N/A\nMatrix: N/A\nIP Address: N/A".to_owned(), |stat| format!(
"Battery: {}%\nBattery Raw: {}\nData Type: {}\nLux: {}\nLDR Raw: {}\nRAM: {}%\nBrightness: {}\nTemperature: {}°C\nHumidity: {}%\nUptime: {}s\nWiFi Signal: {}%\nMessages: {}\nVersion: {}\nIndicator 1: {}\nIndicator 2: {}\nIndicator 3: {}\nApp: {}\nUID: {}\nMatrix: {}\nIP Address: {}",
Expand Down
57 changes: 28 additions & 29 deletions src/ui/statusbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,36 @@ impl StatusBar {

pub fn show(&mut self, ui: &mut Ui, tab: &mut Tab, config: &mut Config) -> anyhow::Result<()> {
self.about_window(ui);
return ui
.horizontal(|ui| {
ui.add_enabled_ui(!config.ip.is_empty(), |ui| {
ui.selectable_value(tab, Tab::Screen, "Screen");
ui.selectable_value(tab, Tab::Status, "Status");
ui.selectable_value(tab, Tab::Settings, "Settings");
});
ui.horizontal(|ui| {
ui.add_enabled_ui(!config.ip.is_empty(), |ui| {
ui.selectable_value(tab, Tab::Screen, "Screen");
ui.selectable_value(tab, Tab::Status, "Status");
ui.selectable_value(tab, Tab::Settings, "Settings");
});

ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
ui.add(Button::new(" ? ").rounding(40.0))
.clicked()
.then(|| self.show_about = true);
let ret = ui
.add(Button::new("Save"))
.clicked()
.then(|| match config.write() {
Ok(()) => anyhow::Ok(()),
Err(e) => anyhow::bail!(e),
})
.unwrap_or(Ok(()));
ui.add(
TextEdit::singleline(&mut config.ip)
.hint_text("IP")
.desired_width(150.0),
);
ui.label("IP:");
ret
})
.inner
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
ui.add(Button::new(" ? ").rounding(40.0))
.clicked()
.then(|| self.show_about = true);
let ret = ui
.add(Button::new("Save"))
.clicked()
.then(|| match config.write() {
Ok(()) => anyhow::Ok(()),
Err(e) => anyhow::bail!(e),
})
.unwrap_or(Ok(()));
ui.add(
TextEdit::singleline(&mut config.ip)
.hint_text("IP")
.desired_width(150.0),
);
ui.label("IP:");
ret
})
.inner;
.inner
})
.inner
}

fn about_window(&mut self, ui: &Ui) {
Expand Down
Loading