5
5
#include < qt/modaloverlay.h>
6
6
#include < qt/forms/ui_modaloverlay.h>
7
7
8
- #include < qt/guiutil.h>
9
-
10
8
#include < chainparams.h>
9
+ #include < qt/guiutil.h>
11
10
12
- #include < QResizeEvent >
11
+ #include < QEasingCurve >
13
12
#include < QPropertyAnimation>
13
+ #include < QResizeEvent>
14
14
15
15
ModalOverlay::ModalOverlay (bool enable_wallet, QWidget *parent) :
16
16
QWidget(parent),
@@ -33,6 +33,11 @@ userClosed(false)
33
33
ui->infoText ->setVisible (false );
34
34
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));
35
35
}
36
+
37
+ m_animation.setTargetObject (this );
38
+ m_animation.setPropertyName (" pos" );
39
+ m_animation.setDuration (300 /* ms */ );
40
+ m_animation.setEasingCurve (QEasingCurve::OutQuad);
36
41
}
37
42
38
43
ModalOverlay::~ModalOverlay ()
@@ -48,6 +53,9 @@ bool ModalOverlay::eventFilter(QObject * obj, QEvent * ev) {
48
53
if (!layerIsVisible)
49
54
setGeometry (0 , height (), width (), height ());
50
55
56
+ if (m_animation.endValue ().toPoint ().y () > 0 ) {
57
+ m_animation.setEndValue (QPoint (0 , height ()));
58
+ }
51
59
}
52
60
else if (ev->type () == QEvent::ChildAdded) {
53
61
raise ();
@@ -166,14 +174,10 @@ void ModalOverlay::showHide(bool hide, bool userRequested)
166
174
if (!isVisible () && !hide)
167
175
setVisible (true );
168
176
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);
177
181
layerIsVisible = !hide;
178
182
}
179
183
0 commit comments