| 791 | } |
| 792 | |
| 793 | void HealthApplet::updateStatusLabels(const AntennaHealthSample& sample, |
| 794 | MeterSource source) |
| 795 | { |
| 796 | if (!m_statusLabel) |
| 797 | return; |
| 798 | |
| 799 | m_lastSource = source; |
| 800 | m_sourceLabel->setText(QStringLiteral("SRC %1").arg(sourceText(source))); |
| 801 | m_swrLabel->setText(QStringLiteral("SWR %1").arg(sample.swr, 0, 'f', 2)); |
| 802 | m_returnLossLabel->setText(sample.active |
| 803 | ? QStringLiteral("RL %1dB").arg(sample.returnLossDb, 0, 'f', 0) |
| 804 | : QStringLiteral("RL --")); |
| 805 | m_powerLabel->setText(QStringLiteral("PWR %1").arg(formatPower(sample.powerWatts))); |
| 806 | m_varianceLabel->setText(sample.active |
| 807 | ? QStringLiteral("VAR %1").arg(m_swrSpan, 0, 'f', 2) |
| 808 | : QStringLiteral("VAR --")); |
| 809 | |
| 810 | if (!sample.active) { |
| 811 | m_statusLabel->setText(QStringLiteral("IDLE")); |
| 812 | applyPillStyle(m_statusLabel, QStringLiteral("color.background.0"), |
| 813 | QStringLiteral("color.border.strong"), |
| 814 | QStringLiteral("color.text.secondary")); |
| 815 | m_scoreLabel->setText(QStringLiteral("--")); |
| 816 | applyLabelStyle(m_scoreLabel, QStringLiteral("color.text.primary"), 11, true); |
| 817 | return; |
| 818 | } |
| 819 | |
| 820 | const int score = std::clamp(static_cast<int>(std::round(100.0f - sample.severity * 72.0f)), |
| 821 | 0, 100); |
| 822 | m_scoreLabel->setText(QString::number(score)); |
| 823 | |
| 824 | if (sample.severity >= 0.72f) { |
| 825 | m_statusLabel->setText(QStringLiteral("GROUND?")); |
| 826 | applyPillStyle(m_statusLabel, QStringLiteral("color.background.tx"), |
| 827 | QStringLiteral("color.accent.danger"), |
| 828 | QStringLiteral("color.accent.danger")); |
| 829 | applyLabelStyle(m_scoreLabel, QStringLiteral("color.accent.danger"), 11, true); |
| 830 | } else if (sample.severity >= 0.34f) { |
| 831 | m_statusLabel->setText(QStringLiteral("WATCH")); |
| 832 | applyPillStyle(m_statusLabel, QStringLiteral("color.background.tx"), |
| 833 | QStringLiteral("color.accent.warning"), |
| 834 | QStringLiteral("color.accent.warning")); |
| 835 | applyLabelStyle(m_scoreLabel, QStringLiteral("color.accent.warning"), 11, true); |
| 836 | } else { |
| 837 | m_statusLabel->setText(QStringLiteral("OK")); |
| 838 | applyPillStyle(m_statusLabel, QStringLiteral("color.background.1"), |
| 839 | QStringLiteral("color.accent.success"), |
| 840 | QStringLiteral("color.accent.success")); |
| 841 | applyLabelStyle(m_scoreLabel, QStringLiteral("color.accent.success"), 11, true); |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | QString HealthApplet::sourceText(MeterSource source) const |
| 846 | { |
nothing calls this directly
no test coverage detected