mirror of
https://github.com/epasveer/seer.git
synced 2026-08-30 00:50:42 +08:00
Fix bug when scrolling down to the last line.
It wasn't positioning to the begining of the line.
This commit is contained in:
@@ -26,6 +26,7 @@ void SeerCaretAsteriskLogWidget::processText (const QString& text) {
|
||||
|
||||
// Write the string to the log.
|
||||
textEdit->append(str);
|
||||
textEdit->verticalScrollBar()->setValue(textEdit->verticalScrollBar()->maximum());
|
||||
|
||||
moveToEnd();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,26 @@ SeerLogWidget::~SeerLogWidget () {
|
||||
}
|
||||
|
||||
void SeerLogWidget::processText (const QString& text) {
|
||||
|
||||
// Add text to the end of the document.
|
||||
textEdit->append(text);
|
||||
|
||||
moveToEnd();
|
||||
}
|
||||
|
||||
void SeerLogWidget::moveToEnd () {
|
||||
|
||||
// Move cursor to start of the last line.
|
||||
// Move scrollbars to the last line.
|
||||
int nlines = textEdit->document()->lineCount();
|
||||
|
||||
QTextCursor cursor = textEdit->textCursor();
|
||||
|
||||
cursor.setPosition(nlines-1);
|
||||
|
||||
textEdit->setTextCursor(cursor);
|
||||
textEdit->moveCursor(QTextCursor::StartOfLine);
|
||||
|
||||
textEdit->verticalScrollBar()->setValue(textEdit->verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ class SeerLogWidget : public QWidget, protected Ui::SeerLogWidgetForm {
|
||||
~SeerLogWidget ();
|
||||
|
||||
virtual void processText (const QString& text);
|
||||
virtual void moveToEnd ();
|
||||
|
||||
public slots:
|
||||
void handleText (const QString& text);
|
||||
|
||||
@@ -85,6 +85,7 @@ void SeerTildeEqualAmpersandLogWidget::processText (const QString& text) {
|
||||
|
||||
// Write the string to the log.
|
||||
textEdit->append(str);
|
||||
textEdit->verticalScrollBar()->setValue(textEdit->verticalScrollBar()->maximum());
|
||||
|
||||
moveToEnd();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ void SeerTildeLogWidget::processText (const QString& text) {
|
||||
}
|
||||
|
||||
textEdit->append(str);
|
||||
textEdit->verticalScrollBar()->setValue(textEdit->verticalScrollBar()->maximum());
|
||||
|
||||
moveToEnd();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user