From bc54927c840cb4364caf46e29387cfbd0f46168d Mon Sep 17 00:00:00 2001 From: fourtf Date: Tue, 19 Jun 2018 20:34:50 +0200 Subject: [PATCH] fixed smooth scrolling --- src/providers/twitch/twitchchannel.cpp | 8 +++++--- src/widgets/helper/channelview.cpp | 11 ++--------- src/widgets/scrollbar.cpp | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/providers/twitch/twitchchannel.cpp b/src/providers/twitch/twitchchannel.cpp index 9b1f3a4b7..ccf0b8eb3 100644 --- a/src/providers/twitch/twitchchannel.cpp +++ b/src/providers/twitch/twitchchannel.cpp @@ -95,9 +95,11 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection QObject::connect(this->chattersListTimer, &QTimer::timeout, doRefreshChatters); this->chattersListTimer->start(5 * 60 * 1000); - // for (int i = 0; i < 1000; i++) { - // this->addMessage(messages::Message::createSystemMessage("asdf")); - // } +#if 0 + for (int i = 0; i < 1000; i++) { + this->addMessage(messages::Message::createSystemMessage("asdf")); + } +#endif } TwitchChannel::~TwitchChannel() diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index d3a7b6005..f92ef1efe 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -51,8 +51,6 @@ ChannelView::ChannelView(BaseWidget *parent) })); this->scrollBar_.getCurrentValueChanged().connect([this] { - // qDebug() << "getCurrentValueChanged"; - // Whenever the scrollbar value has been changed, re-render the ChatWidgetView this->actuallyLayoutMessages(true); @@ -192,6 +190,7 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar) this->showingLatestMessages_ = this->scrollBar_.isAtBottom() || !this->scrollBar_.isVisible(); size_t start = size_t(this->scrollBar_.getCurrentValue()); + qDebug() << this->scrollBar_.getCurrentValue(); int layoutWidth = this->getLayoutWidth(); MessageElement::Flags flags = this->getFlags(); @@ -285,7 +284,6 @@ QString ChannelView::getSelectedText() return result; } - qDebug() << "xd >"; for (int msg = _selection.selectionMin.messageIndex; msg <= _selection.selectionMax.messageIndex; msg++) { MessageLayoutPtr layout = messagesSnapshot[msg]; @@ -493,7 +491,7 @@ void ChannelView::pause(int msecTimeout) this->pauseTimeout_.stop(); this->pauseTimeout_.start(msecTimeout); - qDebug() << "pause" << msecTimeout; + // qDebug() << "pause" << msecTimeout; } } @@ -1157,11 +1155,6 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link QPoint(int(150 * this->getScale()), int(70 * this->getScale()))); userPopup->show(); - // this->userPopupWidget.setName(user); - // this->userPopupWidget.moveTo(this, event->screenPos().toPoint()); - // this->userPopupWidget.show(); - // this->userPopupWidget.setFocus(); - qDebug() << "Clicked " << user << "s message"; break; } diff --git a/src/widgets/scrollbar.cpp b/src/widgets/scrollbar.cpp index c269215c8..d46c6a93b 100644 --- a/src/widgets/scrollbar.cpp +++ b/src/widgets/scrollbar.cpp @@ -18,7 +18,7 @@ namespace widgets { Scrollbar::Scrollbar(ChannelView *parent) : BaseWidget(parent) - , currentValueAnimation_(this, "currentValue") + , currentValueAnimation_(this, "currentValue_") { resize(int(16 * this->getScale()), 100); this->currentValueAnimation_.setDuration(150); @@ -115,6 +115,7 @@ void Scrollbar::setDesiredValue(qreal value, bool animated) // if (((this->getMaximum() - this->getLargeChange()) - value) <= 0.01) { // value += 1; // } + this->currentValueAnimation_.setEndValue(value); this->smoothScrollingOffset_ = 0; this->atBottom_ = ((this->getMaximum() - this->getLargeChange()) - value) <= 0.0001; @@ -191,7 +192,6 @@ void Scrollbar::setCurrentValue(qreal value) value + this->smoothScrollingOffset_)); if (std::abs(this->currentValue_ - value) > 0.0001) { - // qDebug() << "setCurrentValue"; this->currentValue_ = value; this->updateScroll();