fix(gui): drive CWX/DVK F1-F12 shortcuts by active slice mode (#2582)#2590
Conversation
PR #2464 gated the F1-F12 / Esc ApplicationShortcuts on the panels' own showEvent/hideEvent to avoid Qt emitting activatedAmbiguously when both CwxPanel and DvkPanel had the same keys registered. As a side effect, the keys went inert whenever both side panels were hidden, breaking the user expectation (and pre-#2464 behavior) that the F-keys fire macros based on the operating mode. Move the enable decision to MainWindow::updateKeyerAvailability, where the active slice's mode is already evaluated: enable CwxPanel's set in CW/CWL and DvkPanel's set in voice modes (USB/LSB/AM/SAM/FM/ NFM/DFM). The two sets stay mutually exclusive, so Qt still sees at most one enabled ApplicationShortcut per key — no ambiguity — but the keys now fire whether or not the panels are visible. The existing mode guard inside CwxPanel's handler stays as belt-and-suspenders.
There was a problem hiding this comment.
Reviewed the diff against MainWindow.cpp and both panels.
The fix is clean and well-targeted:
- Shortcuts are constructed with
setEnabled(false)in both panels (pre-existing), so removingshowEvent/hideEventdoesn't leave a window where the shortcuts are spuriously live beforeupdateKeyerAvailabilityruns. updateKeyerAvailability(mode)is already invoked from every mode-change path inMainWindow.cpp(active-slice change, slice mode-changed, status echo at ~8788, and the initial9296call), so the newsetShortcutsEnabledcalls will fire whenever the active mode transitions.- The two sets remain mutually exclusive (
isCwvsisSsbare disjoint), preserving theactivatedAmbiguouslyguarantee from #2464. - Null guards (
if (m_cwxPanel)/if (m_dvkPanel)) match the construction order; comments in both headers and.cppfiles are updated consistently with the new behavior.
No bugs, leaks, or scope creep. Thanks @aethersdr-agent — nice tight fix for #2582.
ten9876
left a comment
There was a problem hiding this comment.
Claude here, reviewing on Jeremy's behalf.
Verdict
Clean small fix from AetherClaude. Correct architectural shift. Recommend merge.
The bug
PR #2469 (referenced as #2464 in code comments) introduced visibility-gated F1-F12 shortcuts on CwxPanel and DvkPanel to avoid Qt's activatedAmbiguously when both panels register Qt::ApplicationShortcut on the same keys. The trade-off was that shortcuts only fired when the panel was visible — which is fine if you keep the panel open, but regressed for operators who close them.
The fix
Moves the enable/disable decision from showEvent/hideEvent to MainWindow::updateKeyerAvailability(mode). The new behavior:
- Active slice mode is CW or CWL → CWX shortcuts enabled, DVK shortcuts disabled
- Active slice mode is USB/LSB/AM/SAM/FM/NFM/DFM → DVK enabled, CWX disabled
- Any other mode (RTTY, DIGU, DIGL, etc.) → both disabled
Since the CW set and SSB set are mutually exclusive, Qt only ever sees one enabled ApplicationShortcut per F-key. No ambiguity, no silent event swallowing. Each panel still functions independently when visible.
This is the right architectural shift — using mode as the proxy for should shortcut fire instead of panel visibility matches how operators think about which macros they want.
Verified
- Removed
showEvent/hideEventoverrides from both panels cleanly - Added public
setShortcutsEnabled(bool)method on each MainWindow::updateKeyerAvailabilitynow calls both setters withisCwandisSsbrespectively- The mode list inside
updateKeyerAvailability(CW/CWL for CWX; USB/LSB/AM/SAM/FM/NFM/DFM for DVK) is the same list already used elsewhere in the function to gate the panel visibility indicator — consistent - Comments updated correctly to reference both #2464 (original ambiguity workaround) and #2582 (this fix)
- All 5 CI checks green
- Auto-merge against current main is clean (no rebase needed)
One small observation
The updated comments say "Created disabled; MainWindow flips enable state", but the constructor code still uses new QShortcut(...) which defaults to enabled=true. There's a brief window between panel construction and the first updateKeyerAvailability call where both panels' shortcuts are enabled simultaneously — exactly the ambiguity case the fix is trying to avoid.
In practice this isn't a problem because MainWindow constructs the panels and connects slice signals before any user input is processed, and the first updateKeyerAvailability fires immediately when the active slice's mode is read. The race window is sub-millisecond and unreachable from user input. But for full alignment with the new docstring, adding sc->setEnabled(false); right after the setContext(Qt::ApplicationShortcut) line in each panel's constructor would make the comment factually accurate.
Not blocking — this is a doc/code alignment nit, not a behavioral bug.
Stale-code audit
- ✓
showEvent/hideEventoverrides removed cleanly; no orphans - ✓
m_shortcutsmember retained (still needed) - ✓ No other callers of the removed event handlers
- ✓
eventFilteroverride retained for Esc handling (unrelated to F1-F12 path) - ✓ Comments updated to reflect new behavior at both class members and inside the shortcut-registration loop
Recommendation
Merge after Jeremy verifies on the FLEX-8600:
- CW mode + CWX panel hidden + press F1 → CWX macro fires
- USB mode + DVK panel hidden + press F1 → DVK macro fires
- Switch slice from CW to USB while panels closed → F1 switches from CWX to DVK target without re-opening either panel
- Open CWX panel in CW mode — verify F-keys still fire (no regression)
Thanks @aethersdr-agent — the diagnosis ("visibility was the wrong proxy; mode is the right one") is exactly the architectural reframe this needed, and the comments now correctly document both #2464's ambiguity constraint and #2582's reframing. Small clean fix.
73, Jeremy KK7GWY & Claude (AI dev partner)
ten9876
left a comment
There was a problem hiding this comment.
Approved — right architectural shift, mutual exclusion preserved.
Summary
Fixes #2582
What was changed
fix(gui): drive CWX/DVK F1-F12 shortcuts by active slice mode (#2582)
Files modified
src/gui/CwxPanel.cppsrc/gui/CwxPanel.hsrc/gui/DvkPanel.cppsrc/gui/DvkPanel.hsrc/gui/MainWindow.cppGenerated by AetherClaude (automated agent for AetherSDR)