6 #include <qt/forms/ui_modaloverlay.h> 12 #include <QResizeEvent> 13 #include <QPropertyAnimation> 19 bestHeaderDate(QDateTime()),
20 layerIsVisible(false),
26 parent->installEventFilter(
this);
40 if (obj == parent()) {
41 if (ev->type() == QEvent::Resize) {
42 QResizeEvent * rev =
static_cast<QResizeEvent*
>(ev);
45 setGeometry(0, height(), width(), height());
48 else if (ev->type() == QEvent::ChildAdded) {
52 return QWidget::eventFilter(obj, ev);
57 if (ev->type() == QEvent::ParentAboutToChange) {
58 if (parent()) parent()->removeEventFilter(
this);
60 else if (ev->type() == QEvent::ParentChange) {
62 parent()->installEventFilter(
this);
66 return QWidget::event(ev);
79 QDateTime currentDate = QDateTime::currentDateTime();
82 blockProcessTime.push_front(qMakePair(currentDate.toMSecsSinceEpoch(), nVerificationProgress));
86 double progressDelta = 0;
87 double progressPerHour = 0;
89 qint64 remainingMSecs = 0;
90 double remainingProgress = 1.0 - nVerificationProgress;
95 if (sample.first < (currentDate.toMSecsSinceEpoch() - 500 * 1000) || i ==
blockProcessTime.size() - 1) {
98 progressPerHour = progressDelta / (double) timeDelta * 1000 * 3600;
99 remainingMSecs = (progressDelta > 0) ? remainingProgress / progressDelta * timeDelta : -1;
104 ui->progressIncreasePerH->setText(QString::number(progressPerHour * 100,
'f', 2)+
"%");
107 if(remainingMSecs >= 0) {
110 ui->expectedTimeLeft->setText(QObject::tr(
"unknown"));
113 static const int MAX_SAMPLES = 5000;
120 ui->newestBlockDate->setText(blockDate.toString());
123 ui->percentageProgress->setText(QString::number(nVerificationProgress*100,
'f', 2)+
"%");
124 ui->progressBar->setValue(nVerificationProgress*100);
136 if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) {
139 ui->numberOfBlocksLeft->setText(tr(
"Unknown. Syncing Headers (%1)...").arg(
bestHeaderHeight));
140 ui->expectedTimeLeft->setText(tr(
"Unknown..."));
156 if (!isVisible() && !hide)
159 setGeometry(0, hide ? 0 : height(), width(), height());
161 QPropertyAnimation* animation =
new QPropertyAnimation(
this,
"pos");
162 animation->setDuration(300);
163 animation->setStartValue(QPoint(0, hide ? 0 : this->height()));
164 animation->setEndValue(QPoint(0, hide ? this->height() : 0));
165 animation->setEasingCurve(QEasingCurve::OutQuad);
166 animation->start(QAbstractAnimation::DeleteWhenStopped);
ModalOverlay(QWidget *parent)
bool event(QEvent *ev)
Tracks parent widget changes.
bool eventFilter(QObject *obj, QEvent *ev)
void tipUpdate(int count, const QDateTime &blockDate, double nVerificationProgress)
Modal overlay to display information about the chain-sync state.
void setKnownBestHeight(int count, const QDateTime &blockDate)
int64_t nPowTargetSpacing
void showHide(bool hide=false, bool userRequested=false)
const CChainParams & Params()
Return the currently selected parameters.
QVector< QPair< qint64, double > > blockProcessTime
QString formatNiceTimeOffset(qint64 secs)
const Consensus::Params & GetConsensus() const