summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/logviewform.cpp9
-rw-r--r--src/gui/logviewform.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/gui/logviewform.cpp b/src/gui/logviewform.cpp
index fdf0f71..834496b 100644
--- a/src/gui/logviewform.cpp
+++ b/src/gui/logviewform.cpp
@@ -25,6 +25,12 @@ LogViewForm::~LogViewForm()
// no need to delete child widgets, Qt does it all for us
}
+bool LogViewForm::isOnBottom() const
+{
+ const QScrollBar* vsb = logTextEdit->verticalScrollBar();
+ return (vsb->value() == vsb->maximum());
+}
+
void LogViewForm::scrollToBottom()
{
QScrollBar* vsb = logTextEdit->verticalScrollBar();
@@ -86,7 +92,10 @@ void LogViewForm::update(bool log_zapped)
if (logstream) {
QString s = logstream->read();
if (!s.isNull() && !s.isEmpty()) {
+ bool bottom = isOnBottom();
logTextEdit->appendPlainText(s);
+ if (bottom)
+ scrollToBottom();
}
}
}
diff --git a/src/gui/logviewform.h b/src/gui/logviewform.h
index d91f7c6..ab4ec0b 100644
--- a/src/gui/logviewform.h
+++ b/src/gui/logviewform.h
@@ -15,6 +15,7 @@ private:
QFile* logfile;
QTextStream* logstream;
+ bool isOnBottom() const;
void scrollToBottom();
public: