Skip to content

refactor(gui): split buildMenuBar into MainWindow_Menus.cpp (#3351 Phase 1b)#3520

Merged
jensenpat merged 1 commit into
mainfrom
refactor/3351-phase1b-menus
Jun 11, 2026
Merged

refactor(gui): split buildMenuBar into MainWindow_Menus.cpp (#3351 Phase 1b)#3520
jensenpat merged 1 commit into
mainfrom
refactor/3351-phase1b-menus

Conversation

@ten9876

@ten9876 ten9876 commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Third PR of the #3351 series. Pure code motion — no behavior change, no MainWindow.h changes.

Moves buildMenuBar() — 1,048 lines: every QMenu/QAction, enable/disable wiring, ~70 inline connect lambdas — into the new MainWindow_Menus.cpp.

Not-pure-motion exception (the review surface)

One supporting promotion, forced by the split:

The keyboard-shortcut mutable state gains external linkages_keyboardShortcutsEnabled, s_sliderShortcutLeaseActive, and their accessors (textInputCaptured, shortcutInputCaptured, shortcutGuard, leaseHolderBusy) are now declared in a new internal header MainWindowShortcutState.h. The View-menu shortcut toggle writes the flag and hands shortcutGuard to ShortcutManager::rebuildShortcuts, and it moved with buildMenuBar — so the state now has writers in two TUs. Definitions stay in MainWindow.cpp.

The header documents why file-scope state exists at all (the ShortcutManager guard is a receiver-less std::function<bool()> that can't read MainWindow members) and that the Shortcuts TU (Phase 1c) takes ownership of the definitions next.

Everything else is verbatim. Breadcrumb at the excision site.

Numbers

  • MainWindow.cpp: 17,308 → 16,261 (−1,047)
  • New MainWindow_Menus.cpp: 1,113 lines; new MainWindowShortcutState.h: 44 lines
  • Series running total: 19,474 → 16,261 (−16.5%)

Verification

  • Full build clean (Linux x86, RelWithDebInfo)
  • All 32 ctest suites pass
  • a11y lint: 0 findings

QA checklist for the bench

This phase is menu construction only — the lowest-risk split in the series:

  • Walk every top-level menu (File / View / Radio / Audio / Tools / Help) — all entries present, none greyed out that shouldn't be
  • View → keyboard-shortcuts toggle: disable, confirm shortcuts dead; re-enable, confirm they fire
  • View → Minimal Mode in/out
  • Theme submenu: switch theme, switch back
  • Help → About / What's New / Check for Updates open
  • Profiles menu: load a profile

Refs #3351

…ase 1b)

Third PR of the #3351 monolith-decomposition series. Pure code motion —
no behavior change, no MainWindow.h changes.

Moves buildMenuBar() (1,048 lines: every QMenu/QAction, their
enable/disable wiring, and ~70 inline connect lambdas) out of
MainWindow.cpp into the new MainWindow_Menus.cpp.

One supporting promotion, called out for review:

- The keyboard-shortcut mutable state (s_keyboardShortcutsEnabled,
  s_sliderShortcutLeaseActive) and its accessor helpers
  (textInputCaptured, shortcutInputCaptured, shortcutGuard,
  leaseHolderBusy) gain external linkage, declared in a new internal
  header MainWindowShortcutState.h. The View-menu shortcut toggle —
  which writes the flag and hands shortcutGuard to
  ShortcutManager::rebuildShortcuts — moved with buildMenuBar, so the
  state now has writers in two TUs. Definitions stay in MainWindow.cpp;
  the header documents why file-scope state exists at all (the
  ShortcutManager guard is a receiver-less std::function that cannot
  read MainWindow members). The Shortcuts TU (Phase 1c) will take
  ownership of the definitions.

Breadcrumb comment at the excision site points to the new file.

MainWindow.cpp: 17,308 → 16,261 lines (series total: 19,474 → 16,261,
−16.5%).
Verified: full build clean, all 32 ctest suites pass, a11y lint clean.

Refs #3351. Principle XI.
@ten9876 ten9876 requested review from a team as code owners June 11, 2026 02:34

@jensenpat jensenpat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: verified verbatim code motion (multiset diff of removed vs added lines — only deltas are the new TU's include block and the documented static→extern promotion of shortcut state). MainWindowShortcutState.h is well-scoped and documented; CMake updated; all CI green on Linux/macOS/Windows + CodeQL + a11y.

@jensenpat jensenpat merged commit f39746a into main Jun 11, 2026
6 checks passed
@jensenpat jensenpat deleted the refactor/3351-phase1b-menus branch June 11, 2026 03:06

@aethersdr-agent aethersdr-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed with focus on the stated review surface (the shortcut-state linkage promotion) and verbatim-motion verification.

Verified:

  • buildMenuBar() is byte-identical — I extracted the old body from main and the new body from MainWindow_Menus.cpp and diffed them: 1,048 lines, zero differences. The "pure code motion" claim holds.
  • Linkage is consistent. The header declares everything in namespace AetherSDR, and the definitions in MainWindow.cpp sit inside the namespace block that opens at line 246 — so the extern declarations and definitions match. Grepped the whole tree for the six promoted names: no colliding definitions in any other TU.
  • MainWindow.cpp changes are exactly the minimum: 8 added lines total (the new include, static dropped from the two flags and four accessors, and the breadcrumb at the excision site). Nothing else touched.
  • Thread-safety of the now-cross-TU writers: both write sites (the View-menu toggle in the Menus TU, the lease lifecycle in MainWindow.cpp) and the guard's invocation via ShortcutManager all run on the GUI thread, so plain bools remain fine.
  • CMakeLists addition is correct; all four files are in scope; AppSettings usage is pre-existing moved code.

One optional note, no action needed: the s_ prefix is now a slight misnomer on external-linkage globals, but the header already documents that the Shortcuts TU (Phase 1c) takes ownership of the definitions next — renaming there, when the state actually moves, is the right time.

The header comment explaining why file-scope state exists (the receiver-less std::function<bool()> guard) is exactly the kind of documentation that makes these splits reviewable later. Nice work — this is a clean Phase 1b. The QA bench checklist in the description covers the right surfaces (shortcut toggle round-trip especially).


🤖 aethersdr-agent · cost: $10.7221 · model: claude-fable-5

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