From 24a2d8a86fec19acedbb2274ec384ec2815451a6 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sat, 24 Apr 2021 11:15:15 -0400 Subject: [PATCH] Wait for smooth scrolling animation to add new message (#2084) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Co-authored-by: pajlada --- CHANGELOG.md | 2 ++ src/widgets/Scrollbar.cpp | 5 +++++ src/widgets/Scrollbar.hpp | 2 ++ src/widgets/helper/ChannelView.cpp | 12 ++++++++++++ 4 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a05eeda4..75096b5d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unversioned +- Bugfix: Fixed visual glitch with smooth scrolling. (#2084) + ## 2.3.0 - Major: Added custom FrankerFaceZ VIP Badges. (#2628) diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index 399329b94..c581723b6 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -188,6 +188,11 @@ qreal Scrollbar::getCurrentValue() const return this->currentValue_; } +const QPropertyAnimation &Scrollbar::getCurrentValueAnimation() const +{ + return this->currentValueAnimation_; +} + void Scrollbar::offset(qreal value) { if (this->currentValueAnimation_.state() == QPropertyAnimation::Running) diff --git a/src/widgets/Scrollbar.hpp b/src/widgets/Scrollbar.hpp index 09cbeb2c5..ff6cbc76c 100644 --- a/src/widgets/Scrollbar.hpp +++ b/src/widgets/Scrollbar.hpp @@ -44,6 +44,8 @@ public: qreal getDesiredValue() const; qreal getCurrentValue() const; + const QPropertyAnimation &getCurrentValueAnimation() const; + // offset the desired value without breaking smooth scolling void offset(qreal value); pajlada::Signals::NoArgSignal &getCurrentValueChanged(); diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 01e313383..f67151575 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -785,6 +785,18 @@ void ChannelView::messageAppended(MessagePtr &message, this->lastMessageHasAlternateBackground_ = !this->lastMessageHasAlternateBackground_; + if (!this->scrollBar_->isAtBottom() && + this->scrollBar_->getCurrentValueAnimation().state() == + QPropertyAnimation::Running) + { + QEventLoop loop; + + connect(&this->scrollBar_->getCurrentValueAnimation(), + &QAbstractAnimation::stateChanged, &loop, &QEventLoop::quit); + + loop.exec(); + } + if (this->messages_.pushBack(MessageLayoutPtr(messageRef), deleted)) { if (this->paused())