Skip to content

[gui] FreeDvReporterModel: migrate hardcoded TX/RX/Msg highlight colors to ThemeManager tokens #3446

@ten9876

Description

@ten9876

Follow-up to #3439 (merged as 8679cdb). Surfaced during review — the FreeDV Reporter dialog itself uses ThemeManager tokens (`{{color.background.0}}`, `{{color.text.primary}}`, etc.) throughout, but the row-highlight backgrounds in `FreeDvReporterModel.cpp` are still three hardcoded `QColor` constants.

The hardcoded constants

`src/gui/FreeDvReporterModel.cpp:18-20`:

```cpp
const QColor kTxBg {0xfc, 0x45, 0x00}; // orange (#fc4500)
const QColor kRxBg {0x37, 0x9b, 0xaf}; // teal (#379baf)
const QColor kMsgBg{0xe5, 0x8b, 0xe5}; // purple (#e58be5)
```

These drive the row `Qt::BackgroundRole` when a station is actively transmitting (`kTxBg`), recently RX'd (`kRxBg`, fades after a timeout), or has a recent message (`kMsgBg`, fades after a timeout).

Why migrate

  1. Theme consistency. Every other surface in the dialog already pulls from ThemeManager — these three constants are the only chrome that doesn't follow the active theme. A future light-mode or high-contrast theme would render the rest of the dialog correctly while leaving these three rows looking off.
  2. The TX token already exists. `ThemeManager` already exposes `color.background.tx` (a TX-state background token used elsewhere in the chrome). `kTxBg` should consume that token; if the resolved value differs from `#fc4500`, that's a theme inconsistency worth resolving in the token, not in this file.
  3. Accessibility. Per docs/a11y.md "Colour contrast" (added in docs(a11y): add WCAG/POUR grounding, colour contrast, manual-test sections #3443), highlight backgrounds need WCAG 4.5:1 contrast against the foreground text. The current hex values were picked visually; running them through the ThemeManager pipeline lets a future high-contrast theme override them without touching this file.

Existing tokens vs new tokens needed

Constant Hex Existing token? Action
`kTxBg` `#fc4500` orange ✅ `color.background.tx` exists Consume it. If the resolved value differs, fix the token, not the file.
`kRxBg` `#379baf` teal ❌ No `color.background.rx` yet Add a new token. Suggested: `color.background.rx` (mirrors `.tx` naming).
`kMsgBg` `#e58be5` purple ❌ No semantic token for "message" Add a new token. Suggested: `color.background.message` or `color.accent.message`.

Migration sketch

  1. Add the two missing tokens (`color.background.rx`, `color.background.message`) to ThemeManager's theme JSON files for each active theme variant.
  2. Replace the three `QColor` constants with calls to `ThemeManager::instance().resolveColor(...)` (or whatever the consuming API is for non-stylesheet contexts — TableView background roles are returned as `QVariant` from `data()`, not painted via stylesheets, so this needs the C++ accessor not the `{{token}}` substitution).
  3. Verify the highlight expiration tick (`onHighlightTick` at `FreeDvReporterModel.cpp`) still re-renders the row when the resolved color changes — should be automatic via the existing `dataChanged` emit.

Scope notes

  • Out of scope: any other model files in `src/gui/` that may have similar hardcoded highlight colors. If grep finds them while touching the theme JSON, separate issue.
  • Out of scope: the dialog's existing `{{color.*}}` token usage — that's already correct.

Test plan

  • Build clean on all three platforms.
  • Visual parity check: open FreeDV Reporter, trigger a TX (other station), an RX, and a message, confirm the three highlight backgrounds render at the resolved colors.
  • Theme switch test (if the project has multiple themes wired up): switch theme, confirm highlights change.

Refs #3439

Metadata

Metadata

Assignees

Labels

GUIUser interfaceenhancementImprovement to existing featuremaintainer-reviewRequires maintainer review before any action is taken

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions