Merge branch 'bugfix/persistent-theme' into 'main'

Reintroduce persistent dark/light mode

See merge request asus-linux/asusctl!180
This commit is contained in:
Luke Jones
2024-02-19 19:44:59 +00:00
2 changed files with 33 additions and 1 deletions

View File

@@ -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

View File

@@ -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();
}
}
}