Persist advanced options expand/collapse state per section
Each ExpanderRow now remembers its expanded state between sessions using a per-section key stored in SessionState. Replaces the global detailed_mode toggle with granular per-section persistence.
This commit is contained in:
@@ -102,6 +102,19 @@ pub struct AppState {
|
||||
pub job_config: Rc<RefCell<JobConfig>>,
|
||||
pub detailed_mode: bool,
|
||||
pub batch_queue: Rc<RefCell<BatchQueue>>,
|
||||
pub expanded_sections: Rc<RefCell<std::collections::HashMap<String, bool>>>,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
/// Get the expanded state for a named section, falling back to the skill level default
|
||||
pub fn is_section_expanded(&self, section: &str) -> bool {
|
||||
self.expanded_sections.borrow().get(section).copied().unwrap_or(self.detailed_mode)
|
||||
}
|
||||
|
||||
/// Set and persist an expander's state
|
||||
pub fn set_section_expanded(&self, section: &str, expanded: bool) {
|
||||
self.expanded_sections.borrow_mut().insert(section.to_string(), expanded);
|
||||
}
|
||||
}
|
||||
|
||||
/// A queued batch of images with their processing settings
|
||||
@@ -300,6 +313,7 @@ fn build_ui(app: &adw::Application) {
|
||||
output_dir: Rc::new(RefCell::new(None)),
|
||||
detailed_mode: app_cfg.skill_level.is_advanced(),
|
||||
batch_queue: Rc::new(RefCell::new(BatchQueue::default())),
|
||||
expanded_sections: Rc::new(RefCell::new(sess_state.expanded_sections.clone())),
|
||||
job_config: Rc::new(RefCell::new(JobConfig {
|
||||
resize_enabled: if remember { sess_state.resize_enabled.unwrap_or(true) } else { true },
|
||||
resize_width: if remember { sess_state.resize_width.unwrap_or(1200) } else { 1200 },
|
||||
@@ -574,6 +588,9 @@ fn build_ui(app: &adw::Application) {
|
||||
state.rename_enabled = Some(cfg.rename_enabled);
|
||||
}
|
||||
|
||||
// Always save expanded section states
|
||||
state.expanded_sections = app_state_for_close.expanded_sections.borrow().clone();
|
||||
|
||||
let _ = session.save(&state);
|
||||
glib::Propagation::Proceed
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user