From 3271ab1dff7df6f6464cb714d675291aae791639 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Fri, 7 Nov 2008 11:38:32 +0100 Subject: [PATCH 1/1] ChatView now asks the scene if scrolling is ok on message appending That way, the scene can inhibit autoscroll for example while selecting, or during a click sequence (nothing is more annoying than a link that scrolls away while you have the button still pressed...). The former is already implemented, the latter follows next as soon as I get a decent click handling going. --- src/qtui/chatscene.cpp | 9 +++++++++ src/qtui/chatscene.h | 2 ++ src/qtui/chatview.cpp | 3 +++ 3 files changed, 14 insertions(+) diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 81996488..358eb12b 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -513,6 +513,15 @@ void ChatScene::updateSelection(const QPointF &pos) { } } +bool ChatScene::isScrollingAllowed() const { + if(_isSelecting) + return false; + + // TODO: Handle clicks and single-item selections too + + return true; +} + void ChatScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { if(_isSelecting && event->buttons() == Qt::LeftButton) { updateSelection(event->scenePos()); diff --git a/src/qtui/chatscene.h b/src/qtui/chatscene.h index a932380b..0c9329ed 100644 --- a/src/qtui/chatscene.h +++ b/src/qtui/chatscene.h @@ -72,6 +72,8 @@ public: inline CutoffMode senderCutoffMode() const { return _cutoffMode; } inline void setSenderCutoffMode(CutoffMode mode) { _cutoffMode = mode; } + bool isScrollingAllowed() const; + virtual bool event(QEvent *e); public slots: diff --git a/src/qtui/chatview.cpp b/src/qtui/chatview.cpp index d360d9de..536a5111 100644 --- a/src/qtui/chatview.cpp +++ b/src/qtui/chatview.cpp @@ -108,6 +108,9 @@ void ChatView::scrollTimerTimeout() { void ChatView::lastLineChanged(QGraphicsItem *chatLine, qreal offset) { Q_UNUSED(chatLine) + if(!scene()->isScrollingAllowed()) + return; + QAbstractSlider *vbar = verticalScrollBar(); Q_ASSERT(vbar); if(vbar->maximum() - vbar->value() <= (offset + 5) * _currentScaleFactor ) { // 5px grace area -- 2.20.1