| 56 | // --- Public interface -------------------------------------------------------- |
| 57 | |
| 58 | void SMeterWidget::setLevel(float dbm) |
| 59 | { |
| 60 | m_receiveMeterReadingActive = false; |
| 61 | m_levelDbm = dbm; |
| 62 | |
| 63 | // Peak hold (existing needle/triangle behavior) |
| 64 | if (dbm > m_peakDbm) { |
| 65 | m_peakDbm = dbm; |
| 66 | m_peakDecay.start(); |
| 67 | } |
| 68 | |
| 69 | // Configurable peak hold line |
| 70 | if (m_peakHoldEnabled) { |
| 71 | if (dbm > m_peakHoldDbm) { |
| 72 | m_peakHoldDbm = dbm; |
| 73 | m_peakHoldDecayStartDbm = dbm; |
| 74 | m_peakHoldTimer.start(); |
| 75 | m_peakHoldTimerRunning = true; |
| 76 | } |
| 77 | updatePeakHoldValue(); |
| 78 | } |
| 79 | |
| 80 | updateNeedleTarget(); |
| 81 | |
| 82 | if (!m_transmitting) { |
| 83 | update(); |
| 84 | if (hasFocus() && QAccessible::isActive()) { |
| 85 | // Announce the same value that paintEvent displays — in Peak mode |
| 86 | // the needle and text readout track m_peakDbm, not the raw level. |
| 87 | const float displayDbm = (m_rxMode == RxMode::SMeterPeak) ? m_peakDbm : m_levelDbm; |
| 88 | QString sText; |
| 89 | if (displayDbm <= S0_DBM) |
| 90 | sText = QStringLiteral("S0"); |
| 91 | else if (displayDbm <= S9_DBM) |
| 92 | sText = QStringLiteral("S%1").arg(qBound(0, qRound((displayDbm - S0_DBM) / DB_PER_S), 9)); |
| 93 | else |
| 94 | sText = QStringLiteral("S9+%1").arg(qRound(displayDbm - S9_DBM)); |
| 95 | const QString accessText = sText + QStringLiteral(", ") |
| 96 | + QString::number(static_cast<int>(displayDbm)) |
| 97 | + QStringLiteral(" dBm"); |
| 98 | QAccessibleValueChangeEvent event(this, accessText); |
| 99 | QAccessible::updateAccessibility(&event); |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | void SMeterWidget::setReceiveMeterReading( |
| 105 | const KiwiSdrProtocol::MeterReading& reading) |
no test coverage detected