Skip to content

Commit

Permalink
Merge pull request #2622 from jamescowens/fix_beacon_status
Browse files Browse the repository at this point in the history
gui: Correct updateBeaconIcon() function in bitcoingui.cpp
  • Loading branch information
jamescowens authored Jan 22, 2023
2 parents d81196b + f42a352 commit 725be57
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/qt/researcher/researchermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,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) {
Expand Down
1 change: 1 addition & 0 deletions src/qt/researcher/researchermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 725be57

Please sign in to comment.