From ece04825024c28d9d282ef0c826f1c1f872d01aa Mon Sep 17 00:00:00 2001 From: Date: Thu, 28 Dec 2017 00:48:21 +0100 Subject: [PATCH] removed autoscoll and gotobottom from emotepopup --- src/widgets/emotepopup.cpp | 3 +++ src/widgets/helper/channelview.cpp | 15 +++++++++++++-- src/widgets/helper/channelview.hpp | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/widgets/emotepopup.cpp b/src/widgets/emotepopup.cpp index 121d2d4f7..074fee8c6 100644 --- a/src/widgets/emotepopup.cpp +++ b/src/widgets/emotepopup.cpp @@ -20,6 +20,9 @@ EmotePopup::EmotePopup(ColorScheme &colorScheme) this->viewEmotes = new ChannelView(); this->viewEmojis = new ChannelView(); + this->viewEmotes->setEnableScrollingToBottom(false); + this->viewEmojis->setEnableScrollingToBottom(false); + this->setLayout(new QVBoxLayout(this)); QTabWidget *tabs = new QTabWidget(this); diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index 2454737a9..4290b37b8 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -45,7 +45,8 @@ ChannelView::ChannelView(BaseWidget *parent) this->scrollBar.getCurrentValueChanged().connect([this] { // Whenever the scrollbar value has been changed, re-render the ChatWidgetView this->layoutMessages(); - this->goToBottom->setVisible(this->scrollBar.isVisible() && !this->scrollBar.isAtBottom()); + this->goToBottom->setVisible(this->enableScrollingToBottom && this->scrollBar.isVisible() && + !this->scrollBar.isAtBottom()); this->queueUpdate(); }); @@ -178,7 +179,7 @@ void ChannelView::actuallyLayoutMessages() this->scrollBar.setMaximum(messagesSnapshot.getLength()); - if (this->showingLatestMessages && showScrollbar) { + if (this->enableScrollingToBottom && this->showingLatestMessages && showScrollbar) { // If we were showing the latest messages and the scrollbar now wants to be rendered, scroll // to bottom // TODO: Do we want to check if the user is currently moving the scrollbar? @@ -329,6 +330,16 @@ void ChannelView::clearSelection() layoutMessages(); } +void ChannelView::setEnableScrollingToBottom(bool value) +{ + this->enableScrollingToBottom = value; +} + +bool ChannelView::getEnableScrollingToBottom() const +{ + return this->enableScrollingToBottom; +} + messages::LimitedQueueSnapshot ChannelView::getMessagesSnapshot() { return this->messages.getSnapshot(); diff --git a/src/widgets/helper/channelview.hpp b/src/widgets/helper/channelview.hpp index 19fd79eb7..90350ff76 100644 --- a/src/widgets/helper/channelview.hpp +++ b/src/widgets/helper/channelview.hpp @@ -95,6 +95,8 @@ public: QString getSelectedText(); bool hasSelection(); void clearSelection(); + void setEnableScrollingToBottom(bool); + bool getEnableScrollingToBottom() const; void setChannel(std::shared_ptr channel); messages::LimitedQueueSnapshot getMessagesSnapshot(); @@ -147,6 +149,7 @@ private: // This variable can be used to decide whether or not we should render the "Show latest // messages" button bool showingLatestMessages = true; + bool enableScrollingToBottom = true; AccountPopupWidget userPopupWidget; bool onlyUpdateEmotes = false;