7 #include "ui_modaloverlay.h" 13 #include <QResizeEvent> 14 #include <QPropertyAnimation> 20 bestHeaderDate(QDateTime()),
21 layerIsVisible(false),
25 connect(
ui->closeButton, SIGNAL(clicked()),
this, SLOT(
closeClicked()));
27 parent->installEventFilter(
this);
41 if (obj == parent()) {
42 if (ev->type() == QEvent::Resize) {
43 QResizeEvent * rev =
static_cast<QResizeEvent*
>(ev);
46 setGeometry(0, height(), width(), height());
49 else if (ev->type() == QEvent::ChildAdded) {
53 return QWidget::eventFilter(obj, ev);
58 if (ev->type() == QEvent::ParentAboutToChange) {
59 if (parent()) parent()->removeEventFilter(
this);
61 else if (ev->type() == QEvent::ParentChange) {
63 parent()->installEventFilter(
this);
67 return QWidget::event(ev);
80 QDateTime currentDate = QDateTime::currentDateTime();
83 blockProcessTime.push_front(qMakePair(currentDate.toMSecsSinceEpoch(), nVerificationProgress));
87 double progressDelta = 0;
88 double progressPerHour = 0;
90 qint64 remainingMSecs = 0;
91 double remainingProgress = 1.0 - nVerificationProgress;
96 if (sample.first < (currentDate.toMSecsSinceEpoch() - 500 * 1000) || i ==
blockProcessTime.size() - 1) {
99 progressPerHour = progressDelta / (double) timeDelta * 1000 * 3600;
100 remainingMSecs = (progressDelta > 0) ? remainingProgress / progressDelta * timeDelta : -1;
105 ui->progressIncreasePerH->setText(QString::number(progressPerHour * 100,
'f', 2)+
"%");
108 if(remainingMSecs >= 0) {
111 ui->expectedTimeLeft->setText(QObject::tr(
"unknown"));
114 static const int MAX_SAMPLES = 5000;
121 ui->newestBlockDate->setText(blockDate.toString());
124 ui->percentageProgress->setText(QString::number(nVerificationProgress*100,
'f', 2)+
"%");
125 ui->progressBar->setValue(nVerificationProgress*100);
137 if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) {
140 ui->numberOfBlocksLeft->setText(tr(
"Unknown. Syncing Headers (%1)...").arg(
bestHeaderHeight));
141 ui->expectedTimeLeft->setText(tr(
"Unknown..."));
157 if (!isVisible() && !hide)
160 setGeometry(0, hide ? 0 : height(), width(), height());
162 QPropertyAnimation* animation =
new QPropertyAnimation(
this,
"pos");
163 animation->setDuration(300);
164 animation->setStartValue(QPoint(0, hide ? 0 : this->height()));
165 animation->setEndValue(QPoint(0, hide ? this->height() : 0));
166 animation->setEasingCurve(QEasingCurve::OutQuad);
167 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