mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Don't stick to bottom if the user scrolls while the worker is still
running
This commit is contained in:
parent
4930b32641
commit
437282b80c
|
@ -106,7 +106,7 @@ ChatLog::ChatLog(QWidget* parent)
|
||||||
workerLastIndex = 0;
|
workerLastIndex = 0;
|
||||||
workerDy = 0.0;
|
workerDy = 0.0;
|
||||||
|
|
||||||
if(workerStb)
|
if(stickToBottom())
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -134,17 +134,12 @@ void ChatLog::clearSelection()
|
||||||
|
|
||||||
QRect ChatLog::getVisibleRect() const
|
QRect ChatLog::getVisibleRect() const
|
||||||
{
|
{
|
||||||
return mapToScene(viewport()->rect()).boundingRect().toRect();
|
return mapToScene(calculateSceneRect().toRect()).boundingRect().toRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLog::updateSceneRect()
|
void ChatLog::updateSceneRect()
|
||||||
{
|
{
|
||||||
qreal bottom = (lines.empty() ? 0.0 : lines.last()->boundingSceneRect().bottom());
|
setSceneRect(calculateSceneRect());
|
||||||
|
|
||||||
if(typingNotification.get() != nullptr)
|
|
||||||
bottom += typingNotification->boundingSceneRect().height() + lineSpacing;
|
|
||||||
|
|
||||||
setSceneRect(QRectF(-margins.left(), -margins.top(), useableWidth(), bottom + margins.bottom() + margins.top()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal ChatLog::layout(int start, int end, qreal width)
|
qreal ChatLog::layout(int start, int end, qreal width)
|
||||||
|
@ -584,8 +579,6 @@ void ChatLog::checkVisibility()
|
||||||
if(lines.empty())
|
if(lines.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateSceneRect();
|
|
||||||
|
|
||||||
// find first visible line
|
// find first visible line
|
||||||
auto lowerBound = std::upper_bound(lines.cbegin(), lines.cend(), getVisibleRect().top(), [](const qreal lhs, const ChatLine::Ptr rhs)
|
auto lowerBound = std::upper_bound(lines.cbegin(), lines.cend(), getVisibleRect().top(), [](const qreal lhs, const ChatLine::Ptr rhs)
|
||||||
{
|
{
|
||||||
|
@ -688,6 +681,16 @@ void ChatLog::updateTypingNotification()
|
||||||
notification->layout(useableWidth(), QPointF(0.0, posY));
|
notification->layout(useableWidth(), QPointF(0.0, posY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF ChatLog::calculateSceneRect() const
|
||||||
|
{
|
||||||
|
qreal bottom = (lines.empty() ? 0.0 : lines.last()->boundingSceneRect().bottom());
|
||||||
|
|
||||||
|
if(typingNotification.get() != nullptr)
|
||||||
|
bottom += typingNotification->boundingSceneRect().height() + lineSpacing;
|
||||||
|
|
||||||
|
return QRectF(-margins.left(), -margins.top(), useableWidth(), bottom + margins.bottom() + margins.top());
|
||||||
|
}
|
||||||
|
|
||||||
void ChatLog::onSelectionTimerTimeout()
|
void ChatLog::onSelectionTimerTimeout()
|
||||||
{
|
{
|
||||||
const int scrollSpeed = 10;
|
const int scrollSpeed = 10;
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
ChatLine::Ptr getTypingNotification() const;
|
ChatLine::Ptr getTypingNotification() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
QRectF calculateSceneRect() const;
|
||||||
QRect getVisibleRect() const;
|
QRect getVisibleRect() const;
|
||||||
ChatLineContent* getContentFromPos(QPointF scenePos) const;
|
ChatLineContent* getContentFromPos(QPointF scenePos) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user