Output panes: Fix auto-scrolling issue

The idea is that the user turns auto-scrolling off by manually moving the
scrollbar up and turns it back on again by moving it all the way down.
However, at least on my machine I am no longer able to do the
latter -- the scrollbar position is always at least one below the
maximum. I don't know when, why or how that changed, nor do I know
whether it's about Qt, the window system or something else. Either way,
we have to account for it.

Change-Id: I83aab758d72735d4db45d228eca8bbc7a8eebd93
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2021-02-25 16:47:49 +01:00
parent 1616e72fcc
commit 4ebe717a7d
2 changed files with 3 additions and 7 deletions

View File

@@ -155,6 +155,8 @@ OutputWindow::OutputWindow(Context context, const QString &settingsKey, QWidget
connect(verticalScrollBar(), &QAbstractSlider::sliderMoved, connect(verticalScrollBar(), &QAbstractSlider::sliderMoved,
this, &OutputWindow::updateAutoScroll); this, &OutputWindow::updateAutoScroll);
connect(verticalScrollBar(), &QAbstractSlider::sliderReleased,
this, &OutputWindow::updateAutoScroll);
undoAction->setEnabled(false); undoAction->setEnabled(false);
redoAction->setEnabled(false); redoAction->setEnabled(false);
@@ -449,7 +451,7 @@ void OutputWindow::handleOutputChunk(const QString &output, OutputFormat format)
void OutputWindow::updateAutoScroll() void OutputWindow::updateAutoScroll()
{ {
d->scrollToBottom = isScrollbarAtBottom(); d->scrollToBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum() - 1;
} }
void OutputWindow::setMaxCharCount(int count) void OutputWindow::setMaxCharCount(int count)
@@ -473,11 +475,6 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format)
d->queueTimer.start(); d->queueTimer.start();
} }
bool OutputWindow::isScrollbarAtBottom() const
{
return verticalScrollBar()->value() == verticalScrollBar()->maximum();
}
QMimeData *OutputWindow::createMimeDataFromSelection() const QMimeData *OutputWindow::createMimeDataFromSelection() const
{ {
const auto mimeData = new QMimeData; const auto mimeData = new QMimeData;

View File

@@ -91,7 +91,6 @@ public slots:
void setWordWrapEnabled(bool wrap); void setWordWrapEnabled(bool wrap);
protected: protected:
bool isScrollbarAtBottom() const;
virtual void handleLink(const QPoint &pos); virtual void handleLink(const QPoint &pos);
private: private: