fix: replace profile cycle button with ComboBox for instant style switching

This commit is contained in:
Developer
2026-05-14 21:08:31 +08:00
parent 7d056e2670
commit 515ec0e07d
2 changed files with 29 additions and 14 deletions

View File

@@ -191,6 +191,7 @@ impl eframe::App for App {
let mut style = self.active_profile().clone();
let theme_copy = self.settings.theme;
let use_kraft = self.settings.use_kraft_bg;
let profile_names: Vec<String> = self.settings.profiles.iter().map(|p| p.name.clone()).collect();
egui::CentralPanel::default().show(ctx, |ui| {
let book = self.state.book.as_mut().unwrap();
@@ -205,6 +206,7 @@ impl eframe::App for App {
&file_path,
self.kraft_texture.as_ref(),
use_kraft,
&profile_names,
);
if action.go_back {
@@ -214,12 +216,19 @@ impl eframe::App for App {
self.state.current_page = 0;
}
if action.cycle_profile {
let idx = self.settings.profiles.iter()
.position(|p| p.name == self.settings.active_profile)
.unwrap_or(0);
let next = (idx + 1) % self.settings.profiles.len();
self.settings.active_profile = self.settings.profiles[next].name.clone();
// Switch profile immediately: copy all settings from the selected profile
if let Some(ref target) = action.switch_to_profile {
if let Some(profile) = self.settings.profiles.iter()
.find(|p| p.name == *target)
{
style.alignment = profile.alignment;
style.line_spacing = profile.line_spacing;
style.paragraph_spacing = profile.paragraph_spacing;
style.first_line_indent = profile.first_line_indent;
style.font_size = profile.font_size;
style.name = profile.name.clone();
self.settings.active_profile = profile.name.clone();
}
}
if action.toggle_kraft_bg {