mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 03:18:49 +03:00
Hack to work around layout flickering when adding new timeline items
This commit is contained in:
parent
7792ca7149
commit
26540bd120
2 changed files with 16 additions and 3 deletions
|
@ -123,6 +123,17 @@ protected:
|
||||||
private:
|
private:
|
||||||
using TimelineEvent = mtx::events::collections::TimelineEvents;
|
using TimelineEvent = mtx::events::collections::TimelineEvents;
|
||||||
|
|
||||||
|
//! HACK: Fixing layout flickering when adding to the bottom
|
||||||
|
//! of the timeline.
|
||||||
|
void pushTimelineItem(TimelineItem *item)
|
||||||
|
{
|
||||||
|
item->hide();
|
||||||
|
QTimer::singleShot(0, this, [=]() {
|
||||||
|
scroll_layout_->addWidget(item);
|
||||||
|
item->show();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void addTimelineItem(TimelineItem *item, TimelineDirection direction);
|
void addTimelineItem(TimelineItem *item, TimelineDirection direction);
|
||||||
void updateLastSender(const QString &user_id, TimelineDirection direction);
|
void updateLastSender(const QString &user_id, TimelineDirection direction);
|
||||||
|
@ -229,7 +240,8 @@ TimelineView::addUserMessage(const QString &url,
|
||||||
|
|
||||||
TimelineItem *view_item =
|
TimelineItem *view_item =
|
||||||
new TimelineItem(widget, local_user_, with_sender, scroll_widget_);
|
new TimelineItem(widget, local_user_, with_sender, scroll_widget_);
|
||||||
scroll_layout_->addWidget(view_item);
|
|
||||||
|
pushTimelineItem(view_item);
|
||||||
|
|
||||||
lastMessageDirection_ = TimelineDirection::Bottom;
|
lastMessageDirection_ = TimelineDirection::Bottom;
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,7 @@ TimelineView::addTimelineItem(TimelineItem *item, TimelineDirection direction)
|
||||||
addDateSeparator(newDate, lastItemPosition);
|
addDateSeparator(newDate, lastItemPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
scroll_layout_->addWidget(item);
|
pushTimelineItem(item);
|
||||||
} else {
|
} else {
|
||||||
// The first item (position 0) is a stretch widget that pushes
|
// The first item (position 0) is a stretch widget that pushes
|
||||||
// the widgets to the bottom of the page.
|
// the widgets to the bottom of the page.
|
||||||
|
@ -479,7 +479,8 @@ TimelineView::addUserMessage(mtx::events::MessageType ty, const QString &body)
|
||||||
|
|
||||||
TimelineItem *view_item =
|
TimelineItem *view_item =
|
||||||
new TimelineItem(ty, local_user_, body, with_sender, scroll_widget_);
|
new TimelineItem(ty, local_user_, body, with_sender, scroll_widget_);
|
||||||
scroll_layout_->addWidget(view_item);
|
|
||||||
|
pushTimelineItem(view_item);
|
||||||
|
|
||||||
lastMessageDirection_ = TimelineDirection::Bottom;
|
lastMessageDirection_ = TimelineDirection::Bottom;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue