Skip to content
Snippets Groups Projects
Commit 2a276da5 authored by mae's avatar mae
Browse files

Be more agressive in scrolling to the bottom in output

panes when output was appended while the window was
not visible.
parent 7483880b
No related branches found
No related tags found
No related merge requests found
...@@ -341,6 +341,7 @@ OutputWindow::OutputWindow(QWidget *parent) ...@@ -341,6 +341,7 @@ OutputWindow::OutputWindow(QWidget *parent)
: QPlainTextEdit(parent) : QPlainTextEdit(parent)
{ {
m_enforceNewline = false; m_enforceNewline = false;
m_scrollToBottom = false;
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
//setCenterOnScroll(false); //setCenterOnScroll(false);
...@@ -392,8 +393,18 @@ OutputWindow::~OutputWindow() ...@@ -392,8 +393,18 @@ OutputWindow::~OutputWindow()
Core::ICore::instance()->removeContextObject(m_outputWindowContext); Core::ICore::instance()->removeContextObject(m_outputWindowContext);
} }
void OutputWindow::showEvent(QShowEvent *e)
{
QPlainTextEdit::showEvent(e);
if (m_scrollToBottom) {
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
}
m_scrollToBottom = false;
}
void OutputWindow::appendOutput(const QString &out) void OutputWindow::appendOutput(const QString &out)
{ {
m_scrollToBottom = true;
QString s = out; QString s = out;
m_enforceNewline = true; // make appendOutputInline put in a newline next time m_enforceNewline = true; // make appendOutputInline put in a newline next time
if (s.endsWith(QLatin1Char('\n'))) { if (s.endsWith(QLatin1Char('\n'))) {
...@@ -407,6 +418,7 @@ void OutputWindow::appendOutput(const QString &out) ...@@ -407,6 +418,7 @@ void OutputWindow::appendOutput(const QString &out)
void OutputWindow::appendOutputInline(const QString &out) void OutputWindow::appendOutputInline(const QString &out)
{ {
m_scrollToBottom = true;
setMaximumBlockCount(MaxBlockCount); setMaximumBlockCount(MaxBlockCount);
int newline = -1; int newline = -1;
...@@ -439,6 +451,7 @@ void OutputWindow::appendOutputInline(const QString &out) ...@@ -439,6 +451,7 @@ void OutputWindow::appendOutputInline(const QString &out)
void OutputWindow::insertLine() void OutputWindow::insertLine()
{ {
m_scrollToBottom = true;
setMaximumBlockCount(MaxBlockCount); setMaximumBlockCount(MaxBlockCount);
appendPlainText(QString()); appendPlainText(QString());
enableUndoRedo(); enableUndoRedo();
......
...@@ -126,10 +126,13 @@ public: ...@@ -126,10 +126,13 @@ public:
void appendOutputInline(const QString &out); void appendOutputInline(const QString &out);
void insertLine(); void insertLine();
void showEvent(QShowEvent *);
private: private:
Core::BaseContext *m_outputWindowContext; Core::BaseContext *m_outputWindowContext;
void enableUndoRedo(); void enableUndoRedo();
bool m_enforceNewline; bool m_enforceNewline;
bool m_scrollToBottom;
}; };
#if 0 #if 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment