mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 03:03:22 -03:00
qt: Track QEvent::Resize during animation
This commit is contained in:
parent
d4fc9aeb8b
commit
4fc1df41d5
2 changed files with 17 additions and 11 deletions
|
@ -5,12 +5,12 @@
|
||||||
#include <qt/modaloverlay.h>
|
#include <qt/modaloverlay.h>
|
||||||
#include <qt/forms/ui_modaloverlay.h>
|
#include <qt/forms/ui_modaloverlay.h>
|
||||||
|
|
||||||
|
#include <chainparams.h>
|
||||||
#include <qt/guiutil.h>
|
#include <qt/guiutil.h>
|
||||||
|
|
||||||
#include <chainparams.h>
|
#include <QEasingCurve>
|
||||||
|
|
||||||
#include <QResizeEvent>
|
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
#include <QResizeEvent>
|
||||||
|
|
||||||
ModalOverlay::ModalOverlay(bool enable_wallet, QWidget *parent) :
|
ModalOverlay::ModalOverlay(bool enable_wallet, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
|
@ -33,6 +33,11 @@ userClosed(false)
|
||||||
ui->infoText->setVisible(false);
|
ui->infoText->setVisible(false);
|
||||||
ui->infoTextStrong->setText(tr("%1 is currently syncing. It will download headers and blocks from peers and validate them until reaching the tip of the block chain.").arg(PACKAGE_NAME));
|
ui->infoTextStrong->setText(tr("%1 is currently syncing. It will download headers and blocks from peers and validate them until reaching the tip of the block chain.").arg(PACKAGE_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_animation.setTargetObject(this);
|
||||||
|
m_animation.setPropertyName("pos");
|
||||||
|
m_animation.setDuration(300 /* ms */);
|
||||||
|
m_animation.setEasingCurve(QEasingCurve::OutQuad);
|
||||||
}
|
}
|
||||||
|
|
||||||
ModalOverlay::~ModalOverlay()
|
ModalOverlay::~ModalOverlay()
|
||||||
|
@ -48,6 +53,9 @@ bool ModalOverlay::eventFilter(QObject * obj, QEvent * ev) {
|
||||||
if (!layerIsVisible)
|
if (!layerIsVisible)
|
||||||
setGeometry(0, height(), width(), height());
|
setGeometry(0, height(), width(), height());
|
||||||
|
|
||||||
|
if (m_animation.endValue().toPoint().y() > 0) {
|
||||||
|
m_animation.setEndValue(QPoint(0, height()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (ev->type() == QEvent::ChildAdded) {
|
else if (ev->type() == QEvent::ChildAdded) {
|
||||||
raise();
|
raise();
|
||||||
|
@ -166,14 +174,10 @@ void ModalOverlay::showHide(bool hide, bool userRequested)
|
||||||
if (!isVisible() && !hide)
|
if (!isVisible() && !hide)
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
|
||||||
setGeometry(0, hide ? 0 : height(), width(), height());
|
m_animation.setStartValue(QPoint(0, hide ? 0 : height()));
|
||||||
|
// The eventFilter() updates the endValue if it is required for QEvent::Resize.
|
||||||
QPropertyAnimation* animation = new QPropertyAnimation(this, "pos");
|
m_animation.setEndValue(QPoint(0, hide ? height() : 0));
|
||||||
animation->setDuration(300);
|
m_animation.start(QAbstractAnimation::KeepWhenStopped);
|
||||||
animation->setStartValue(QPoint(0, hide ? 0 : this->height()));
|
|
||||||
animation->setEndValue(QPoint(0, hide ? this->height() : 0));
|
|
||||||
animation->setEasingCurve(QEasingCurve::OutQuad);
|
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
|
||||||
layerIsVisible = !hide;
|
layerIsVisible = !hide;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#define BITCOIN_QT_MODALOVERLAY_H
|
#define BITCOIN_QT_MODALOVERLAY_H
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QPropertyAnimation>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
//! The required delta of headers to the estimated number of available headers until we show the IBD progress
|
//! The required delta of headers to the estimated number of available headers until we show the IBD progress
|
||||||
|
@ -45,6 +46,7 @@ private:
|
||||||
QVector<QPair<qint64, double> > blockProcessTime;
|
QVector<QPair<qint64, double> > blockProcessTime;
|
||||||
bool layerIsVisible;
|
bool layerIsVisible;
|
||||||
bool userClosed;
|
bool userClosed;
|
||||||
|
QPropertyAnimation m_animation;
|
||||||
void UpdateHeaderSyncLabel();
|
void UpdateHeaderSyncLabel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue