1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

revert(chatlog): "fix stick to bottom behavior"

This reverts commit f2fa601073.
This commit is contained in:
Anthony Bilinski 2020-04-04 22:33:00 -07:00
parent 5da1e4b9a8
commit b04639c6d0
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
2 changed files with 15 additions and 15 deletions

View File

@ -407,9 +407,10 @@ void ChatLog::insertChatlineAtBottom(const QList<ChatLine::Ptr>& newLines)
layout(lines.last()->getRow(), lines.size(), useableWidth());
// redo layout only when scrolled down
if(stickToBottom()) {
startResizeWorker(true);
if (visibleLines.size() > 1) {
startResizeWorker(visibleLines[1]);
} else {
startResizeWorker();
}
}
@ -462,9 +463,9 @@ void ChatLog::insertChatlinesOnTop(const QList<ChatLine::Ptr>& newLines)
// redo layout
if (visibleLines.size() > 1) {
startResizeWorker(stickToBottom(), visibleLines[1]);
startResizeWorker(visibleLines[1]);
} else {
startResizeWorker(stickToBottom());
startResizeWorker();
}
}
@ -480,7 +481,7 @@ void ChatLog::scrollToBottom()
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
}
void ChatLog::startResizeWorker(bool stick, ChatLine::Ptr anchorLine)
void ChatLog::startResizeWorker(ChatLine::Ptr anchorLine)
{
if (lines.empty()) {
isScroll = true;
@ -490,11 +491,11 @@ void ChatLog::startResizeWorker(bool stick, ChatLine::Ptr anchorLine)
// (re)start the worker
if (!workerTimer->isActive()) {
// these values must not be reevaluated while the worker is running
workerStb = stick;
if (stick) {
workerAnchorLine = ChatLine::Ptr();
} else {
if (anchorLine) {
workerAnchorLine = anchorLine;
workerStb = false;
} else {
workerStb = stickToBottom();
}
}
@ -764,7 +765,7 @@ int ChatLog::getNumRemove() const
void ChatLog::forceRelayout()
{
startResizeWorker(stickToBottom());
startResizeWorker();
}
void ChatLog::checkVisibility(bool causedWheelEvent)
@ -833,7 +834,7 @@ void ChatLog::resizeEvent(QResizeEvent* ev)
bool stb = stickToBottom();
if (ev->size().width() != ev->oldSize().width()) {
startResizeWorker(stb);
startResizeWorker();
stb = false; // let the resize worker handle it
}
@ -900,9 +901,8 @@ QRectF ChatLog::calculateSceneRect() const
{
qreal bottom = (lines.empty() ? 0.0 : lines.last()->sceneBoundingRect().bottom());
if (typingNotification.get() != nullptr) {
if (typingNotification.get() != nullptr)
bottom += typingNotification->sceneBoundingRect().height() + lineSpacing;
}
return QRectF(-margins.left(), -margins.top(), useableWidth(),
bottom + margins.bottom() + margins.top());

View File

@ -105,7 +105,7 @@ protected:
void updateSceneRect();
void checkVisibility(bool causedWheelEvent = false);
void scrollToBottom();
void startResizeWorker(bool stick, ChatLine::Ptr anchorLine = nullptr);
void startResizeWorker(ChatLine::Ptr anchorLine = nullptr);
virtual void mouseDoubleClickEvent(QMouseEvent* ev) final override;
virtual void mousePressEvent(QMouseEvent* ev) final override;