Skip to content

Commit 4fc1df4

Browse files
committed
qt: Track QEvent::Resize during animation
1 parent d4fc9ae commit 4fc1df4

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/qt/modaloverlay.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
#include <qt/modaloverlay.h>
66
#include <qt/forms/ui_modaloverlay.h>
77

8-
#include <qt/guiutil.h>
9-
108
#include <chainparams.h>
9+
#include <qt/guiutil.h>
1110

12-
#include <QResizeEvent>
11+
#include <QEasingCurve>
1312
#include <QPropertyAnimation>
13+
#include <QResizeEvent>
1414

1515
ModalOverlay::ModalOverlay(bool enable_wallet, QWidget *parent) :
1616
QWidget(parent),
@@ -33,6 +33,11 @@ userClosed(false)
3333
ui->infoText->setVisible(false);
3434
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));
3535
}
36+
37+
m_animation.setTargetObject(this);
38+
m_animation.setPropertyName("pos");
39+
m_animation.setDuration(300 /* ms */);
40+
m_animation.setEasingCurve(QEasingCurve::OutQuad);
3641
}
3742

3843
ModalOverlay::~ModalOverlay()
@@ -48,6 +53,9 @@ bool ModalOverlay::eventFilter(QObject * obj, QEvent * ev) {
4853
if (!layerIsVisible)
4954
setGeometry(0, height(), width(), height());
5055

56+
if (m_animation.endValue().toPoint().y() > 0) {
57+
m_animation.setEndValue(QPoint(0, height()));
58+
}
5159
}
5260
else if (ev->type() == QEvent::ChildAdded) {
5361
raise();
@@ -166,14 +174,10 @@ void ModalOverlay::showHide(bool hide, bool userRequested)
166174
if (!isVisible() && !hide)
167175
setVisible(true);
168176

169-
setGeometry(0, hide ? 0 : height(), width(), height());
170-
171-
QPropertyAnimation* animation = new QPropertyAnimation(this, "pos");
172-
animation->setDuration(300);
173-
animation->setStartValue(QPoint(0, hide ? 0 : this->height()));
174-
animation->setEndValue(QPoint(0, hide ? this->height() : 0));
175-
animation->setEasingCurve(QEasingCurve::OutQuad);
176-
animation->start(QAbstractAnimation::DeleteWhenStopped);
177+
m_animation.setStartValue(QPoint(0, hide ? 0 : height()));
178+
// The eventFilter() updates the endValue if it is required for QEvent::Resize.
179+
m_animation.setEndValue(QPoint(0, hide ? height() : 0));
180+
m_animation.start(QAbstractAnimation::KeepWhenStopped);
177181
layerIsVisible = !hide;
178182
}
179183

src/qt/modaloverlay.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define BITCOIN_QT_MODALOVERLAY_H
77

88
#include <QDateTime>
9+
#include <QPropertyAnimation>
910
#include <QWidget>
1011

1112
//! The required delta of headers to the estimated number of available headers until we show the IBD progress
@@ -45,6 +46,7 @@ public Q_SLOTS:
4546
QVector<QPair<qint64, double> > blockProcessTime;
4647
bool layerIsVisible;
4748
bool userClosed;
49+
QPropertyAnimation m_animation;
4850
void UpdateHeaderSyncLabel();
4951
};
5052

0 commit comments

Comments
 (0)