5#include <qt/forms/ui_modaloverlay.h>
8#include <chainparams.h>
11#include <QEasingCurve>
12#include <QPropertyAnimation>
13#include <QResizeEvent>
17 bestHeaderDate(QDateTime()), layerIsVisible(false), userClosed(false) {
19 connect(
ui->closeButton, &QPushButton::clicked,
this,
22 parent->installEventFilter(
this);
29 ui->infoText->setVisible(
false);
30 ui->infoTextStrong->setText(
31 tr(
"%1 is currently syncing. It will download headers "
32 "and blocks from peers and validate them until reaching the tip "
33 "of the block chain.")
48 if (obj == parent()) {
49 if (ev->type() == QEvent::Resize) {
50 QResizeEvent *rev =
static_cast<QResizeEvent *
>(ev);
53 setGeometry(0, height(), width(), height());
59 }
else if (ev->type() == QEvent::ChildAdded) {
63 return QWidget::eventFilter(obj, ev);
68 if (ev->type() == QEvent::ParentAboutToChange) {
70 parent()->removeEventFilter(
this);
72 }
else if (ev->type() == QEvent::ParentChange) {
74 parent()->installEventFilter(
this);
78 return QWidget::event(ev);
94 double nVerificationProgress) {
95 QDateTime currentDate = QDateTime::currentDateTime();
99 qMakePair(currentDate.toMSecsSinceEpoch(), nVerificationProgress));
103 double progressDelta = 0;
104 double progressPerHour = 0;
105 qint64 timeDelta = 0;
106 qint64 remainingMSecs = 0;
107 double remainingProgress = 1.0 - nVerificationProgress;
112 if (sample.first < (currentDate.toMSecsSinceEpoch() - 500 * 1000) ||
117 progressDelta / (double)timeDelta * 1000 * 3600;
120 ? remainingProgress / progressDelta * timeDelta
126 ui->progressIncreasePerH->setText(
127 QString::number(progressPerHour * 100,
'f', 2) +
"%");
130 if (remainingMSecs >= 0) {
131 ui->expectedTimeLeft->setText(
134 ui->expectedTimeLeft->setText(QObject::tr(
"unknown"));
137 static const int MAX_SAMPLES = 5000;
145 ui->newestBlockDate->setText(blockDate.toString());
148 ui->percentageProgress->setText(
149 QString::number(nVerificationProgress * 100,
'f', 2) +
"%");
150 ui->progressBar->setValue(nVerificationProgress * 100);
165 ui->numberOfBlocksLeft->setText(
169 ui->expectedTimeLeft->setText(tr(
"Unknown..."));
174 int est_headers_left =
bestHeaderDate.secsTo(QDateTime::currentDateTime()) /
176 ui->numberOfBlocksLeft->setText(
177 tr(
"Unknown. Syncing Headers (%1, %2%)...")
185 const QDateTime &blockDate) {
186 int est_headers_left = blockDate.secsTo(QDateTime::currentDateTime()) /
188 ui->numberOfBlocksLeft->setText(
189 tr(
"Unknown. Pre-syncing Headers (%1, %2%)…")
191 .arg(QString::number(100.0 / (height + est_headers_left) * height,
210 if (!isVisible() && !hide) {
214 m_animation.setStartValue(QPoint(0, hide ? 0 : height()));
217 m_animation.setEndValue(QPoint(0, hide ? height() : 0));
218 m_animation.start(QAbstractAnimation::KeepWhenStopped);
const CChainParams & Params()
Return the currently selected parameters.
const Consensus::Params & GetConsensus() const
Modal overlay to display information about the chain-sync state.
void showHide(bool hide=false, bool userRequested=false)
bool event(QEvent *ev) override
Tracks parent widget changes.
void tipUpdate(int count, const QDateTime &blockDate, double nVerificationProgress)
void UpdateHeaderSyncLabel()
ModalOverlay(bool enable_wallet, QWidget *parent)
void triggered(bool hidden)
void setKnownBestHeight(int count, const QDateTime &blockDate, bool presync)
QVector< QPair< qint64, double > > blockProcessTime
bool eventFilter(QObject *obj, QEvent *ev) override
void UpdateHeaderPresyncLabel(int height, const QDateTime &blockDate)
QPropertyAnimation m_animation
static constexpr int HEADER_HEIGHT_DELTA_SYNC
The required delta of headers to the estimated number of available headers until we show the IBD prog...
QString formatNiceTimeOffset(qint64 secs)
int64_t nPowTargetSpacing