Skip to content

fix(toolbox): persist config on dialog close regardless of accept/reject#54

Merged
pabloinigoblasco merged 3 commits into
developmentfrom
fix/toolbox-config-persistence
Apr 14, 2026
Merged

fix(toolbox): persist config on dialog close regardless of accept/reject#54
pabloinigoblasco merged 3 commits into
developmentfrom
fix/toolbox-config-persistence

Conversation

@pabloinigoblasco
Copy link
Copy Markdown
Collaborator

@pabloinigoblasco pabloinigoblasco commented Apr 14, 2026

Motivation

Toolbox plugins (FFT, Quaternion, ColorMap, etc.) are persistent workspaces — unlike file-open dialogs where Cancel means "don't load", a toolbox dialog is a work area where the user configures parameters, selects fields, adjusts settings, and may run computations. Closing the dialog (whether with OK, Close, or the X button) should not discard that work.

The bug: In the current code, loadConfig (which persists the plugin's state) only runs if the user clicks OK. If the user clicks Close or the X button, runDialog returns early before saving, and the plugin's configuration is lost. The next time the user opens the toolbox, it starts from scratch.

In PJ 3.x, toolbox panels were permanently visible in the main window — there was no "close and lose state" problem. In the new SDK, toolboxes open as dialogs that can be closed, so we need to explicitly persist state on every close.

Concrete example: The FFT toolbox lets the user select fields, toggle "Remove DC", choose "All data" vs "Only zoomed area", and set a suffix for saved curves. If the user configures all of this, runs an FFT, then closes the dialog to look at the chart, they expect to reopen the FFT dialog and find everything as they left it — not a blank slate.

Summary

  • Move loadConfig and flushPending before the rejected-early-return so config is always saved after the dialog closes
  • The return value of runDialog still distinguishes accept vs reject for callers that care

Test plan

  • Open a toolbox dialog, change parameters, click Close (X) — reopen, parameters preserved
  • Open a toolbox dialog, change parameters, click OK — parameters preserved (unchanged)
  • Open a toolbox dialog, change nothing, click Close — no crash, no side effects

Introduces ToolboxSession, which encapsulates the lifecycle of a single
toolbox plugin instance inside pj_proto_app.

Contents:
- toolbox_session.hpp / toolbox_session.cpp: new ToolboxSession QObject that
  binds toolbox host, runtime host and config, and exposes runDialog()
- runDialog() reads kToolboxCapabilityNonModalDialog from the plugin's capability
  flags and sets DialogEngineConfig::non_modal accordingly, so plugins that
  declared non-modal capability get a non-blocking dialog automatically
- Runtime host vtable wired via captureless static lambdas; dataChanged() signal
  emitted when the plugin calls notify_data_changed
Toolbox dialogs are persistent workspaces — closing with X or Cancel
should not discard the plugin's configuration. Move loadConfig and
flushPending before the rejected-early-return so config is always
saved after the dialog closes, not only when the user clicks OK.
@pabloinigoblasco
Copy link
Copy Markdown
Collaborator Author

Okay. We accept this since we want to have the same PJ 3.x behavior.

@pabloinigoblasco pabloinigoblasco changed the base branch from feat/toolbox-session to development April 14, 2026 15:21
…ox-config-persistence

# Conflicts:
#	pj_proto_app/src/toolbox_session.cpp
@pabloinigoblasco pabloinigoblasco merged commit fbb2a61 into development Apr 14, 2026
2 checks passed
pabloinigoblasco added a commit that referenced this pull request Apr 15, 2026
Sync from GitHub development:
- PR #45: feat: drag-and-drop support for dialog plugins
- PR #54: fix: persist config on dialog close
- PR #55: feat: Tools menu with toolbox plugin discovery
- PR #56: feat: Python syntax highlighter + runtime language swapping
@pabloinigoblasco pabloinigoblasco deleted the fix/toolbox-config-persistence branch May 4, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant