Add collapsible slice receiver flags#1166
Conversation
Clicking the slice letter badge (A/B/C/etc) toggles the VFO flag between full and collapsed modes. Collapsed mode shows only the slice letter, TX indicator, and frequency — saving screen space when multiple slices are active. Features: - Click slice letter to collapse/expand the flag - Collapsed state shows painted slice badge, TX indicator, and floating frequency label - TX toggle works in collapsed mode (click TX badge area) - Scroll-to-tune works in collapsed mode - Collapsed state persists per-slice via AppSettings - All child widgets set WA_TransparentForMouseEvents when collapsed to prevent phantom clicks on hidden buttons - Extended slice letter table from A-D to A-H for 8-slice support
There was a problem hiding this comment.
Pull request overview
Adds a collapsible “slice flag” mode to VfoWidget to reduce on-screen space usage when multiple slices are active, while keeping key interactions (TX toggle and scroll-to-tune) available in the collapsed state.
Changes:
- Introduces collapsed/expanded state handling in
VfoWidget, including persistence viaAppSettings. - Implements collapsed-mode painting (slice badge + TX badge) and a floating frequency label.
- Extends slice letter display mapping from A–D to A–H.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/gui/VfoWidget.h |
Adds collapsed-state API/state and tracking for widgets hidden during collapse. |
src/gui/VfoWidget.cpp |
Implements collapse/expand behavior, collapsed painting + interactions, persistence, and positioning for the floating frequency label. |
Comments suppressed due to low confidence (1)
src/gui/VfoWidget.cpp:2595
- Expanded-mode slice badge color uses
kSliceColors[id]only whenid < kSliceColorCount(4), so slices E–H will not get a consistent per-slice color even though letters now support 8. Align with SliceColors.h’s documentedsliceId % 4indexing so colors cycle instead of falling back.
const char letters[] = "ABCDEFGH";
int id = m_slice->sliceId();
m_sliceBadge->setText(QString(QChar(id >= 0 && id < 8 ? letters[id] : '?')));
// Color-code the slice badge to match the spectrum overlay colors
const char* badgeColor = (id >= 0 && id < kSliceColorCount)
? kSliceColors[id].hexActive : "#0070c0";
m_sliceBadge->setStyleSheet(
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| bool m_lastOnLeft{true}; | ||
| float m_signalDbm{-130.0f}; | ||
| bool m_collapsed{false}; | ||
| bool m_collapseToggled{false}; // guard: absorb release after toggle |
There was a problem hiding this comment.
m_collapseToggled is declared but never read or written anywhere in the implementation, so it’s dead state (and will likely trigger unused-field warnings). Either remove this member or implement the intended guard logic in the mouse handlers so the variable is meaningful.
| bool m_collapseToggled{false}; // guard: absorb release after toggle |
| // Click anywhere else on collapsed widget → expand (deferred) | ||
| QTimer::singleShot(0, this, [this] { setCollapsed(false); }); |
There was a problem hiding this comment.
In collapsed mode, the widget expands on any mouse button because this path isn’t gated on Qt::LeftButton. This makes right/middle clicks (e.g., context-menu clicks) unexpectedly expand the flag. Restrict the expand toggle to the intended button(s).
| // Click anywhere else on collapsed widget → expand (deferred) | |
| QTimer::singleShot(0, this, [this] { setCollapsed(false); }); | |
| // Left-click anywhere else on collapsed widget → expand (deferred) | |
| if (ev->button() == Qt::LeftButton) { | |
| QTimer::singleShot(0, this, [this] { setCollapsed(false); }); | |
| } |
| const char* badgeColor = (sliceId >= 0 && sliceId < kSliceColorCount) | ||
| ? kSliceColors[sliceId].hexActive : "#0070c0"; |
There was a problem hiding this comment.
Collapsed-mode badge coloring only uses kSliceColors[sliceId] when sliceId < kSliceColorCount, but kSliceColorCount is 4 (and SliceColors.h documents indexing by sliceId % 4). With 8-slice letters enabled, sliceIds 4–7 will fall back to the default color instead of cycling the defined colors. Use modulo (and keep the bounds check) so colors remain consistent for higher sliceIds.
| const char* badgeColor = (sliceId >= 0 && sliceId < kSliceColorCount) | |
| ? kSliceColors[sliceId].hexActive : "#0070c0"; | |
| const char* badgeColor = (sliceId >= 0 && kSliceColorCount > 0) | |
| ? kSliceColors[sliceId % kSliceColorCount].hexActive : "#0070c0"; |
| // Keep collapsed frequency label in sync | ||
| if (m_collapsed && m_collapsedFreqLabel) { | ||
| m_collapsedFreqLabel->setText(freqText); | ||
| m_collapsedFreqLabel->adjustSize(); |
There was a problem hiding this comment.
When collapsed, updateFreqLabel() updates and adjustSize()s the floating frequency label but doesn’t reposition it afterward. If the text width changes (e.g., MHz digit count), the label can drift and overlap/leave an incorrect gap relative to the collapsed flag until the next updatePosition() call. Recompute/move the label after resizing so it stays correctly anchored to the flag.
| m_collapsedFreqLabel->adjustSize(); | |
| m_collapsedFreqLabel->adjustSize(); | |
| updatePosition(); |
|
I snuck in the 8-slice letter support in this one. It kept showing question marks '?' for some slices for me. |
Clicking the slice letter badge (A/B/C/etc) toggles the VFO flag between full and collapsed modes. Collapsed mode shows only the slice letter, TX indicator, and frequency — saving screen space when multiple slices are active.
Features
WA_TransparentForMouseEventswhen collapsed to prevent phantom clicks on hidden buttonsChanges
VfoWidget.h: Added collapsed state,setCollapsed()/isCollapsed(),mouseReleaseEvent()override, collapsed freq label, hidden-widget tracking setVfoWidget.cpp: Collapse/expand toggle logic, collapsed-mode painting, per-slice persistence, deferred toggle viaQTimer::singleShotto avoid mouse event leaksTesting