Skip to content

Add 'Replace' action to File menu#1274

Merged
danielhrisca merged 1 commit intodanielhrisca:developmentfrom
PCSmithy:feature/file-replace-action
Feb 20, 2026
Merged

Add 'Replace' action to File menu#1274
danielhrisca merged 1 commit intodanielhrisca:developmentfrom
PCSmithy:feature/file-replace-action

Conversation

@PCSmithy
Copy link
Copy Markdown

Summary

  • Adds a File > Replace menu action (Ctrl+Shift+O) that swaps the current MDF file while preserving the display configuration (plot windows, selected channels, window geometry, etc.)
  • This streamlines the workflow of comparing multiple MDF files that share the same signal layout — no need to manually re-open a .dspf config after switching files

Implementation

src/asammdf/gui/widgets/main.py:

  • New menu action "Replace" added to the File menu after "Open folder", reusing the existing open icon
  • New replace_file() method that:
    1. Captures the current display config via FileWidget.to_config()
    2. Shows a single-file open dialog
    3. Closes the old tab
    4. Opens the new file with display_file=config to restore the layout
    5. Inserts the new tab at the same position

Guard clauses handle edge cases: no file open, not in single-file mode, user cancels dialog.

Test coverage

test/asammdf/gui/widgets/Shortcuts/test_MainWindow_Shortcuts.py — 4 new test cases in TestReplaceFile:

Test What it verifies
test_replace_file_preserves_tab_position Tab count stays at 1, tab label/tooltip update to new file
test_replace_file_preserves_display_config Plot sub-window with selected channels is recreated on the new file
test_replace_file_no_op_when_no_file_open Replace is a no-op when no tabs are open (dialog never shown)
test_replace_file_no_op_when_dialog_cancelled Original tab is unchanged when user cancels the file dialog

All 4 tests pass.

Test plan

  • Open an MDF file, select signals, create plot windows
  • File > Replace (or Ctrl+Shift+O), pick a different MDF with same signal names
  • Verify: new file loaded, same plot windows appear with data from the new file, tab position preserved
  • Test: Replace with no file open (should no-op)
  • Test: Cancel the dialog (should no-op)
  • Test: Replace with a file that has different signals (should show partial data gracefully)

@danielhrisca
Copy link
Copy Markdown
Owner

Hello Patrick, thanks for the PR. I wish I had the patience and discipline to write PR descriptions such as yours.

@PCSmithy PCSmithy force-pushed the feature/file-replace-action branch from 84bd1de to acfb3e7 Compare February 17, 2026 00:40
@PCSmithy
Copy link
Copy Markdown
Author

Hello Patrick, thanks for the PR. I wish I had the patience and discipline to write PR descriptions such as yours.

haha, thanks, I try to make things easy to review.

I think I've fixed the failed tests (had to do with the unsaved-config popup). I'm not sure how to re-trigger the CI checks on the PR. Could you re-trigger those by chance?

@danielhrisca danielhrisca changed the base branch from master to development February 17, 2026 20:26
@PCSmithy PCSmithy force-pushed the feature/file-replace-action branch from acfb3e7 to d32e719 Compare February 19, 2026 18:50
…ed display config

When working with multiple MDF files that share the same signal layout, switching
files while keeping the current display configuration (plot windows, selected
channels, etc.) previously required multiple manual steps. The new File > Replace
action (Ctrl+Shift+O) captures the current display config via to_config(), closes
the old tab, and opens the selected file with display_file=config to restore
the layout automatically.
@PCSmithy PCSmithy force-pushed the feature/file-replace-action branch from d32e719 to dfffd00 Compare February 19, 2026 18:59
@danielhrisca danielhrisca merged commit 8443e54 into danielhrisca:development Feb 20, 2026
@danielhrisca
Copy link
Copy Markdown
Owner

thanks !

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.

2 participants