Only layout visible ChannelViews (#4811)
This commit is contained in:
@@ -228,8 +228,15 @@ void ChannelView::initializeLayout()
|
||||
void ChannelView::initializeScrollbar()
|
||||
{
|
||||
this->scrollBar_->getCurrentValueChanged().connect([this] {
|
||||
this->performLayout(true);
|
||||
this->queueUpdate();
|
||||
if (this->isVisible())
|
||||
{
|
||||
this->performLayout(true);
|
||||
this->queueUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->layoutQueued_ = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -413,33 +420,35 @@ void ChannelView::scaleChangedEvent(float scale)
|
||||
|
||||
void ChannelView::queueUpdate()
|
||||
{
|
||||
// if (this->updateTimer.isActive()) {
|
||||
// this->updateQueued = true;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// this->repaint();
|
||||
|
||||
this->update();
|
||||
|
||||
// this->updateTimer.start();
|
||||
}
|
||||
|
||||
void ChannelView::queueLayout()
|
||||
{
|
||||
// if (!this->layoutCooldown->isActive()) {
|
||||
this->performLayout();
|
||||
|
||||
// this->layoutCooldown->start();
|
||||
// } else {
|
||||
// this->layoutQueued = true;
|
||||
// }
|
||||
if (this->isVisible())
|
||||
{
|
||||
this->performLayout();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->layoutQueued_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelView::performLayout(bool causedByScrollbar)
|
||||
void ChannelView::showEvent(QShowEvent * /*event*/)
|
||||
{
|
||||
if (this->layoutQueued_)
|
||||
{
|
||||
this->performLayout(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelView::performLayout(bool causedByScrollbar, bool causedByShow)
|
||||
{
|
||||
// BenchmarkGuard benchmark("layout");
|
||||
|
||||
this->layoutQueued_ = false;
|
||||
|
||||
/// Get messages and check if there are at least 1
|
||||
const auto &messages = this->getMessagesSnapshot();
|
||||
|
||||
@@ -451,7 +460,7 @@ void ChannelView::performLayout(bool causedByScrollbar)
|
||||
this->layoutVisibleMessages(messages);
|
||||
|
||||
/// Update scrollbar
|
||||
this->updateScrollbar(messages, causedByScrollbar);
|
||||
this->updateScrollbar(messages, causedByScrollbar, causedByShow);
|
||||
|
||||
this->goToBottom_->setVisible(this->enableScrollingToBottom_ &&
|
||||
this->scrollBar_->isVisible() &&
|
||||
@@ -490,7 +499,7 @@ void ChannelView::layoutVisibleMessages(
|
||||
|
||||
void ChannelView::updateScrollbar(
|
||||
const LimitedQueueSnapshot<MessageLayoutPtr> &messages,
|
||||
bool causedByScrollbar)
|
||||
bool causedByScrollbar, bool causedByShow)
|
||||
{
|
||||
if (messages.size() == 0)
|
||||
{
|
||||
@@ -539,6 +548,7 @@ void ChannelView::updateScrollbar(
|
||||
showScrollbar && !causedByScrollbar)
|
||||
{
|
||||
this->scrollBar_->scrollToBottom(
|
||||
!causedByShow &&
|
||||
getSettings()->enableSmoothScrollingNewMessages.getValue());
|
||||
}
|
||||
}
|
||||
@@ -799,7 +809,7 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
|
||||
|
||||
this->underlyingChannel_ = underlyingChannel;
|
||||
|
||||
this->queueLayout();
|
||||
this->performLayout();
|
||||
this->queueUpdate();
|
||||
|
||||
// Notifications
|
||||
@@ -903,6 +913,10 @@ void ChannelView::messageAppended(MessagePtr &message,
|
||||
else
|
||||
{
|
||||
this->scrollBar_->offsetMinimum(1);
|
||||
if (this->showingLatestMessages_ && !this->isVisible())
|
||||
{
|
||||
this->scrollBar_->scrollToBottom(false);
|
||||
}
|
||||
this->selection_.shiftMessageIndex(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user