[shortcuts] Center active VFO when zooming in from keyboard#2183
Merged
Conversation
Contributor
There was a problem hiding this comment.
Nice, clean fix — the change is well-scoped and the logic is easy to follow.
What I checked:
- Null safety: Both paths are already guarded —
s(activeSlice) is checked at line 9753 inMainWindow.cpp, andao(activeOverlay) has theif (ao)guard inSpectrumWidget.cpp. No new null risks introduced. - Scope: Only the two files listed are touched, and only the zoom-in centering logic is changed. Zoom-out and pinch paths are untouched, matching the PR description.
- Conventions: No
QSettingsusage, no resource leaks, nothing outside the stated scope. - Correctness: Replacing the edge-biased offset logic (
halfBw * 0.8) with a direct center-on-VFO is the right call for keyboard/button zoom. The old code kept the signal visible but didn't keep it centered, which is exactly the #1932 complaint.
One minor observation (not blocking): on zoom-in, if the VFO frequency is near the edge of the radio's tunable range, newCenter = s->frequency() could place the center such that newCenter ± newBw/2 extends outside the valid range. This is probably clamped downstream by applyPanRangeRequest / the radio itself, but worth confirming if you haven't already.
Thanks for the contribution, @jensenpat — this is a clean and well-tested fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes #1932 by changing command zoom-in behavior to center the panadapter on the active VFO/slice instead of only nudging the center when the VFO would fall outside the newly zoomed bandwidth.
The patch is intentionally narrow:
Problem
Before this change, repeated zoom-in commands could gradually push the active signal toward the edge of the visible panadapter. The previous logic only adjusted the center if the active VFO would be outside the new bandwidth, and even then it used an 80% edge-preserving offset. That kept the signal visible, but did not keep it centered during repeated command zooms.
For issue #1932, the expected behavior is that command-style zoom-in keeps the active operating frequency centered so the operator can repeatedly zoom in without chasing the signal across the display.
Solution
The zoom-in paths now make command zoom deterministic:
MainWindow::registerShortcutActions()centers keyboard zoom-in onSliceModel::frequency()SpectrumWidgetcenters button/menu zoom-in on the active overlay frequencyThe change deliberately does not route through the broader tune centering policy or memory recall code. Memory application remains radio-native via the existing
memory applysemantics, which preserves radio-supported fields such as repeater offsets and avoids replaying an incomplete local subset of memory attributes.Validation
git diff --checkcmake --build build -j10./build/memory_recall_policy_testManual verification covered:
Closes #1932, #1866, #1722
👨🏼💻 Generated with OpenAI Codex (GPT-5.5 Pro 4/23) and tested by @jensenpat