mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 03:18:49 +03:00
Show the scroll-down button when showing the timeline
This commit is contained in:
parent
48dabdfdc7
commit
2274642f12
2 changed files with 19 additions and 9 deletions
|
@ -134,6 +134,8 @@ private:
|
|||
});
|
||||
};
|
||||
|
||||
//! Decides whether or not to show or hide the scroll down button.
|
||||
void toggleScrollDownButton();
|
||||
void init();
|
||||
void addTimelineItem(TimelineItem *item, TimelineDirection direction);
|
||||
void updateLastSender(const QString &user_id, TimelineDirection direction);
|
||||
|
|
|
@ -130,15 +130,7 @@ TimelineView::sliderMoved(int position)
|
|||
if (!scroll_area_->verticalScrollBar()->isVisible())
|
||||
return;
|
||||
|
||||
const int maxScroll = scroll_area_->verticalScrollBar()->maximum();
|
||||
const int currentScroll = scroll_area_->verticalScrollBar()->value();
|
||||
|
||||
if (maxScroll - currentScroll > SCROLL_BAR_GAP) {
|
||||
scrollDownBtn_->show();
|
||||
scrollDownBtn_->raise();
|
||||
} else {
|
||||
scrollDownBtn_->hide();
|
||||
}
|
||||
toggleScrollDownButton();
|
||||
|
||||
// The scrollbar is high enough so we can start retrieving old events.
|
||||
if (position < SCROLL_BAR_GAP) {
|
||||
|
@ -641,6 +633,8 @@ TimelineView::showEvent(QShowEvent *event)
|
|||
scrollDown();
|
||||
}
|
||||
|
||||
toggleScrollDownButton();
|
||||
|
||||
readLastEvent();
|
||||
|
||||
QWidget::showEvent(event);
|
||||
|
@ -766,3 +760,17 @@ TimelineView::getEventSender(const mtx::events::collections::TimelineEvents &eve
|
|||
|
||||
return QString("");
|
||||
}
|
||||
|
||||
void
|
||||
TimelineView::toggleScrollDownButton()
|
||||
{
|
||||
const int maxScroll = scroll_area_->verticalScrollBar()->maximum();
|
||||
const int currentScroll = scroll_area_->verticalScrollBar()->value();
|
||||
|
||||
if (maxScroll - currentScroll > SCROLL_BAR_GAP) {
|
||||
scrollDownBtn_->show();
|
||||
scrollDownBtn_->raise();
|
||||
} else {
|
||||
scrollDownBtn_->hide();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue