From 28bf8478c4542c14196e1784189d35731a8b85a3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 15 Mar 2022 14:39:59 +0100 Subject: [PATCH] [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. --- src/libcalamaresui/widgets/LogWidget.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/libcalamaresui/widgets/LogWidget.cpp b/src/libcalamaresui/widgets/LogWidget.cpp index 7d81e0ca0..d4d9a8e20 100644 --- a/src/libcalamaresui/widgets/LogWidget.cpp +++ b/src/libcalamaresui/widgets/LogWidget.cpp @@ -1,6 +1,8 @@ #include "LogWidget.h" #include "utils/Logger.h" + #include +#include #include #include #include @@ -61,6 +63,7 @@ LogWidget::LogWidget( QWidget* parent ) setLayout( layout ); m_text->setReadOnly( true ); + m_text->setVerticalScrollBarPolicy( Qt::ScrollBarPolicy::ScrollBarAlwaysOn ); QFont monospaceFont( "monospace" ); monospaceFont.setStyleHint( QFont::Monospace ); @@ -77,15 +80,7 @@ LogWidget::LogWidget( QWidget* parent ) void 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 ); - if ( isAtEnd ) - { - m_text->moveCursor( QTextCursor::End ); - } - m_text->ensureCursorVisible(); } void