From a6101fce7fd7c61152731fd3049e30a912faa6f8 Mon Sep 17 00:00:00 2001 From: Rahix Date: Mon, 25 Aug 2025 19:14:31 +0200 Subject: [PATCH 1/2] Fix theme preference not being restored correctly Using `set_visuals(Visuals::dark())` in `main()` somehow interfered badly with the theme switching code such that a light theme was not restored properly. Instead, the correct function to set the theme on startup is `set_theme()` and we should pass in the saved perference instead of hard-coding dark-mode. With these changes, all of the theme preferences work correctly and are restored correctly. --- src/main.rs | 4 ++-- src/settings_window.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 03290b0..e7ca6fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use crate::gui::{load_gui_settings, GuiCommand, MyApp, RIGHT_PANEL_WIDTH}; use crate::io::{open_from_csv, save_to_csv, FileOptions}; use crate::serial::{load_serial_settings, serial_devices_thread, serial_thread, Device}; use crossbeam_channel::{select, Receiver, Sender}; -use eframe::egui::{vec2, ViewportBuilder, Visuals}; +use eframe::egui::{vec2, ViewportBuilder}; use eframe::{egui, icon_data}; use egui_plot::PlotPoint; use preferences::AppInfo; @@ -349,7 +349,7 @@ fn main() { let mut fonts = egui::FontDefinitions::default(); egui_phosphor::add_to_fonts(&mut fonts, egui_phosphor::Variant::Regular); ctx.egui_ctx.set_fonts(fonts); - ctx.egui_ctx.set_visuals(Visuals::dark()); + ctx.egui_ctx.set_theme(gui_settings.theme_preference); egui_extras::install_image_loaders(&ctx.egui_ctx); let repaint_signal = ctx.egui_ctx.clone(); diff --git a/src/settings_window.rs b/src/settings_window.rs index 0e78690..da572c4 100644 --- a/src/settings_window.rs +++ b/src/settings_window.rs @@ -2,7 +2,7 @@ use crate::gui::GuiSettingsContainer; #[cfg(feature = "self_update")] use crate::update::{check_update, update}; use eframe::egui; -use eframe::egui::{Align2, InnerResponse, Vec2, Visuals}; +use eframe::egui::{Align2, InnerResponse, Vec2}; use egui_theme_switch::ThemeSwitch; #[cfg(feature = "self_update")] use self_update::restart::restart; @@ -32,7 +32,7 @@ pub fn settings_window( { ui.ctx().set_theme(gui_conf.theme_preference); }; - gui_conf.dark_mode = ui.visuals() == &Visuals::dark(); + gui_conf.dark_mode = ui.ctx().theme() == egui::Theme::Dark; ui.end_row(); ui.end_row(); From 78b46c34a03b38cd0e5120de8c7b4b68488a6910 Mon Sep 17 00:00:00 2001 From: Rahix Date: Mon, 25 Aug 2025 20:30:17 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ecab29..7b9dfd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to the `Serial Monitor` crate will be documented in this fil * Releases are now linked to libssl 3.4.1 on linux (built on Ubuntu 22.04) * allow to plot only every n-th point (max points is 5000, if dataset is larger, it will reduce it by showing only every 2nd point. if it is larger than 10000 only every 3rd point etc...) +* Fixed the theme preference setting not being properly restored after restarting the application ## 0.3.4