forked from 1b-agent/opencadstudio-upstream
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
74936063f9
commit
1448909b6f
8 files changed
+365
-55
No files matched your search
@@ -18,6 +18,7 @@ mod dimension_preview_tests;
|
||||
mod document;
|
||||
mod drafting_settings;
|
||||
pub(crate) mod expr_eval;
|
||||
mod options_session;
|
||||
mod find_replace;
|
||||
pub(crate) mod helpers;
|
||||
mod history;
|
||||
@@ -570,6 +571,10 @@ pub(super) struct OpenCADStudio {
|
||||
dyn_input: bool,
|
||||
/// Currently visible page in the application Options dialog.
|
||||
options_tab: crate::ui::window::options::OptionsTab,
|
||||
/// The Options window's commit point (see `options_session`).
|
||||
options_saved: Option<options_session::OptionsSnapshot>,
|
||||
/// Close was pressed with unapplied changes; the discard guard is up.
|
||||
options_close_confirm: bool,
|
||||
spacemouse: crate::input::spacemouse::Service,
|
||||
spacemouse_preferences: crate::input::spacemouse::Preferences,
|
||||
spacemouse_paused: bool,
|
||||
@@ -2825,6 +2830,14 @@ pub enum Message {
|
||||
DraftingSettingsClose,
|
||||
DraftingSettingsCloseDiscard,
|
||||
DraftingSettingsCloseKeep,
|
||||
/// Options window: commit the changes made so far.
|
||||
OptionsApply,
|
||||
/// Options window: commit and close.
|
||||
OptionsOk,
|
||||
/// Options window: close, asking first when changes would be lost.
|
||||
OptionsClose,
|
||||
OptionsCloseDiscard,
|
||||
OptionsCloseKeep,
|
||||
AutoConstrainSelectRow(usize),
|
||||
AutoConstrainToggleKind(settings::AutoConstraintKind),
|
||||
AutoConstrainMoveUp,
|
||||
@@ -3865,6 +3878,8 @@ impl OpenCADStudio {
|
||||
grid_beyond_limits: true,
|
||||
dyn_input: true,
|
||||
options_tab: crate::ui::window::options::OptionsTab::General,
|
||||
options_saved: None,
|
||||
options_close_confirm: false,
|
||||
spacemouse: {
|
||||
let service = crate::input::spacemouse::Service::default();
|
||||
service.set_actions(navigation::actions());
|
||||
|
||||
Reference in new issue
Block a user