X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatview.cpp;h=918cec64a42bb662d0729d9fdeb005435c209344;hp=f8fb586627ea77ab02828d5265a20f3886d308c9;hb=26406e4c1f049a021fd99fd6592389289a510e99;hpb=c01c1ad4823a3e49c9526c19560dd5ce4fe30cb8 diff --git a/src/qtui/chatview.cpp b/src/qtui/chatview.cpp index f8fb5866..918cec64 100644 --- a/src/qtui/chatview.cpp +++ b/src/qtui/chatview.cpp @@ -84,6 +84,9 @@ void ChatView::init(MessageFilter* filter) connect(verticalScrollBar(), &QAbstractSlider::valueChanged, this, &ChatView::verticalScrollbarChanged); _lastScrollbarPos = verticalScrollBar()->maximum(); + // Workaround for the ChatView scrolling up a fair bit when scrollbar becomes visible + verticalScrollBar()->installEventFilter(this); + connect(Client::networkModel(), &NetworkModel::markerLineSet, this, &ChatView::markerLineSet); // only connect if client is synched with a core @@ -157,6 +160,28 @@ bool ChatView::event(QEvent* event) return QGraphicsView::event(event); } +bool ChatView::eventFilter(QObject* watched, QEvent* event) +{ + QAbstractSlider* vbar = verticalScrollBar(); + Q_ASSERT(vbar); + + if (watched != vbar) { + // Ignore and pass through all events not featuring the scrollbar + return false; + } + if (event->type() == QEvent::Show) { + // FIXME: Workaround for the ChatView scrolling up a fair bit when transitioning from the + // vertical scrollbar not being visible, to becoming visible. This happens especially + // often when no initial backlog is loaded. + if (_backlogRequestedBeforeScrollable) { + _backlogRequestedBeforeScrollable = false; + vbar->setValue(vbar->maximum()); + } + } + // Pass through all events + return false; +} + void ChatView::resizeEvent(QResizeEvent* event) { // if view is currently scrolled to bottom, we want it that way after resizing @@ -415,6 +440,7 @@ bool ChatView::requestBacklogForScroll() // Future improvement: continue fetching backlog in chunks until the scrollbar is visible, // or the beginning of the buffer has been reached. scene()->requestBacklog(); + _backlogRequestedBeforeScrollable = true; // Backlog has been requested return true; }