mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 13:08: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);
|
auto separator = new DateSeparator(newDate, this);
|
||||||
|
|
||||||
if (separator)
|
if (separator)
|
||||||
pushTimelineItem(separator);
|
pushTimelineItem(separator, direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pushTimelineItem(item);
|
pushTimelineItem(item, direction);
|
||||||
} else {
|
} else {
|
||||||
if (scroll_layout_->count() > 0) {
|
if (scroll_layout_->count() > 0) {
|
||||||
const auto firstItem = scroll_layout_->itemAt(0)->widget();
|
const auto firstItem = scroll_layout_->itemAt(0)->widget();
|
||||||
|
@ -650,12 +650,12 @@ TimelineView::addTimelineItem(QWidget *item, TimelineDirection direction)
|
||||||
auto separator = new DateSeparator(oldDate);
|
auto separator = new DateSeparator(oldDate);
|
||||||
|
|
||||||
if (separator)
|
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();
|
void getMessages();
|
||||||
//! HACK: Fixing layout flickering when adding to the bottom
|
//! HACK: Fixing layout flickering when adding to the bottom
|
||||||
//! of the timeline.
|
//! of the timeline.
|
||||||
void pushTimelineItem(QWidget *item)
|
void pushTimelineItem(QWidget *item, TimelineDirection dir)
|
||||||
{
|
{
|
||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
item->hide();
|
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]() {
|
QTimer::singleShot(0, this, [item, this]() {
|
||||||
item->show();
|
item->show();
|
||||||
item->adjustSize();
|
item->adjustSize();
|
||||||
setUpdatesEnabled(true);
|
setUpdatesEnabled(true);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
//! Decides whether or not to show or hide the scroll down button.
|
//! Decides whether or not to show or hide the scroll down button.
|
||||||
void toggleScrollDownButton();
|
void toggleScrollDownButton();
|
||||||
|
|
Loading…
Reference in a new issue