From f42a352d96540f6785d464c4df54a21788b3d2d9 Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Sat, 7 Jan 2023 23:20:43 -0500 Subject: [PATCH] Correct updateBeaconIcon() function in bitcoingui.cpp This function now properly handles pending beacons when the original beacon is either expired or not expired. --- src/qt/bitcoingui.cpp | 27 ++++++++++++++++++--------- src/qt/researcher/researchermodel.cpp | 9 +++++++++ src/qt/researcher/researchermodel.h | 1 + 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index bc7b1e9f08..7a382f855d 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1859,23 +1859,32 @@ void BitcoinGUI::updateBeaconIcon() labelBeaconIcon->show(); labelBeaconIcon->setPixmap(GRC::ScaleStatusIcon(this, researcherModel->getBeaconStatusIcon())); - if (researcherModel->beaconExpired()) { + if (researcherModel->hasPendingBeacon()) { + labelBeaconIcon->setToolTip(tr("CPID: %1\n" + "Time left to activate: %2" + "%3") + .arg(researcherModel->formatCpid(), + researcherModel->formatTimeToPendingBeaconExpiration(), + researcherModel->formatBeaconStatus())); + } else if (researcherModel->beaconExpired()) { labelBeaconIcon->setToolTip(tr("CPID: %1\n" "Beacon age: %2\n" "Current beacon expired!\n" "%3") - .arg(researcherModel->formatCpid()) - .arg(researcherModel->formatBeaconAge()) - .arg(researcherModel->formatBeaconStatus())); - } else { + .arg(researcherModel->formatCpid(), + researcherModel->formatBeaconAge(), + researcherModel->formatBeaconStatus())); + } else if (researcherModel->hasActiveBeacon()) { labelBeaconIcon->setToolTip(tr("CPID: %1\n" "Beacon age: %2\n" "Expires: %3\n" "%4") - .arg(researcherModel->formatCpid()) - .arg(researcherModel->formatBeaconAge()) - .arg(researcherModel->formatTimeToBeaconExpiration()) - .arg(researcherModel->formatBeaconStatus())); + .arg(researcherModel->formatCpid(), + researcherModel->formatBeaconAge(), + researcherModel->formatTimeToBeaconExpiration(), + researcherModel->formatBeaconStatus())); + } else { + labelBeaconIcon->setToolTip(researcherModel->formatBeaconStatus()); } } diff --git a/src/qt/researcher/researchermodel.cpp b/src/qt/researcher/researchermodel.cpp index e894e37539..21752d351f 100644 --- a/src/qt/researcher/researchermodel.cpp +++ b/src/qt/researcher/researchermodel.cpp @@ -413,6 +413,15 @@ QString ResearcherModel::formatTimeToBeaconExpiration() const return GUIUtil::formatDurationStr(Beacon::MAX_AGE - m_beacon->Age(GetAdjustedTime())); } +QString ResearcherModel::formatTimeToPendingBeaconExpiration() const +{ + if (!m_pending_beacon) { + return QString(); + } + + return GUIUtil::formatDurationStr(PendingBeacon::RETENTION_AGE - m_pending_beacon->Age(GetAdjustedTime())); +} + QString ResearcherModel::formatBeaconAddress() const { if (!m_beacon) { diff --git a/src/qt/researcher/researchermodel.h b/src/qt/researcher/researchermodel.h index 07e1b07c88..480fac6ee2 100644 --- a/src/qt/researcher/researchermodel.h +++ b/src/qt/researcher/researchermodel.h @@ -115,6 +115,7 @@ class ResearcherModel : public QObject QString formatBeaconStatus() const; QString formatBeaconAge() const; QString formatTimeToBeaconExpiration() const; + QString formatTimeToPendingBeaconExpiration() const; QString formatBeaconAddress() const; QString formatBeaconVerificationCode() const;