[libcalamaresui] Simplify log-window
Scrolling explicitly to the bottom isn't needed; leaving it up to appendPlainText() has the following behavior: - if the text is scrolled all the way down, follows the text and scrolls further down (tailing) - if it is not scrolled all the way down, keeps current position.
This commit is contained in:
parent
d998c9e24b
commit
28bf8478c4
@ -1,6 +1,8 @@
|
|||||||
#include "LogWidget.h"
|
#include "LogWidget.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QScrollBar>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@ -61,6 +63,7 @@ LogWidget::LogWidget( QWidget* parent )
|
|||||||
setLayout( layout );
|
setLayout( layout );
|
||||||
|
|
||||||
m_text->setReadOnly( true );
|
m_text->setReadOnly( true );
|
||||||
|
m_text->setVerticalScrollBarPolicy( Qt::ScrollBarPolicy::ScrollBarAlwaysOn );
|
||||||
|
|
||||||
QFont monospaceFont( "monospace" );
|
QFont monospaceFont( "monospace" );
|
||||||
monospaceFont.setStyleHint( QFont::Monospace );
|
monospaceFont.setStyleHint( QFont::Monospace );
|
||||||
@ -77,15 +80,7 @@ LogWidget::LogWidget( QWidget* parent )
|
|||||||
void
|
void
|
||||||
LogWidget::handleLogChunk( const QString& logChunk )
|
LogWidget::handleLogChunk( const QString& logChunk )
|
||||||
{
|
{
|
||||||
// Scroll to the end of the new chunk, only if we were at the end (tailing
|
|
||||||
// the log); scrolling up will break the tail-to-end behavior.
|
|
||||||
const bool isAtEnd = m_text->textCursor().atEnd();
|
|
||||||
m_text->appendPlainText( logChunk );
|
m_text->appendPlainText( logChunk );
|
||||||
if ( isAtEnd )
|
|
||||||
{
|
|
||||||
m_text->moveCursor( QTextCursor::End );
|
|
||||||
}
|
|
||||||
m_text->ensureCursorVisible();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user