From 1975fc2d8d5f1a2a7bf71717c0ca7cef6dd57566 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Tue, 26 May 2015 21:23:00 +0200 Subject: [PATCH] Always keep log scrolled to the bottom --- src/gui/widgets/LogDockAppender.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/widgets/LogDockAppender.cxx b/src/gui/widgets/LogDockAppender.cxx index 5003139..321860a 100644 --- a/src/gui/widgets/LogDockAppender.cxx +++ b/src/gui/widgets/LogDockAppender.cxx @@ -2,6 +2,7 @@ #include "LogDock.hxx" #include +#include using namespace log4cxx::helpers; @@ -51,6 +52,14 @@ void LogDockAppender::append(const spi::LoggingEventPtr& event, Pool& p) { target->item(rowcount, 1)->setBackground(rowcolor); target->item(rowcount, 2)->setBackground(rowcolor); target->resizeColumnsToContents(); + + QTimer *timer = new QTimer(target); + timer->setSingleShot(true); + + QObject::connect(timer, &QTimer::timeout, [=]() { + target->scrollToItem(target->item(rowcount, 2), QAbstractItemView::PositionAtTop); + }); + timer->start(10); } void LogDockAppender::setTarget(LogDock *target) { -- 2.39.5