Merge #17968: qt: Ensure that ModalOverlay is resized properly

4fc1df41d5 qt: Track QEvent::Resize during animation (Hennadii Stepanov)

Pull request description:

  In certain circumstances the `ModalOverlay` widget is not sized properly:
  - #17269
  - #17967
  - https://github.com/bitcoin/bitcoin/pull/17968#pullrequestreview-350753107

  On master (f018d0c9cd) this bug looks like this:
  ![DeepinScreenshot_bitcoin-qt_20200120193402](https://user-images.githubusercontent.com/32963518/72748165-298b2a80-3bbf-11ea-810d-2966f08e496a.png)

  With this PR the wallet frame looks ok:
  ![DeepinScreenshot_bitcoin-qt_20200120195241](https://user-images.githubusercontent.com/32963518/72748388-c64dc800-3bbf-11ea-8875-1ba1899b3513.png)

  Fix #17269
  Fix #17967

ACKs for top commit:
  promag:
    Code review ACK 4fc1df41d5.
  jonasschnelli:
    utACK 4fc1df41d5

Tree-SHA512: b5d303fbc139c9383cd22edecba05e51b0d6115631aeb7d4474e973e7250a84019c11c0e41b5200e4d9ab10e17908774b45234317535857dc5314c3c28614ad4
This commit is contained in:
Jonas Schnelli 2020-05-29 10:30:27 +02:00
commit beb3844c45
No known key found for this signature in database
GPG key ID: 1EB776BB03C7922D
2 changed files with 17 additions and 11 deletions

View file

@ -5,12 +5,12 @@
#include <qt/modaloverlay.h>
#include <qt/forms/ui_modaloverlay.h>
#include <chainparams.h>
#include <qt/guiutil.h>
#include <chainparams.h>
#include <QResizeEvent>
#include <QEasingCurve>
#include <QPropertyAnimation>
#include <QResizeEvent>
ModalOverlay::ModalOverlay(bool enable_wallet, QWidget *parent) :
QWidget(parent),
@ -33,6 +33,11 @@ userClosed(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));
}
m_animation.setTargetObject(this);
m_animation.setPropertyName("pos");
m_animation.setDuration(300 /* ms */);
m_animation.setEasingCurve(QEasingCurve::OutQuad);
}
ModalOverlay::~ModalOverlay()
@ -48,6 +53,9 @@ bool ModalOverlay::eventFilter(QObject * obj, QEvent * ev) {
if (!layerIsVisible)
setGeometry(0, height(), width(), height());
if (m_animation.endValue().toPoint().y() > 0) {
m_animation.setEndValue(QPoint(0, height()));
}
}
else if (ev->type() == QEvent::ChildAdded) {
raise();
@ -166,14 +174,10 @@ void ModalOverlay::showHide(bool hide, bool userRequested)
if (!isVisible() && !hide)
setVisible(true);
setGeometry(0, hide ? 0 : height(), width(), height());
QPropertyAnimation* animation = new QPropertyAnimation(this, "pos");
animation->setDuration(300);
animation->setStartValue(QPoint(0, hide ? 0 : this->height()));
animation->setEndValue(QPoint(0, hide ? this->height() : 0));
animation->setEasingCurve(QEasingCurve::OutQuad);
animation->start(QAbstractAnimation::DeleteWhenStopped);
m_animation.setStartValue(QPoint(0, hide ? 0 : height()));
// The eventFilter() updates the endValue if it is required for QEvent::Resize.
m_animation.setEndValue(QPoint(0, hide ? height() : 0));
m_animation.start(QAbstractAnimation::KeepWhenStopped);
layerIsVisible = !hide;
}

View file

@ -6,6 +6,7 @@
#define BITCOIN_QT_MODALOVERLAY_H
#include <QDateTime>
#include <QPropertyAnimation>
#include <QWidget>
//! 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;
bool layerIsVisible;
bool userClosed;
QPropertyAnimation m_animation;
void UpdateHeaderSyncLabel();
};