Skip to content

DragValuePopup polish: tighten slider member types + extract constants #2987

Description

@ten9876

Context

PR #2944 added `DragValuePopup` (floating value readouts during slider drag) integrated through `GuardedSlider` and `MeterSlider`. The core implementation is solid; three small polish items came up in review that don't justify their own PRs.

Three nits to fold into one PR

1. Tighten slider member types where construction is `new GuardedSlider(...)`

`TxApplet` and `PhoneApplet` declare their slider members as `QSlider*` for historical reasons but construct them as `new GuardedSlider(Qt::Horizontal)`. After #2944, calling the new `setDragValueFormatter` method requires an awkward cast:

```cpp
m_rfPowerSlider = new GuardedSlider(Qt::Horizontal);
m_rfPowerSlider->setRange(0, 100);
static_cast<GuardedSlider*>(m_rfPowerSlider)->setDragValueFormatter(wattsText);
```

Sites to update (member declarations + the cast removal at the call site):

  • `src/gui/TxApplet.h` + `TxApplet.cpp`: `m_rfPowerSlider`, `m_tunePowerSlider`
  • `src/gui/PhoneApplet.h` + `PhoneApplet.cpp`: `m_amCarrierSlider`, `m_voxLevelSlider`, `m_dexpSlider`

Pure type-tightening. Zero behavior change. After the change, the callsites become:
```cpp
m_rfPowerSlider->setDragValueFormatter(wattsText);
```

2. EQ formatter consistency

The EQ dB formatter in `src/gui/EqApplet.cpp` is an inline lambda:
```cpp
slider->setDragValueFormatter([](int v) {
return QStringLiteral("%1%2 dB")
.arg(v > 0 ? QStringLiteral("+") : QString())
.arg(v);
});
```

The other applets use free functions at file scope (`wattsText`, `percentText`, `panText`). Extract this to a static `dbWithSignText(int)` helper for symmetry. Trivial.

3. Named constant for the 450 ms linger

In `src/gui/DragValuePopup.h`, `linger(int msec = 450)` has the value baked into the default-argument literal. Extract to a named constant in the .cpp or .h so the source comment in #2944's PR body about "intentionally chose 450 ms" lives next to the value rather than in PR archeology.

Suggested:
```cpp
// DragValuePopup.h
static constexpr int kDefaultLingerMs = 450; // brief "memory cue" after release
void linger(int msec = kDefaultLingerMs);
```

Effort

~30 minutes for all three combined. None individually justify the overhead of a PR; bundled into one they're a tidy housekeeping pass.

References

Metadata

Metadata

Assignees

Labels

GUIUser interfaceenhancementImprovement to existing featuregood first issueGood for newcomersmaintainer-reviewRequires maintainer review before any action is takenpriority: lowLow priority

Type

No type

Fields

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