diff options
author | kh1 <karsten.heimrich@digia.com> | 2014-07-18 11:22:31 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2014-07-18 13:12:17 +0200 |
commit | 5ca8f4d7a4171a1dae355899fb4fa457d34489b1 (patch) | |
tree | e31dca31c6d4f99563a886ed155f117e8e2b3d56 /src/libs/installer/lazyplaintextedit.cpp | |
parent | e7925974802829339ebe351a5bb5a5d143933745 (diff) |
Show Details widget doesn't follow content during install.
Now also keeps the position if we have scrolled somewhere.
Task-number: QTIFW-353
Change-Id: I58e90592df3d8d4589b5e577366c251e501900d9
Reviewed-by: Niels Weber <niels.weber@digia.com>
Diffstat (limited to 'src/libs/installer/lazyplaintextedit.cpp')
-rw-r--r-- | src/libs/installer/lazyplaintextedit.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/libs/installer/lazyplaintextedit.cpp b/src/libs/installer/lazyplaintextedit.cpp index c0857458a..93a090e96 100644 --- a/src/libs/installer/lazyplaintextedit.cpp +++ b/src/libs/installer/lazyplaintextedit.cpp @@ -57,10 +57,12 @@ void LazyPlainTextEdit::timerEvent(QTimerEvent *event) killTimer(m_timerId); m_timerId = 0; m_cachedOutput.chop(1); //removes the last \n - if (!m_cachedOutput.isEmpty()) + if (!m_cachedOutput.isEmpty()) { appendPlainText(m_cachedOutput); - horizontalScrollBar()->setValue( 0 ); - m_cachedOutput.clear(); + updateCursor(TextCursorPosition::Keep); + horizontalScrollBar()->setValue(0); + m_cachedOutput.clear(); + } } } @@ -81,7 +83,6 @@ void LazyPlainTextEdit::clear() QPlainTextEdit::clear(); } - void LazyPlainTextEdit::setVisible(bool visible) { if (m_timerId) { @@ -93,4 +94,21 @@ void LazyPlainTextEdit::setVisible(bool visible) m_timerId = startTimer(INTERVAL); QPlainTextEdit::setVisible(visible); + updateCursor(TextCursorPosition::Keep); +} + +void LazyPlainTextEdit::updateCursor(TextCursorPosition position) +{ + QTextCursor cursor = textCursor(); + if ((position == TextCursorPosition::ForceEnd) || cursor.atEnd()) { + // Workaround for height calculation issue if scrollbar is set to Qt::ScrollBarAsNeeded. + Qt::ScrollBarPolicy policy = horizontalScrollBarPolicy(); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); // enforce always on + + cursor.movePosition(QTextCursor::End); + setTextCursor(cursor); + ensureCursorVisible(); + + setHorizontalScrollBarPolicy(policy); // but reset once we updated the cursor position + } } |