Commit 0e95a561 authored by Daniel Teske's avatar Daniel Teske
Browse files

Make OutputWindow a bit faster



By limiting how often we scroll to the bottom and thus limiting
how often we redraw.

Change-Id: I42ec9dc6284112025108000420ccdfdf5d003f34
Task-number: QTCREATORBUG-14307
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 097ff14b
...@@ -127,6 +127,12 @@ OutputWindow::OutputWindow(Context context, QWidget *parent) ...@@ -127,6 +127,12 @@ OutputWindow::OutputWindow(Context context, QWidget *parent)
redoAction->setEnabled(false); redoAction->setEnabled(false);
cutAction->setEnabled(false); cutAction->setEnabled(false);
copyAction->setEnabled(false); copyAction->setEnabled(false);
m_scrollTimer.setInterval(10);
m_scrollTimer.setSingleShot(true);
connect(&m_scrollTimer, &QTimer::timeout,
this, &OutputWindow::scrollToBottom);
m_lastMessage.start();
} }
OutputWindow::~OutputWindow() OutputWindow::~OutputWindow()
...@@ -241,7 +247,7 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format) ...@@ -241,7 +247,7 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format)
{ {
const QString out = SynchronousProcess::normalizeNewlines(output); const QString out = SynchronousProcess::normalizeNewlines(output);
setMaximumBlockCount(d->maxLineCount); setMaximumBlockCount(d->maxLineCount);
const bool atBottom = isScrollbarAtBottom(); const bool atBottom = isScrollbarAtBottom() || m_scrollTimer.isActive();
if (format == ErrorMessageFormat || format == NormalMessageFormat) { if (format == ErrorMessageFormat || format == NormalMessageFormat) {
...@@ -281,8 +287,16 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format) ...@@ -281,8 +287,16 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format)
} }
} }
if (atBottom) if (atBottom) {
scrollToBottom(); if (m_lastMessage.elapsed() < 5) {
m_scrollTimer.start();
} else {
m_scrollTimer.stop();
scrollToBottom();
}
}
m_lastMessage.start();
enableUndoRedo(); enableUndoRedo();
} }
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include <utils/outputformat.h> #include <utils/outputformat.h>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QTimer>
#include <QTime>
namespace Utils { class OutputFormatter; } namespace Utils { class OutputFormatter; }
...@@ -82,6 +84,8 @@ protected: ...@@ -82,6 +84,8 @@ protected:
virtual void keyPressEvent(QKeyEvent *ev); virtual void keyPressEvent(QKeyEvent *ev);
private: private:
QTimer m_scrollTimer;
QTime m_lastMessage;
void enableUndoRedo(); void enableUndoRedo();
QString doNewlineEnforcement(const QString &out); QString doNewlineEnforcement(const QString &out);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment