diff --git a/CHANGELOG.md b/CHANGELOG.md index f5cd198d..5e889e03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Reintroduce persisting dark/light mode in config file ### Changed - Added ability to change what EPP is linked with each throttle profile diff --git a/rog-control-center/src/widgets/top_bar.rs b/rog-control-center/src/widgets/top_bar.rs index 72b2fff3..344942cf 100644 --- a/rog-control-center/src/widgets/top_bar.rs +++ b/rog-control-center/src/widgets/top_bar.rs @@ -8,7 +8,7 @@ impl RogApp { // The top panel is often a good place for a menu bar: egui::menu::bar(ui, |ui| { ui.horizontal(|ui| { - egui::global_dark_light_mode_buttons(ui); + self.dark_light_mode_buttons(ui); egui::warn_if_debug_build(ui); }); @@ -44,4 +44,34 @@ impl RogApp { }); }); } + + fn dark_light_mode_buttons(&mut self, ui: &mut egui::Ui) { + let load_from_cfg = self.config.dark_mode != ui.ctx().style().visuals.dark_mode; + + if ui + .add(egui::SelectableLabel::new( + !self.config.dark_mode, + "☀ Light", + )) + .clicked() + || (load_from_cfg && !self.config.dark_mode) + { + ui.ctx().set_visuals(egui::Visuals::light()); + } + if ui + .add(egui::SelectableLabel::new(self.config.dark_mode, "🌙 Dark")) + .clicked() + || (load_from_cfg && self.config.dark_mode) + { + ui.ctx().set_visuals(egui::Visuals::dark()); + } + + let applied_dark_mode = ui.ctx().style().visuals.dark_mode; + + if self.config.dark_mode != applied_dark_mode { + self.config.dark_mode = applied_dark_mode; + let tmp = self.config.enabled_notifications.clone(); + self.config.save(&tmp).ok(); + } + } }