feat(options): OK / Apply / Close with a discard guard

The Options window used to commit every control the moment it was
touched, with no way back but re-editing. It now works like the Drafting
Settings window: changes still show at once (a theme, a cursor size or a
language is seen immediately), but nothing is committed until Apply or OK.
Close — and the window's × or Esc — puts everything back the way it was
when the window opened or Apply was last pressed, asking first when there
is something to lose.

The commit point is a snapshot of the persisted configuration plus the
drawing variables the 3D Modeling page edits (with the drawing's modified
flag), so every control the window has or gains is covered without being
registered; reverting re-applies the snapshot the way start-up does and
re-bakes text or regenerates solids when those settings moved.

The "unsaved changes" guard is now a shared modal helper used by both
windows.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
PanosandClaude Opus 5 committed 2026-09-18 14:53:54 +03:00
1 parent 74936063f9
commit 1448909b6f
8 files changed
+365 -55

No files matched your search

+37 -1
View File
@@ -177,6 +177,10 @@ impl OpenCADStudio {
self.drafting_settings_state = None;
self.drafting_settings_saved = None;
}
if self.active_modal == Some(Options) {
self.options_saved = None;
self.options_close_confirm = false;
}
#[cfg(not(target_arch = "wasm32"))]
if self.active_modal == Some(FileInUse) {
self.pending_save_failure = None;
@@ -6957,7 +6961,35 @@ impl OpenCADStudio {
}
// ── Options / About windows ───────────────────────────────────
Message::OptionsOpen => {
self.active_modal = Some(super::ModalKind::Options);
self.options_open();
Task::none()
}
Message::OptionsApply => {
self.options_apply();
Task::none()
}
Message::OptionsOk => {
self.options_apply();
self.options_forget();
self.close_active_modal();
Task::none()
}
Message::OptionsClose => {
if !self.options_close_confirm && self.options_dirty() {
self.options_close_confirm = true;
return Task::none();
}
self.options_discard();
self.close_active_modal();
Task::none()
}
Message::OptionsCloseDiscard => {
self.options_discard();
self.close_active_modal();
Task::none()
}
Message::OptionsCloseKeep => {
self.options_close_confirm = false;
Task::none()
}
@@ -7541,6 +7573,10 @@ impl OpenCADStudio {
if self.active_modal == Some(super::ModalKind::RecoveryPrompt) {
return self.update(Message::RecoveryDecline);
}
// The Options window's × and Esc behave like its Close button.
if self.active_modal == Some(super::ModalKind::Options) {
return self.update(Message::OptionsClose);
}
// Closing the shortcut editor with un-applied rows needs an
// explicit discard; a second close attempt (or the overlay's
// Discard button) goes through.