Skip to content

refactor(gui): split controller methods into MainWindow_Controllers.cpp (#3351 Phase 1a)#3516

Merged
jensenpat merged 2 commits into
mainfrom
refactor/3351-phase1a-controllers
Jun 11, 2026
Merged

refactor(gui): split controller methods into MainWindow_Controllers.cpp (#3351 Phase 1a)#3516
jensenpat merged 2 commits into
mainfrom
refactor/3351-phase1a-controllers

Conversation

@ten9876

@ten9876 ten9876 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Second PR of the #3351 series. Pure code motion — no behavior change, no MainWindow.h changes (a C++ class may define its members across any number of TUs).

Moves the external-controller surface (~1,800 lines) out of MainWindow.cpp into a new MainWindow_Controllers.cpp:

Subsystem Methods
FlexControl (serial) dialog show/sync, indicator, tune-steps, button, virtual wheel, wheel-action apply
HID encoders hidEncoderDefaultAction, hidEncoderDefaultPushAction, dispatchHidAction (292 lines)
Icom RC-28 rc28HoldActionActive, updateRC28Leds
TMate 2 full overlay/display/status/indicator group (9 methods)
StreamDeck+ refreshStreamDeckLabels
MIDI registerMidiParams (~485 lines, #ifdef HAVE_MIDI)
Support bundle buildControlDevicesSnapshot

Not-pure-motion exceptions (the review surface)

Everything below was forced by the split; everything else is verbatim:

  1. flexWheelModeForAction / flexControlButtonAction — moved from MainWindow.cpp's anon namespace to the new TU's anon namespace. The moved methods are their only callers (verified by grep).
  2. kTMate2DefaultOverlayDurationMs — moved into the new TU's anon namespace (only remaining user).
  3. kCw*ActionId / kCw*ActionName constants — promoted from file-statics to inline constexpr in MainWindowHelpers.h; they're now genuinely cross-TU (shortcut registry stays in MainWindow.cpp; MIDI/HID registries moved).
  4. One constexpr + include additions in the new TU as needed for standalone compilation.

Breadcrumb comments at both excision sites in MainWindow.cpp point to the new file.

Deliberately not moved: constructor wiring for these subsystems — that's the constructor-decomposition phase, later in the series.

Numbers

  • MainWindow.cpp: 19,138 → 17,308 lines (−1,830)
  • New MainWindow_Controllers.cpp: 1,892 lines
  • Running series total: 19,474 → 17,308 (−11%)

Verification

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

QA checklist for the bench (per the per-phase QA gate)

This phase touches every physical-controller path. Suggested hands-on pass:

  • FlexControl: knob tune, button presses (each of the 4 buttons), wheel-mode switch via dialog
  • RC-28: tune + hold actions, LED states track TX/MOX
  • TMate 2: tune, overlay display (volume/RIT/power), idle blanking + backlight
  • Ulanzi Dial: rotate + push
  • StreamDeck+: LCD labels refresh on slice/mode change
  • MIDI: a mapped CC knob (e.g. AF gain) + a mapped note button (e.g. MOX), CW paddle actions if mapped
  • Help → support bundle: control-devices section present and populated

Refs #3351

…rollers.cpp (#3351 Phase 1a)

Second PR of the #3351 monolith-decomposition series. Pure code motion —
no behavior change, no header changes to MainWindow.h (a C++ class may
define its members across any number of translation units).

Moves two blocks out of MainWindow.cpp into the new
MainWindow_Controllers.cpp (1,892 lines):

1. The contiguous external-controller method block (was lines
   6682-7983, ~1,300 lines):
   - FlexControl: showFlexControlDialog, syncFlexControlDialog,
     syncFlexControlIndicatorForSettings, setFlexControlHardwareIndicator,
     handleFlexControlTuneSteps, handleFlexControlButton,
     handleVirtualFlexControlWheel, applyFlexControlWheelAction
   - HID encoders: hidEncoderDefaultAction, hidEncoderDefaultPushAction,
     dispatchHidAction
   - Icom RC-28: rc28HoldActionActive, updateRC28Leds
   - TMate 2: the full overlay/display/status/indicator group (9 methods)
   - StreamDeck: refreshStreamDeckLabels
   - Support bundle: buildControlDevicesSnapshot

2. registerMidiParams() (was lines 18083-18569, ~485 lines inside
   #ifdef HAVE_MIDI).

Supporting moves, each forced by the split and called out for review:

- flexWheelModeForAction / flexControlButtonAction moved from
  MainWindow.cpp's anonymous namespace into the new TU's anonymous
  namespace — the moved methods are their only callers.
- kTMate2DefaultOverlayDurationMs duplicated-by-move into the new TU's
  anonymous namespace (its only remaining user).
- kCw*ActionId / kCw*ActionName constants promoted from MainWindow.cpp
  file-statics to inline constexpr in MainWindowHelpers.h — they are now
  genuinely cross-TU (shortcut registry in MainWindow.cpp, MIDI/HID
  registries in the new TU).

Breadcrumb comments at both excision sites point to the new file.

Constructor wiring for these subsystems intentionally still lives in
MainWindow.cpp — it moves in the constructor-decomposition phase.

MainWindow.cpp: 19,138 → 17,308 lines.
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 10, 2026 23:34
@jensenpat

Copy link
Copy Markdown
Collaborator

Review note (non-blocking): kTMate2DefaultOverlayDurationMs was duplicated into the new TU rather than moved — the original definition at the top of MainWindow.cpp is now unused there. Internal linkage on both sides so it's harmless, but worth deleting the leftover in the next phase PR.

@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 the code-motion claim verified mechanically: I diffed the lines removed from MainWindow.cpp against the lines added in MainWindow_Controllers.cpp, and they match verbatim except for the documented exceptions (new-TU preamble/includes/namespace wrappers, and the kCw* constants promoted to MainWindowHelpers.h). No includes were removed from MainWindow.cpp, the HAVE_SERIALPORT/HAVE_HIDAPI/HAVE_MIDI guards traveled intact with the moved code, the inline constexpr promotion in the header is the right C++17 idiom for the now-cross-TU constants, and all six CI checks are green. Nice, disciplined split — the breadcrumb comments at the excision sites and the "not-pure-motion exceptions" section made this very reviewable.

One small discrepancy vs. the PR description:

kTMate2DefaultOverlayDurationMs was copied, not moved. The description says it moved to the new TU's anon namespace ("only remaining user"), but the original definition is still at MainWindow.cpp:280 and is now unused there (its single use site went to MainWindow_Controllers.cpp:550). No ODR concern — both copies have internal linkage — but it's dead code that contradicts the stated intent and may draw -Wunused-const-variable on clang. Suggest deleting the MainWindow.cpp copy.

While you're on that line: the adjacent kTMate2DefaultUserInteractionTimeoutMs (MainWindow.cpp:281) is also unused — but that's pre-existing on main, not introduced here, so feel free to leave it or fold it into the same one-line cleanup, your call.

Everything else checks out. Thanks @ten9876 — the per-phase QA checklist for the bench is a nice touch given this touches every physical-controller path.


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

…ainWindow.cpp

The Phase 1a split copied this constant into MainWindow_Controllers.cpp's
anonymous namespace (its only user) but left the original behind unused.
Delete the leftover so the constant lives only next to its user.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Co-authored-by: Codex <noreply@openai.com>

@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 mechanically (deleted-vs-added multiset compare): faithful code motion — every removed line reappears verbatim in MainWindow_Controllers.cpp, except the six kCw* constants which moved to MainWindowHelpers.h as inline constexpr with identical values, as described. No dangling callers of the moved anon-namespace functions remain in MainWindow.cpp.

One fix pushed (fe2f966): kTMate2DefaultOverlayDurationMs was duplicated into the new TU rather than moved, leaving the original unused at the top of MainWindow.cpp — deleted the leftover.

Noting for a later phase: the adjacent kTMate2DefaultUserInteractionTimeoutMs was already dead before this PR (defined, never referenced anywhere) — left untouched here to keep this PR pure motion, but it can go in a future cleanup.

@jensenpat jensenpat merged commit 1fc84d7 into main Jun 11, 2026
6 checks passed
@jensenpat jensenpat deleted the refactor/3351-phase1a-controllers branch June 11, 2026 02:14
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