summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-09-30 22:26:33 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-09-30 22:26:33 +0300
commit775d2e88f58b2e4ef52bcee4d76ec47a4fde316a (patch)
tree907005c211eba99a41d5b24d9a9aa562ddc1ae18 /src
parentAdd custom logging format (diff)
downloadnheko-775d2e88f58b2e4ef52bcee4d76ec47a4fde316a.tar.xz
Don't move scrollbar to the bottom when it's active
fixes #55
Diffstat (limited to 'src')
-rw-r--r--src/TimelineView.cc18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/TimelineView.cc b/src/TimelineView.cc

index 542ab98e..8b255cde 100644 --- a/src/TimelineView.cc +++ b/src/TimelineView.cc
@@ -55,9 +55,6 @@ TimelineView::TimelineView(const Timeline &timeline, , room_id_{ room_id } , client_{ client } { - QSettings settings; - local_user_ = settings.value("auth/user_id").toString(); - init(); addEvents(timeline); } @@ -69,9 +66,6 @@ TimelineView::TimelineView(QSharedPointer<MatrixClient> client, , room_id_{ room_id } , client_{ client } { - QSettings settings; - local_user_ = settings.value("auth/user_id").toString(); - init(); client_->messages(room_id_, ""); } @@ -86,6 +80,8 @@ TimelineView::sliderRangeChanged(int min, int max) return; } + // If the scrollbar is close to the bottom and a new message + // is added we move the scrollbar. if (max - scroll_area_->verticalScrollBar()->value() < SCROLL_BAR_GAP) scroll_area_->verticalScrollBar()->setValue(max); @@ -96,9 +92,8 @@ TimelineView::sliderRangeChanged(int min, int max) int diff = currentHeight - oldHeight_; int newPosition = oldPosition_ + diff; - // Keep the scroll bar to the bottom if we are coming from - // an scrollbar without height i.e scrollbar->value() == 0 - if (oldPosition_ == 0) + // Keep the scroll bar to the bottom if it hasn't been activated yet. + if (oldPosition_ == 0 && !scroll_area_->verticalScrollBar()->isVisible()) newPosition = max; scroll_area_->verticalScrollBar()->setValue(newPosition); @@ -108,7 +103,7 @@ TimelineView::sliderRangeChanged(int min, int max) void TimelineView::fetchHistory() { - bool hasEnoughMessages = scroll_area_->verticalScrollBar()->value() != 0; + bool hasEnoughMessages = scroll_area_->verticalScrollBar()->isVisible(); if (!hasEnoughMessages && !isTimelineFinished) { isPaginationInProgress_ = true; @@ -371,6 +366,9 @@ TimelineView::addEvents(const Timeline &timeline) void TimelineView::init() { + QSettings settings; + local_user_ = settings.value("auth/user_id").toString(); + top_layout_ = new QVBoxLayout(this); top_layout_->setSpacing(0); top_layout_->setMargin(0);