fix non latching issue

This commit is contained in:
Akash Mozumdar 2019-12-26 19:18:02 -05:00
parent 5c8edc63d6
commit 6eda5651a4

View File

@ -214,7 +214,7 @@ bool MainWindow::SentenceReceived(TextThread& thread, std::wstring& sentence)
if (current == &thread) QMetaObject::invokeMethod(this, [this, sentence = S(sentence)] if (current == &thread) QMetaObject::invokeMethod(this, [this, sentence = S(sentence)]
{ {
auto scrollbar = ui->textOutput->verticalScrollBar(); auto scrollbar = ui->textOutput->verticalScrollBar();
bool atBottom = scrollbar->value() == scrollbar->maximum(); bool atBottom = scrollbar->value() + 3 > scrollbar->maximum() || (double)scrollbar->value() / scrollbar->maximum() > 0.975; // arbitrary
QTextCursor cursor(ui->textOutput->document()); QTextCursor cursor(ui->textOutput->document());
cursor.movePosition(QTextCursor::End); cursor.movePosition(QTextCursor::End);
cursor.insertText(sentence); cursor.insertText(sentence);