From 6fe7c441c5dd74be3860dd4d25f624ba29579a0c Mon Sep 17 00:00:00 2001 From: Francois Ferrand <thetypz@gmail.com> Date: Thu, 28 Oct 2010 15:57:09 +0200 Subject: [PATCH] Keep scrollbar at bottom of window while resizing, to ensure we keep scrolling. Allow Ctrl+Home/Ctrl+End to scroll to the beginning/end of buffer. Merge-request: 202 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com> --- src/plugins/projectexplorer/outputwindow.cpp | 21 ++++++++++++++++++++ src/plugins/projectexplorer/outputwindow.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/plugins/projectexplorer/outputwindow.cpp b/src/plugins/projectexplorer/outputwindow.cpp index 5384ee5ccb7..98c3c13beee 100644 --- a/src/plugins/projectexplorer/outputwindow.cpp +++ b/src/plugins/projectexplorer/outputwindow.cpp @@ -568,6 +568,27 @@ void OutputWindow::mouseMoveEvent(QMouseEvent *e) QPlainTextEdit::mouseMoveEvent(e); } +void OutputWindow::resizeEvent(QResizeEvent *e) +{ + //Keep scrollbar at bottom of window while resizing, to ensure we keep scrolling + //This can happen if window is resized while building, or if the horizontal scrollbar appears + bool atBottom = isScrollbarAtBottom(); + QPlainTextEdit::resizeEvent(e); + if (atBottom) + scrollToBottom(); +} + +void OutputWindow::keyPressEvent(QKeyEvent *ev) +{ + QPlainTextEdit::keyPressEvent(ev); + + //Ensure we scroll also on Ctrl+Home or Ctrl+End + if (ev->matches(QKeySequence::MoveToStartOfDocument)) + verticalScrollBar()->triggerAction(QAbstractSlider::SliderToMinimum); + else if (ev->matches(QKeySequence::MoveToEndOfDocument)) + verticalScrollBar()->triggerAction(QAbstractSlider::SliderToMaximum); +} + OutputFormatter *OutputWindow::formatter() const { return m_formatter; diff --git a/src/plugins/projectexplorer/outputwindow.h b/src/plugins/projectexplorer/outputwindow.h index ad6999ea1dd..6e7dfd41327 100644 --- a/src/plugins/projectexplorer/outputwindow.h +++ b/src/plugins/projectexplorer/outputwindow.h @@ -175,6 +175,8 @@ protected: virtual void mousePressEvent(QMouseEvent *e); virtual void mouseReleaseEvent(QMouseEvent *e); virtual void mouseMoveEvent(QMouseEvent *e); + virtual void resizeEvent(QResizeEvent *e); + virtual void keyPressEvent(QKeyEvent *ev); private slots: void updateWordWrapMode(); -- GitLab