mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Guard against flickering for items added to the top of the timeline
This commit is contained in:
parent
27fed83083
commit
e9a8e51208
2 changed files with 12 additions and 7 deletions
|
@ -634,11 +634,11 @@ TimelineView::addTimelineItem(QWidget *item, TimelineDirection direction)
|
|||
auto separator = new DateSeparator(newDate, this);
|
||||
|
||||
if (separator)
|
||||
pushTimelineItem(separator);
|
||||
pushTimelineItem(separator, direction);
|
||||
}
|
||||
}
|
||||
|
||||
pushTimelineItem(item);
|
||||
pushTimelineItem(item, direction);
|
||||
} else {
|
||||
if (scroll_layout_->count() > 0) {
|
||||
const auto firstItem = scroll_layout_->itemAt(0)->widget();
|
||||
|
@ -650,12 +650,12 @@ TimelineView::addTimelineItem(QWidget *item, TimelineDirection direction)
|
|||
auto separator = new DateSeparator(oldDate);
|
||||
|
||||
if (separator)
|
||||
scroll_layout_->insertWidget(0, separator);
|
||||
pushTimelineItem(separator, direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scroll_layout_->insertWidget(0, item);
|
||||
pushTimelineItem(item, direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -194,17 +194,22 @@ private:
|
|||
void getMessages();
|
||||
//! HACK: Fixing layout flickering when adding to the bottom
|
||||
//! of the timeline.
|
||||
void pushTimelineItem(QWidget *item)
|
||||
void pushTimelineItem(QWidget *item, TimelineDirection dir)
|
||||
{
|
||||
setUpdatesEnabled(false);
|
||||
item->hide();
|
||||
scroll_layout_->addWidget(item);
|
||||
|
||||
if (dir == TimelineDirection::Top)
|
||||
scroll_layout_->insertWidget(0, item);
|
||||
else
|
||||
scroll_layout_->addWidget(item);
|
||||
|
||||
QTimer::singleShot(0, this, [item, this]() {
|
||||
item->show();
|
||||
item->adjustSize();
|
||||
setUpdatesEnabled(true);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
//! Decides whether or not to show or hide the scroll down button.
|
||||
void toggleScrollDownButton();
|
||||
|
|
Loading…
Reference in a new issue