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 f2fa601073373ae2ef9fba7952aed415af3ccee0.
This commit is contained in:
parent
3b3779c850
commit
e18725c966
@ -413,11 +413,10 @@ void ChatLog::insertChatlineAtBottom(const QList<ChatLine::Ptr>& newLines)
|
|||||||
|
|
||||||
layout(lines.last()->getRow(), lines.size(), useableWidth());
|
layout(lines.last()->getRow(), lines.size(), useableWidth());
|
||||||
|
|
||||||
// redo layout only when scrolled down
|
if (visibleLines.size() > 1) {
|
||||||
if(stickToBottom()) {
|
startResizeWorker(visibleLines[1]);
|
||||||
startResizeWorker(true);
|
|
||||||
} else {
|
} else {
|
||||||
updateSceneRect();
|
startResizeWorker();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,9 +469,9 @@ void ChatLog::insertChatlinesOnTop(const QList<ChatLine::Ptr>& newLines)
|
|||||||
|
|
||||||
// redo layout
|
// redo layout
|
||||||
if (visibleLines.size() > 1) {
|
if (visibleLines.size() > 1) {
|
||||||
startResizeWorker(stickToBottom(), visibleLines[1]);
|
startResizeWorker(visibleLines[1]);
|
||||||
} else {
|
} else {
|
||||||
startResizeWorker(stickToBottom());
|
startResizeWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -488,7 +487,7 @@ void ChatLog::scrollToBottom()
|
|||||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLog::startResizeWorker(bool stick, ChatLine::Ptr anchorLine)
|
void ChatLog::startResizeWorker(ChatLine::Ptr anchorLine)
|
||||||
{
|
{
|
||||||
if (lines.empty()) {
|
if (lines.empty()) {
|
||||||
isScroll = true;
|
isScroll = true;
|
||||||
@ -498,11 +497,11 @@ void ChatLog::startResizeWorker(bool stick, ChatLine::Ptr anchorLine)
|
|||||||
// (re)start the worker
|
// (re)start the worker
|
||||||
if (!workerTimer->isActive()) {
|
if (!workerTimer->isActive()) {
|
||||||
// these values must not be reevaluated while the worker is running
|
// these values must not be reevaluated while the worker is running
|
||||||
workerStb = stick;
|
if (anchorLine) {
|
||||||
if (stick) {
|
|
||||||
workerAnchorLine = ChatLine::Ptr();
|
|
||||||
} else {
|
|
||||||
workerAnchorLine = anchorLine;
|
workerAnchorLine = anchorLine;
|
||||||
|
workerStb = false;
|
||||||
|
} else {
|
||||||
|
workerStb = stickToBottom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,7 +751,7 @@ int ChatLog::getNumRemove() const
|
|||||||
|
|
||||||
void ChatLog::forceRelayout()
|
void ChatLog::forceRelayout()
|
||||||
{
|
{
|
||||||
startResizeWorker(stickToBottom());
|
startResizeWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLog::checkVisibility(bool causedWheelEvent)
|
void ChatLog::checkVisibility(bool causedWheelEvent)
|
||||||
@ -821,7 +820,7 @@ void ChatLog::resizeEvent(QResizeEvent* ev)
|
|||||||
bool stb = stickToBottom();
|
bool stb = stickToBottom();
|
||||||
|
|
||||||
if (ev->size().width() != ev->oldSize().width()) {
|
if (ev->size().width() != ev->oldSize().width()) {
|
||||||
startResizeWorker(stb);
|
startResizeWorker();
|
||||||
stb = false; // let the resize worker handle it
|
stb = false; // let the resize worker handle it
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -888,9 +887,8 @@ QRectF ChatLog::calculateSceneRect() const
|
|||||||
{
|
{
|
||||||
qreal bottom = (lines.empty() ? 0.0 : lines.last()->sceneBoundingRect().bottom());
|
qreal bottom = (lines.empty() ? 0.0 : lines.last()->sceneBoundingRect().bottom());
|
||||||
|
|
||||||
if (typingNotification.get() != nullptr) {
|
if (typingNotification.get() != nullptr)
|
||||||
bottom += typingNotification->sceneBoundingRect().height() + lineSpacing;
|
bottom += typingNotification->sceneBoundingRect().height() + lineSpacing;
|
||||||
}
|
|
||||||
|
|
||||||
return QRectF(-margins.left(), -margins.top(), useableWidth(),
|
return QRectF(-margins.left(), -margins.top(), useableWidth(),
|
||||||
bottom + margins.bottom() + margins.top());
|
bottom + margins.bottom() + margins.top());
|
||||||
|
@ -99,7 +99,7 @@ protected:
|
|||||||
void updateSceneRect();
|
void updateSceneRect();
|
||||||
void checkVisibility(bool causedWheelEvent = false);
|
void checkVisibility(bool causedWheelEvent = false);
|
||||||
void scrollToBottom();
|
void scrollToBottom();
|
||||||
void startResizeWorker(bool stick, ChatLine::Ptr anchorLine = nullptr);
|
void startResizeWorker(ChatLine::Ptr anchorLine = nullptr);
|
||||||
|
|
||||||
void mouseDoubleClickEvent(QMouseEvent* ev) final;
|
void mouseDoubleClickEvent(QMouseEvent* ev) final;
|
||||||
void mousePressEvent(QMouseEvent* ev) final;
|
void mousePressEvent(QMouseEvent* ev) final;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user